Spring-ldap Filter

Spring-ldap Filter 

类:
org.springframework.ldap.filter.AndFilter :且
org.springframework.ldap.filter.OrFilter :或者
org.springframework.ldap.filter.NotFilter :非
org.springframework.ldap.filter.PresentFilter :LDAP目中有存储属性的
org.springframework.ldap.filter.NotPresentFilter :LDAP目中有无存储属性的
org.springframework.ldap.filter.EqualsFilter :等于
org.springframework.ldap.filter.LikeFilter :等于
org.springframework.ldap.filter.WhitespaceWildcardsFilter : 模糊
org.springframework.ldap.filter.GreaterThanOrEqualsFilter :大于等于
org.springframework.ldap.filter.LessThanOrEqualsFilter : 小于等于

结构:

案例:

import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.ldap.filter.GreaterThanOrEqualsFilter;
import org.springframework.ldap.filter.LessThanOrEqualsFilter;
import org.springframework.ldap.filter.LikeFilter;
import org.springframework.ldap.filter.NotFilter;
import org.springframework.ldap.filter.NotPresentFilter;
import org.springframework.ldap.filter.OrFilter;
import org.springframework.ldap.filter.PresentFilter;
import org.springframework.ldap.filter.WhitespaceWildcardsFilter;

public class LdapFilterTest {

    /**
    * @param args
    */
    public static void main(String[] args) {
        // 且
        AndFilter filter = new AndFilter();
        // 等于
        filter.and(new EqualsFilter("objectclass", "person"));
        // 模糊
        filter.and(new WhitespaceWildcardsFilter("sn", "张三"));
        System.out.println(filter.encode());
  
        AndFilter filter2 = new AndFilter();
        // 等于
        filter2.and(new LikeFilter("cn","12121"));
        filter2.and(filter);
        System.out.println(filter2.encode());
  
        AndFilter filter3 = new AndFilter();
        // 小于等于
        filter3.and(new LessThanOrEqualsFilter("age","40"));
        filter3.and(filter2);
        System.out.println(filter3.encode());
  
        AndFilter filter4 = new AndFilter();
        // 大于等于
        filter4.and(new GreaterThanOrEqualsFilter("age","20"));
        filter4.and(filter3);
        System.out.println(filter4.encode());
  
        // 或者
        OrFilter filter5 = new OrFilter();
        filter5.or(new LikeFilter("cn","12120") );
        filter5.or(new WhitespaceWildcardsFilter("sn", "张三"));
        System.out.println(filter5.encode());
  
        // 非
        NotFilter filter6 = new NotFilter(new LikeFilter("cn","12120"));
        System.out.println(filter6.encode());
  
        // LDAP目中有无存储属性的
        NotPresentFilter filter7 = new NotPresentFilter("desc");
        System.out.println(filter7.encode());
  
        // LDAP目中有存储属性的
        PresentFilter filter8 = new PresentFilter("email");
        System.out.println(filter8.encode());

    }

}


你可能感兴趣的:(Spring-ldap Filter)