Example usage for javax.naming Name add

List of usage examples for javax.naming Name add

Introduction

In this page you can find the example usage for javax.naming Name add.

Prototype

public Name add(int posn, String comp) throws InvalidNameException;

Source Link

Document

Adds a single component at a specified position within this name.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String url = "iiop://localhost/";
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    Context ctx = new InitialContext(env);
    NameParser parser = ctx.getNameParser("");
    Name dn = parser.parse("cn=John, ou=People, o=JNDITutorial");

    dn.remove(1);/* w  w w . j  a va2s  .c  om*/
    dn.add(0, "c=us");
    dn.add("cn=fs");
}