本文整理汇总了Java中javax.naming.ldap.Rdn.toAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Rdn.toAttributes方法的具体用法?Java Rdn.toAttributes怎么用?Java Rdn.toAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.ldap.Rdn
的用法示例。
在下文中一共展示了Rdn.toAttributes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRdnAttributes
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* Adds attributes from RDN to attrs if not already present.
* Note that if attrs already contains an attribute by the same name,
* or if the distinguished name is empty, then leave attrs unchanged.
*
* @param dn The non-null DN of the entry to add
* @param attrs The non-null attributes of entry to add
* @param directUpdate Whether attrs can be updated directly
* @returns Non-null attributes with attributes from the RDN added
*/
private static Attributes addRdnAttributes(String dn, Attributes attrs,
boolean directUpdate) throws NamingException {
// Handle the empty name
if (dn.equals("")) {
return attrs;
}
// Parse string name into list of RDNs
List<Rdn> rdnList = (new LdapName(dn)).getRdns();
// Get leaf RDN
Rdn rdn = rdnList.get(rdnList.size() - 1);
Attributes nameAttrs = rdn.toAttributes();
// Add attributes of RDN to attrs if not already there
NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
Attribute nameAttr;
while (enum_.hasMore()) {
nameAttr = enum_.next();
// If attrs already has the attribute, don't change or add to it
if (attrs.get(nameAttr.getID()) == null) {
/**
* When attrs.isCaseIgnored() is false, attrs.get() will
* return null when the case mis-matches for otherwise
* equal attrIDs.
* As the attrIDs' case is irrelevant for LDAP, ignore
* the case of attrIDs even when attrs.isCaseIgnored() is
* false. This is done by explicitly comparing the elements in
* the enumeration of IDs with their case ignored.
*/
if (!attrs.isCaseIgnored() &&
containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
continue;
}
if (!directUpdate) {
attrs = (Attributes)attrs.clone();
directUpdate = true;
}
attrs.put(nameAttr);
}
}
return attrs;
}
示例2: addRdnAttributes
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* Adds attributes from RDN to attrs if not already present.
* Note that if attrs already contains an attribute by the same name,
* or if the distinguished name is empty, then leave attrs unchanged.
*
* @param dn The non-null DN of the entry to add
* @param attrs The non-null attributes of entry to add
* @param directUpdate Whether attrs can be updated directly
* @return Non-null attributes with attributes from the RDN added
*/
private static Attributes addRdnAttributes(String dn, Attributes attrs,
boolean directUpdate) throws NamingException {
// Handle the empty name
if (dn.equals("")) {
return attrs;
}
// Parse string name into list of RDNs
List<Rdn> rdnList = (new LdapName(dn)).getRdns();
// Get leaf RDN
Rdn rdn = rdnList.get(rdnList.size() - 1);
Attributes nameAttrs = rdn.toAttributes();
// Add attributes of RDN to attrs if not already there
NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
Attribute nameAttr;
while (enum_.hasMore()) {
nameAttr = enum_.next();
// If attrs already has the attribute, don't change or add to it
if (attrs.get(nameAttr.getID()) == null) {
/**
* When attrs.isCaseIgnored() is false, attrs.get() will
* return null when the case mis-matches for otherwise
* equal attrIDs.
* As the attrIDs' case is irrelevant for LDAP, ignore
* the case of attrIDs even when attrs.isCaseIgnored() is
* false. This is done by explicitly comparing the elements in
* the enumeration of IDs with their case ignored.
*/
if (!attrs.isCaseIgnored() &&
containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
continue;
}
if (!directUpdate) {
attrs = (Attributes)attrs.clone();
directUpdate = true;
}
attrs.put(nameAttr);
}
}
return attrs;
}
示例3: addRdnAttributes
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* Adds attributes from RDN to attrs if not already present.
* Note that if attrs already contains an attribute by the same name,
* or if the distinguished name is empty, then leave attrs unchanged.
*
* @param dn The non-null DN of the entry to add
* @param attrs The non-null attributes of entry to add
* @param directUpdate Whether attrs can be updated directly
* @returns Non-null attributes with attributes from the RDN added
*/
private static Attributes addRdnAttributes(String dn, Attributes attrs,
boolean directUpdate) throws NamingException {
// Handle the empty name
if (dn.equals("")) {
return attrs;
}
// Parse string name into list of RDNs
//List<Rdn> rdnList = (new LdapName(dn)).rdns();
List rdnList = (new LdapName(dn)).getRdns();
// Get leaf RDN
//Rdn rdn = rdnList.get(rdnList.size() - 1);
Rdn rdn = (Rdn) rdnList.get(rdnList.size() - 1);
Attributes nameAttrs = rdn.toAttributes();
// Add attributes of RDN to attrs if not already there
NamingEnumeration enum_ = nameAttrs.getAll();
Attribute nameAttr;
while (enum_.hasMore()) {
nameAttr = (Attribute) enum_.next();
// If attrs already has the attribute, don't change or add to it
if (attrs.get(nameAttr.getID()) == null) {
/**
* When attrs.isCaseIgnored() is false, attrs.get() will
* return null when the case mis-matches for otherwise
* equal attrIDs.
* As the attrIDs' case is irrelevant for LDAP, ignore
* the case of attrIDs even when attrs.isCaseIgnored() is
* false. This is done by explicitly comparing the elements in
* the enumeration of IDs with their case ignored.
*/
if (!attrs.isCaseIgnored() &&
containsIgnoreCase(attrs.getIDs(), nameAttr.getID())) {
continue;
}
if (!directUpdate) {
attrs = (Attributes)attrs.clone();
directUpdate = true;
}
attrs.put(nameAttr);
}
}
return attrs;
}
示例4: testToAttributes001
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with the string
* "t=\\4C\\4c", notice that here the values are quoted.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes001() throws Exception {
BasicAttributes t = new BasicAttributes("t", "\\4C\\4C");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例5: testToAttributes002
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with the string
* "", notice that here the name is empty.
* </p>
* <p>
* The expected result is the map of the Rdn not null but empty.
* </p>
*/
public void testToAttributes002() throws Exception {
Rdn rdn = new Rdn("");
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
assertEquals(0, ba.size());
}
示例6: testToAttributes003
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with the string
* "t=hola", notice that here the values are not quoted.
* </p>
* <p>
* The expected result is the map of the Rdn."
* </p>
*/
public void testToAttributes003() throws Exception {
BasicAttributes t = new BasicAttributes("t", "hola");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例7: testToAttributes004
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with the string
* "t=", notice that here the values are not quoted.
* </p>
* <p>
* The expected result is the map of the Rdn."
* </p>
*/
public void testToAttributes004() throws Exception {
BasicAttributes t = new BasicAttributes("t", "");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例8: testToAttributes005
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with the string
* "t=test+a=test2+b=test3", notice that here the values are not
* quoted.
* </p>
* <p>
* The expected result is the map of the Rdn."
* </p>
*/
public void testToAttributes005() throws Exception {
BasicAttributes t = new BasicAttributes("t", "test+a=test2+b=test3");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例9: testToAttributes006
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with multiple
* values.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes006() throws Exception {
BasicAttributes t = new BasicAttributes("t", "test+a=test2");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例10: testToAttributes007
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with multiple
* values.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes007() throws Exception {
BasicAttributes t = new BasicAttributes("a", "test+a=test2");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例11: testToAttributes008
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with multiple
* values.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes008() throws Exception {
BasicAttributes t = new BasicAttributes("a", ">asd+t=t+t=t=s<asd");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例12: testToAttributes009
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with multiple
* values.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes009() throws Exception {
BasicAttributes t = new BasicAttributes("a", "+t=t=");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
assertNotNull(ba);
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}
示例13: testToAttributes010
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toAttributes()'
* </p>
* <p>
* Here we are testing if this method correctly returns the Rdn's contents
* as an Attributes map. For this test the Rdn is created with multiple
* values.
* </p>
* <p>
* The expected result is the map of the Rdn.
* </p>
*/
public void testToAttributes010() throws Exception {
BasicAttributes t = new BasicAttributes("a", "t=t");
Rdn rdn = new Rdn(t);
BasicAttributes ba = (BasicAttributes) rdn.toAttributes();
assertNotNull(ba);
NamingEnumeration ne = ba.getAll();
assertAttributesEqual(ne, t);
}