本文整理汇总了Java中org.springframework.ldap.filter.NotFilter类的典型用法代码示例。如果您正苦于以下问题:Java NotFilter类的具体用法?Java NotFilter怎么用?Java NotFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotFilter类属于org.springframework.ldap.filter包,在下文中一共展示了NotFilter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: negateIfApplicable
import org.springframework.ldap.filter.NotFilter; //导入依赖的package包/类
private Filter negateIfApplicable(Filter myFilter) {
if (negated) {
return new NotFilter(myFilter);
}
return myFilter;
}
示例2: search
import org.springframework.ldap.filter.NotFilter; //导入依赖的package包/类
public <T> List<T> search(Class<T> type, Map<String, Object> criteria) {
AndFilter filter = new AndFilter();
for (Map.Entry<String, Object> entry : criteria.entrySet()) {
//attempting to handle null values to prevent NPEs in this code.
if (entry.getValue() == null) {
entry.setValue("null");
}
if (entry.getValue() instanceof Iterable) {
OrFilter orFilter = new OrFilter();
for (String value : (Iterable<String>) entry.getValue()) {
if (value.startsWith("!")) {
orFilter.or(new NotFilter(new LikeFilter(entry.getKey(), value.substring(1))));
} else {
orFilter.or(new LikeFilter(entry.getKey(), value));
}
}
filter.and(orFilter);
}
else {
if (((String)entry.getValue()).startsWith("!")) {
filter.and(new NotFilter(new LikeFilter(entry.getKey(), ((String)entry.getValue()).substring(1))));
} else {
filter.and(new LikeFilter(entry.getKey(), (String) entry.getValue()));
}
}
};
info("Using filter ", filter);
debug("Looking up mapper for ", type.getSimpleName());
final ContextMapper customMapper = contextMappers.get(type.getSimpleName());
ContextMapperCallbackHandler callbackHandler = new CustomContextMapperCallbackHandler(customMapper);
try {
getLdapTemplate().search(DistinguishedName.EMPTY_PATH,
filter.encode(),
getSearchControls(), callbackHandler);
}
catch (SizeLimitExceededException e) {
// Ignore this. We want to limit our results.
}
return callbackHandler.getList();
}