下面列出了怎么用javax.naming.CompoundName的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @param rootDn root context DN.
* @param dn DN to compute a relative name. DN must starts with rootDn.
* @return name relative to a root context DN.
*/
static Name getRelativeDN(final String rootDn, final String dn) throws NamingException {
CompoundName root = new CompoundName(rootDn, DN_SYNTAX);
CompoundName entry = new CompoundName(dn, DN_SYNTAX);
if (!entry.startsWith(root)) {
throw new NamingException("Dn " + dn + " is not from root DN " + rootDn);
}
return entry.getSuffix(root.size());
}
@Override
public Name parse(String name) throws NamingException {
return new CompoundName(name, sSyntax);
}
@Override
public Name parse(final String name) throws NamingException {
return new CompoundName(name, InVMNameParser.syntax);
}
@Override
public Name parse(final String name) throws NamingException {
return new CompoundName(name, InVMNameParser.syntax);
}
@Override
public Name parse(final String name) throws NamingException {
return new CompoundName(name, InVMNameParser.syntax);
}
private static Name newName(String name) throws InvalidNameException {
return new CompoundName(name, LdifScript.DN_SYNTAX);
}
public Name parse(String name) throws NamingException {
return new CompoundName(name, syntax);
}
@Override
public Name parse(final String name) throws NamingException {
return new CompoundName(name, PARSER_PROPERTIES);
}
/**
* Parses name into CompoundName using the following CompoundName properties:
* <p>
* jndi.syntax.direction = "left_to_right" jndi.syntax.separator = "/"
* jndi.syntax.ignorecase = "false" jndi.syntax.trimblanks = "yes"
* <p>
* Any characters '.' in the name <code>name</code> will be replaced with
* the separator character specified above, before parsing.
*
* @param name name to parse
* @throws NamingException if naming error occurrs
*/
public Name parse(String name) throws NamingException {
return new CompoundName(name.replace('.', '/'), syntax);
}
/**
* Parses name into CompoundName using the following CompoundName properties:
* <p>
* jndi.syntax.direction = "left_to_right" jndi.syntax.separator = "/"
* jndi.syntax.ignorecase = "false" jndi.syntax.trimblanks = "yes"
* <p>
* Any characters '.' in the name <code>name</code> will be replaced with
* the separator character specified above, before parsing.
*
* @param name name to parse
* @throws NamingException if naming error occurrs
*/
public Name parse(String name) throws NamingException {
return new CompoundName(name.replace('.', '/'), syntax);
}