本文整理匯總了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);
}