本文整理汇总了Java中org.apache.harmony.jndi.provider.ldap.Filter.SubstringFilter类的典型用法代码示例。如果您正苦于以下问题:Java SubstringFilter类的具体用法?Java SubstringFilter怎么用?Java SubstringFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubstringFilter类属于org.apache.harmony.jndi.provider.ldap.Filter包,在下文中一共展示了SubstringFilter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_encodeValues
import org.apache.harmony.jndi.provider.ldap.Filter.SubstringFilter; //导入依赖的package包/类
public void test_encodeValues() {
// simple filter
filter = new Filter(Filter.APPROX_MATCH_FILTER);
filter.setValue(new AttributeTypeAndValuePair("cn", "test"));
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
filter = new Filter(Filter.EXTENSIBLE_MATCH_FILTER);
MatchingRuleAssertion value = new MatchingRuleAssertion();
value.setDnAttributes(true);
assertTrue(value.isDnAttributes());
value.setMatchingRule("equal");
assertEquals("equal", value.getMatchingRule());
value.setMatchValue("cn");
assertEquals("cn", value.getMatchValue());
value.setType("type");
assertEquals("type", value.getType());
filter.setValue(value);
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
// composite filter
filter = new Filter(Filter.AND_FILTER);
Filter equal = new Filter(Filter.EQUALITY_MATCH_FILTER);
equal.setValue(new AttributeTypeAndValuePair("sn", "tom"));
filter.addChild(equal);
Filter substring = new Filter(Filter.SUBSTRINGS_FILTER);
SubstringFilter sub = new SubstringFilter("o");
sub.addAny("harmony");
sub.addFinal("good");
substring.setValue(sub);
filter.addChild(substring);
Filter present = new Filter(Filter.PRESENT_FILTER);
present.setValue("objectClass");
filter.addChild(present);
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
// more complex filter
Filter or = new Filter(Filter.OR_FILTER);
Filter not = new Filter(Filter.NOT_FILTER);
Filter greater = new Filter(Filter.GREATER_OR_EQUAL_FILTER);
greater.setValue(new AttributeTypeAndValuePair("cn", "hello"));
not.setValue(greater);
or.addChild(not);
Filter less = new Filter(Filter.LESS_OR_EQUAL_FILTER);
less.setValue(new AttributeTypeAndValuePair("o", "apache"));
or.addChild(less);
filter.addChild(or);
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
}