Example usage for javax.naming CompositeName size

List of usage examples for javax.naming CompositeName size

Introduction

In this page you can find the example usage for javax.naming CompositeName size.

Prototype

public int size() 

Source Link

Document

Retrieves the number of components in this composite name.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    CompositeName composite = new CompositeName("cn=John,o=hits/summary.txt");
    String first = composite.get(0);
    String last = composite.get(composite.size() - 1);

    composite.add(0, "yourname.com");
    composite.remove(2);//  www.  ja v  a2 s .c o m
}

From source file:org.eclipse.ecr.runtime.jtajca.NuxeoContainer.java

protected static void addDeepBinding(Context dir, CompositeName comp, Object obj) throws NamingException {
    Name name = comp.getPrefix(1);
    if (comp.size() == 1) {
        addBinding(dir, name, obj);//from  w  w  w  .j a v a  2  s .co  m
        return;
    }
    Context subdir;
    try {
        subdir = (Context) dir.lookup(name);
    } catch (NamingException e) {
        subdir = dir.createSubcontext(name);
    }
    addDeepBinding(subdir, (CompositeName) comp.getSuffix(1), obj);
}

From source file:org.springframework.ldap.support.LdapUtils.java

/**
 * Converts a CompositeName to a String in a way that avoids escaping
 * problems, such as the dreaded "triple backslash" problem.
 * /* w w w.j av  a  2  s. c o  m*/
 * @param compositeName The CompositeName to convert
 * @return String containing the String representation of <code>name</code>
 */
public static String convertCompositeNameToString(CompositeName compositeName) {
    if (compositeName.size() > 0) {
        // A lookup with an empty String seems to produce an empty
        // compositeName here; need to take this into account.
        return compositeName.get(0);
    } else {
        return "";
    }
}