本文整理汇总了Java中com.sun.jndi.ldap.LdapURL.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java LdapURL.getAttributes方法的具体用法?Java LdapURL.getAttributes怎么用?Java LdapURL.getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jndi.ldap.LdapURL
的用法示例。
在下文中一共展示了LdapURL.getAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSearchControlsUsingURL
import com.sun.jndi.ldap.LdapURL; //导入方法依赖的package包/类
private static SearchControls setSearchControlsUsingURL(LdapURL url) {
SearchControls cons = new SearchControls();
String scope = url.getScope();
String attributes = url.getAttributes();
if (scope == null) {
cons.setSearchScope(SearchControls.OBJECT_SCOPE); //default value
} else {
if (scope.equals("sub")) {
cons.setSearchScope(SearchControls.SUBTREE_SCOPE);
} else if (scope.equals("one")) {
cons.setSearchScope(SearchControls.ONELEVEL_SCOPE);
} else if (scope.equals("base")) {
cons.setSearchScope(SearchControls.OBJECT_SCOPE);
}
}
if (attributes == null) {
cons.setReturningAttributes(null); //default value
} else {
StringTokenizer tokens = new StringTokenizer(attributes, ",");
int count = tokens.countTokens();
String[] attrs = new String[count];
for (int i = 0; i < count; i ++) {
attrs[i] = tokens.nextToken();
}
cons.setReturningAttributes(attrs);
}
return cons;
}
示例2: checkEmptyAttributes
import com.sun.jndi.ldap.LdapURL; //导入方法依赖的package包/类
private static void checkEmptyAttributes(String urlString) throws Exception {
LdapURL url = new LdapURL(urlString);
if (url.getAttributes() != null) {
throw new Exception("Expected null attributes for url: '" + urlString + "'");
}
if (url.getScope() != null) {
throw new Exception("Expected null scope for url: '" + urlString + "'");
}
if (url.getFilter() != null) {
throw new Exception("Expected null filter for url: '" + urlString + "'");
}
}