本文整理匯總了Java中javax.naming.NameClassPair.setNameInNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java NameClassPair.setNameInNamespace方法的具體用法?Java NameClassPair.setNameInNamespace怎麽用?Java NameClassPair.setNameInNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.NameClassPair
的用法示例。
在下文中一共展示了NameClassPair.setNameInNamespace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: next
import javax.naming.NameClassPair; //導入方法依賴的package包/類
public NameClassPair next() throws NamingException, NoSuchElementException {
if (!hasMore()) {
throw new NoSuchElementException();
}
String name = names[index++];
NameClassPair pair = new NameClassPair(name, Object.class.getName());
pair.setNameInNamespace(name);
return pair;
}
示例2: addToEnumeration
import javax.naming.NameClassPair; //導入方法依賴的package包/類
private void addToEnumeration() {
if (enumeration == null || entries == null || entries.isEmpty()) {
return;
}
List<Object> list = new ArrayList<Object>();
HashMap<String, Attributes> tempEntries = null;
synchronized (entries) {
tempEntries = (HashMap<String, Attributes>) entries.clone();
entries.clear();
}
try {
for (String dn : tempEntries.keySet()) {
String relativeName = LdapUtils.convertToRelativeName(dn,
baseDN);
Attributes attrs = tempEntries.get(dn);
Attribute attrClass = attrs.get("javaClassName"); //$NON-NLS-1$
String className = null;
switch (enumerationType) {
case 1:
if (attrClass != null) {
className = (String) attrClass.get(0);
} else {
className = DirContext.class.getName();
}
NameClassPair pair = new NameClassPair(relativeName,
className, true);
pair.setNameInNamespace(dn);
list.add(pair);
break;
case 2:
Object bound = null;
if (attrClass != null) {
className = (String) attrClass.get(0);
bound = context.lookup(name);
} else {
className = DirContext.class.getName();
bound = new LdapContextImpl(context, baseDN);
}
Binding binding = new Binding(relativeName, className,
bound);
binding.setNameInNamespace(dn);
list.add(binding);
break;
case 3:
SearchResult sr = null;
if (dn.startsWith("ldap://")) {
sr = new SearchResult(dn, null, attrs, false);
int index = dn.indexOf("/", 7);
sr.setNameInNamespace(dn.substring(index + 1, dn
.length()));
} else {
sr = new SearchResult(relativeName, null, attrs);
sr.setNameInNamespace(dn);
}
list.add(sr);
break;
}
}
} catch (NamingException e) {
ex = e;
isFinished = true;
}
enumeration.setException(ex);
enumeration.add(list, isFinished);
}