Example usage for javax.naming CompositeName get

List of usage examples for javax.naming CompositeName get

Introduction

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

Prototype

public String get(int posn) 

Source Link

Document

Retrieves a component of 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);//from   www.j  a va2 s .co  m
}

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.
 * /*from   w  w w . ja v  a2  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 "";
    }
}