本文整理汇总了Java中org.springframework.ldap.filter.LikeFilter类的典型用法代码示例。如果您正苦于以下问题:Java LikeFilter类的具体用法?Java LikeFilter怎么用?Java LikeFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LikeFilter类属于org.springframework.ldap.filter包,在下文中一共展示了LikeFilter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagLogBySwissEduPersonCardUID
import org.springframework.ldap.filter.LikeFilter; //导入依赖的package包/类
public TagLog getTagLogBySwissEduPersonCardUID(String cardUID, String cardUidType) {
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person"));
filter.and(new LikeFilter("swissEduPersonCardUID", cardUID + "@" + cardUidType));
List<TagLog> tagLogs = ldapTemplate.search("", filter.encode(),
new TagLogLdapAttributMapper(cardUidType));
if(!tagLogs.isEmpty()) {
log.info("Got ldap entry from : " + ((LdapContextSource)ldapTemplate.getContextSource()).getUrls() + "for this swissEduPersonCardUID " + cardUID + "@" + cardUidType);
return tagLogs.get(0);
} else {
log.warn("Got NO ldap entry from : " + ((LdapContextSource)ldapTemplate.getContextSource()).getUrls() + "for this swissEduPersonCardUID " + cardUID + "@" + cardUidType);
return null;
}
}
示例2: search
import org.springframework.ldap.filter.LikeFilter; //导入依赖的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();
}
示例3: like
import org.springframework.ldap.filter.LikeFilter; //导入依赖的package包/类
@Override
public ContainerCriteria like(String value) {
return appendToParent(new LikeFilter(attribute, value));
}