本文整理汇总了Java中javax.naming.Binding.setNameInNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java Binding.setNameInNamespace方法的具体用法?Java Binding.setNameInNamespace怎么用?Java Binding.setNameInNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.Binding
的用法示例。
在下文中一共展示了Binding.setNameInNamespace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: next
import javax.naming.Binding; //导入方法依赖的package包/类
public Binding next() throws NoSuchElementException, NamingException {
if (!hasMore()) {
throw new NoSuchElementException();
}
String name = names[index++];
Binding binding = new Binding(name, context.lookup(name));
binding.setNameInNamespace(name);
return binding;
}
示例2: addToEnumeration
import javax.naming.Binding; //导入方法依赖的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);
}