javax.naming
Class CompositeName

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.naming.CompositeName
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Comparable sample code for java.lang.Comparable definition code for java.lang.Comparable <Object sample code for java.lang.Object definition code for java.lang.Object >, Name sample code for javax.naming.Name definition code for javax.naming.Name

public class CompositeName
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Name sample code for javax.naming.Name definition code for javax.naming.Name

This class represents a composite name -- a sequence of component names spanning multiple namespaces. Each component is a string name from the namespace of a naming system. If the component comes from a hierarchical namespace, that component can be further parsed into its atomic parts by using the CompoundName class.

The components of a composite name are numbered. The indexes of a composite name with N components range from 0 up to, but not including, N. This range may be written as [0,N). The most significant component is at index 0. An empty composite name has no components.

JNDI Composite Name Syntax

JNDI defines a standard string representation for composite names. This representation is the concatenation of the components of a composite name from left to right using the component separator (a forward slash character (/)) to separate each component. The JNDI syntax defines the following meta characters: Any occurrence of a leading quote, an escape preceding any meta character, an escape at the end of a component, or a component separator character in an unquoted component must be preceded by an escape character when that component is being composed into a composite name string. Alternatively, to avoid adding escape characters as described, the entire component can be quoted using matching single quotes or matching double quotes. A single quote occurring within a double-quoted component is not considered a meta character (and need not be escaped), and vice versa.

When two composite names are compared, the case of the characters is significant.

A leading component separator (the composite name string begins with a separator) denotes a leading empty component (a component consisting of an empty string). A trailing component separator (the composite name string ends with a separator) denotes a trailing empty component. Adjacent component separators denote an empty component.

Composite Name Examples

This table shows examples of some composite names. Each row shows the string form of a composite name and its corresponding structural form (CompositeName).

String Name CompositeName
"" {} (the empty name == new CompositeName("") == new CompositeName())
"x" {"x"}
"x/y" {"x", "y"}
"x/" {"x", ""}
"/x" {"", "x"}
"/" {""}
"//" {"", ""}
"/x/" {"", "x", ""}
"x//y" {"x", "", "y"}

Composition Examples

Here are some composition examples. The right column shows composing string composite names while the left column shows composing the corresponding CompositeNames. Notice that composing the string forms of two composite names simply involves concatenating their string forms together.

String Names CompositeNames
"x/y" + "/" = x/y/ {"x", "y"} + {""} = {"x", "y", ""}
"" + "x" = "x" {} + {"x"} = {"x"}
"/" + "x" = "/x" {""} + {"x"} = {"", "x"}
"x" + "" + "" = "x" {"x"} + {} + {} = {"x"}

Multithreaded Access

A CompositeName instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a CompositeName should lock the object.

Since:
1.3
See Also:
Serialized Form

Constructor Summary
  CompositeName sample code for javax.naming.CompositeName.CompositeName() definition code for javax.naming.CompositeName.CompositeName() ()
          Constructs a new empty composite name.
protected CompositeName sample code for javax.naming.CompositeName.CompositeName(java.util.Enumeration) definition code for javax.naming.CompositeName.CompositeName(java.util.Enumeration) (Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > comps)
          Constructs a new composite name instance using the components specified by 'comps'.
  CompositeName sample code for javax.naming.CompositeName.CompositeName(java.lang.String) definition code for javax.naming.CompositeName.CompositeName(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  n)
          Constructs a new composite name instance by parsing the string n using the composite name syntax (left-to-right, slash separated).
 
Method Summary
 Name sample code for javax.naming.Name definition code for javax.naming.Name add sample code for javax.naming.CompositeName.add(int, java.lang.String) definition code for javax.naming.CompositeName.add(int, java.lang.String) (int posn, String sample code for java.lang.String definition code for java.lang.String  comp)
          Adds a single component at a specified position within this composite name.
 Name sample code for javax.naming.Name definition code for javax.naming.Name add sample code for javax.naming.CompositeName.add(java.lang.String) definition code for javax.naming.CompositeName.add(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  comp)
          Adds a single component to the end of this composite name.
 Name sample code for javax.naming.Name definition code for javax.naming.Name addAll sample code for javax.naming.CompositeName.addAll(int, javax.naming.Name) definition code for javax.naming.CompositeName.addAll(int, javax.naming.Name) (int posn, Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
          Adds the components of a composite name -- in order -- at a specified position within this composite name.
 Name sample code for javax.naming.Name definition code for javax.naming.Name addAll sample code for javax.naming.CompositeName.addAll(javax.naming.Name) definition code for javax.naming.CompositeName.addAll(javax.naming.Name) (Name sample code for javax.naming.Name definition code for javax.naming.Name  suffix)
          Adds the components of a composite name -- in order -- to the end of this composite name.
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for javax.naming.CompositeName.clone() definition code for javax.naming.CompositeName.clone() ()
          Generates a copy of this composite name.
 int compareTo sample code for javax.naming.CompositeName.compareTo(java.lang.Object) definition code for javax.naming.CompositeName.compareTo(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares this CompositeName with the specified Object for order.
 boolean endsWith sample code for javax.naming.CompositeName.endsWith(javax.naming.Name) definition code for javax.naming.CompositeName.endsWith(javax.naming.Name) (Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
          Determines whether a composite name is a suffix of this composite name.
 boolean equals sample code for javax.naming.CompositeName.equals(java.lang.Object) definition code for javax.naming.CompositeName.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Determines whether two composite names are equal.
 String sample code for java.lang.String definition code for java.lang.String get sample code for javax.naming.CompositeName.get(int) definition code for javax.naming.CompositeName.get(int) (int posn)
          Retrieves a component of this composite name.
 Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > getAll sample code for javax.naming.CompositeName.getAll() definition code for javax.naming.CompositeName.getAll() ()
          Retrieves the components of this composite name as an enumeration of strings.
 Name sample code for javax.naming.Name definition code for javax.naming.Name getPrefix sample code for javax.naming.CompositeName.getPrefix(int) definition code for javax.naming.CompositeName.getPrefix(int) (int posn)
          Creates a composite name whose components consist of a prefix of the components in this composite name.
 Name sample code for javax.naming.Name definition code for javax.naming.Name getSuffix sample code for javax.naming.CompositeName.getSuffix(int) definition code for javax.naming.CompositeName.getSuffix(int) (int posn)
          Creates a composite name whose components consist of a suffix of the components in this composite name.
 int hashCode sample code for javax.naming.CompositeName.hashCode() definition code for javax.naming.CompositeName.hashCode() ()
          Computes the hash code of this composite name.
 boolean isEmpty sample code for javax.naming.CompositeName.isEmpty() definition code for javax.naming.CompositeName.isEmpty() ()
          Determines whether this composite name is empty.
 Object sample code for java.lang.Object definition code for java.lang.Object remove sample code for javax.naming.CompositeName.remove(int) definition code for javax.naming.CompositeName.remove(int) (int posn)
          Deletes a component from this composite name.
 int size sample code for javax.naming.CompositeName.size() definition code for javax.naming.CompositeName.size() ()
          Retrieves the number of components in this composite name.
 boolean startsWith sample code for javax.naming.CompositeName.startsWith(javax.naming.Name) definition code for javax.naming.CompositeName.startsWith(javax.naming.Name) (Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
          Determines whether a composite name is a prefix of this composite name.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.naming.CompositeName.toString() definition code for javax.naming.CompositeName.toString() ()
          Generates the string representation of this composite name.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

CompositeName sample code for javax.naming.CompositeName(java.util.Enumeration<java.lang.String>) definition code for javax.naming.CompositeName(java.util.Enumeration<java.lang.String>)

protected CompositeName(Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > comps)
Constructs a new composite name instance using the components specified by 'comps'. This protected method is intended to be to be used by subclasses of CompositeName when they override methods such as clone(), getPrefix(), getSuffix().

Parameters:
comps - A non-null enumeration containing the components for the new composite name. Each element is of class String. The enumeration will be consumed to extract its elements.

CompositeName sample code for javax.naming.CompositeName(java.lang.String) definition code for javax.naming.CompositeName(java.lang.String)

public CompositeName(String sample code for java.lang.String definition code for java.lang.String  n)
              throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Constructs a new composite name instance by parsing the string n using the composite name syntax (left-to-right, slash separated). The composite name syntax is described in detail in the class description.

Parameters:
n - The non-null string to parse.
Throws:
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If n has invalid composite name syntax.

CompositeName sample code for javax.naming.CompositeName() definition code for javax.naming.CompositeName()

public CompositeName()
Constructs a new empty composite name. Such a name returns true when isEmpty() is invoked on it.

Method Detail

toString sample code for javax.naming.CompositeName.toString() definition code for javax.naming.CompositeName.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Generates the string representation of this composite name. The string representation consists of enumerating in order each component of the composite name and separating each component by a forward slash character. Quoting and escape characters are applied where necessary according to the JNDI syntax, which is described in the class description. An empty component is represented by an empty string. The string representation thus generated can be passed to the CompositeName constructor to create a new equivalent composite name.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
A non-null string representation of this composite name.

equals sample code for javax.naming.CompositeName.equals(java.lang.Object) definition code for javax.naming.CompositeName.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Determines whether two composite names are equal. If obj is null or not a composite name, false is returned. Two composite names are equal if each component in one is equal to the corresponding component in the other. This implies both have the same number of components, and each component's equals() test against the corresponding component in the other name returns true.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - The possibly null object to compare against.
Returns:
true if obj is equal to this composite name, false otherwise.
See Also:
hashCode() sample code for javax.naming.CompositeName.hashCode() definition code for javax.naming.CompositeName.hashCode()

hashCode sample code for javax.naming.CompositeName.hashCode() definition code for javax.naming.CompositeName.hashCode()

public int hashCode()
Computes the hash code of this composite name. The hash code is the sum of the hash codes of individual components of this composite name.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
An int representing the hash code of this name.
See Also:
equals(java.lang.Object) sample code for javax.naming.CompositeName.equals(java.lang.Object) definition code for javax.naming.CompositeName.equals(java.lang.Object)

compareTo sample code for javax.naming.CompositeName.compareTo(java.lang.Object) definition code for javax.naming.CompositeName.compareTo(java.lang.Object)

public int compareTo(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares this CompositeName with the specified Object for order. Returns a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object.

If obj is null or not an instance of CompositeName, ClassCastException is thrown.

See equals() for what it means for two composite names to be equal. If two composite names are equal, 0 is returned.

Ordering of composite names follows the lexicographical rules for string comparison, with the extension that this applies to all the components in the composite name. The effect is as if all the components were lined up in their specified ordered and the lexicographical rules applied over the two line-ups. If this composite name is "lexicographically" lesser than obj, a negative number is returned. If this composite name is "lexicographically" greater than obj, a positive number is returned.

Specified by:
compareTo sample code for java.lang.Comparable.compareTo(T) definition code for java.lang.Comparable.compareTo(T) in interface Comparable sample code for java.lang.Comparable definition code for java.lang.Comparable <Object sample code for java.lang.Object definition code for java.lang.Object >
Specified by:
compareTo sample code for javax.naming.Name.compareTo(java.lang.Object) definition code for javax.naming.Name.compareTo(java.lang.Object) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
obj - The non-null object to compare against.
Returns:
a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object.
Throws:
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if obj is not a CompositeName.
See Also:
Comparable.compareTo(Object) sample code for java.lang.Comparable.compareTo(T) definition code for java.lang.Comparable.compareTo(T)

clone sample code for javax.naming.CompositeName.clone() definition code for javax.naming.CompositeName.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
Generates a copy of this composite name. Changes to the components of this composite name won't affect the new copy and vice versa.

Specified by:
clone sample code for javax.naming.Name.clone() definition code for javax.naming.Name.clone() in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Overrides:
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
A non-null copy of this composite name.
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

size sample code for javax.naming.CompositeName.size() definition code for javax.naming.CompositeName.size()

public int size()
Retrieves the number of components in this composite name.

Specified by:
size sample code for javax.naming.Name.size() definition code for javax.naming.Name.size() in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Returns:
The nonnegative number of components in this composite name.

isEmpty sample code for javax.naming.CompositeName.isEmpty() definition code for javax.naming.CompositeName.isEmpty()

public boolean isEmpty()
Determines whether this composite name is empty. A composite name is empty if it has zero components.

Specified by:
isEmpty sample code for javax.naming.Name.isEmpty() definition code for javax.naming.Name.isEmpty() in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Returns:
true if this composite name is empty, false otherwise.

getAll sample code for javax.naming.CompositeName.getAll() definition code for javax.naming.CompositeName.getAll()

public Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > getAll()
Retrieves the components of this composite name as an enumeration of strings. The effects of updates to this composite name on this enumeration is undefined.

Specified by:
getAll sample code for javax.naming.Name.getAll() definition code for javax.naming.Name.getAll() in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Returns:
A non-null enumeration of the components of this composite name. Each element of the enumeration is of class String.

get sample code for javax.naming.CompositeName.get(int) definition code for javax.naming.CompositeName.get(int)

public String sample code for java.lang.String definition code for java.lang.String  get(int posn)
Retrieves a component of this composite name.

Specified by:
get sample code for javax.naming.Name.get(int) definition code for javax.naming.Name.get(int) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
posn - The 0-based index of the component to retrieve. Must be in the range [0,size()).
Returns:
The non-null component at index posn.
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - if posn is outside the specified range.

getPrefix sample code for javax.naming.CompositeName.getPrefix(int) definition code for javax.naming.CompositeName.getPrefix(int)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  getPrefix(int posn)
Creates a composite name whose components consist of a prefix of the components in this composite name. Subsequent changes to this composite name does not affect the name that is returned.

Specified by:
getPrefix sample code for javax.naming.Name.getPrefix(int) definition code for javax.naming.Name.getPrefix(int) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
posn - The 0-based index of the component at which to stop. Must be in the range [0,size()].
Returns:
A composite name consisting of the components at indexes in the range [0,posn).
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.

getSuffix sample code for javax.naming.CompositeName.getSuffix(int) definition code for javax.naming.CompositeName.getSuffix(int)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  getSuffix(int posn)
Creates a composite name whose components consist of a suffix of the components in this composite name. Subsequent changes to this composite name does not affect the name that is returned.

Specified by:
getSuffix sample code for javax.naming.Name.getSuffix(int) definition code for javax.naming.Name.getSuffix(int) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
posn - The 0-based index of the component at which to start. Must be in the range [0,size()].
Returns:
A composite name consisting of the components at indexes in the range [posn,size()). If posn is equal to size(), an empty composite name is returned.
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.

startsWith sample code for javax.naming.CompositeName.startsWith(javax.naming.Name) definition code for javax.naming.CompositeName.startsWith(javax.naming.Name)

public boolean startsWith(Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
Determines whether a composite name is a prefix of this composite name. A composite name 'n' is a prefix if it is equal to getPrefix(n.size())--in other words, this composite name starts with 'n'. If 'n' is null or not a composite name, false is returned.

Specified by:
startsWith sample code for javax.naming.Name.startsWith(javax.naming.Name) definition code for javax.naming.Name.startsWith(javax.naming.Name) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
n - The possibly null name to check.
Returns:
true if n is a CompositeName and is a prefix of this composite name, false otherwise.

endsWith sample code for javax.naming.CompositeName.endsWith(javax.naming.Name) definition code for javax.naming.CompositeName.endsWith(javax.naming.Name)

public boolean endsWith(Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
Determines whether a composite name is a suffix of this composite name. A composite name 'n' is a suffix if it it is equal to getSuffix(size()-n.size())--in other words, this composite name ends with 'n'. If n is null or not a composite name, false is returned.

Specified by:
endsWith sample code for javax.naming.Name.endsWith(javax.naming.Name) definition code for javax.naming.Name.endsWith(javax.naming.Name) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
n - The possibly null name to check.
Returns:
true if n is a CompositeName and is a suffix of this composite name, false otherwise.

addAll sample code for javax.naming.CompositeName.addAll(javax.naming.Name) definition code for javax.naming.CompositeName.addAll(javax.naming.Name)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  addAll(Name sample code for javax.naming.Name definition code for javax.naming.Name  suffix)
            throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Adds the components of a composite name -- in order -- to the end of this composite name.

Specified by:
addAll sample code for javax.naming.Name.addAll(javax.naming.Name) definition code for javax.naming.Name.addAll(javax.naming.Name) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
suffix - The non-null components to add.
Returns:
The updated CompositeName, not a new one. Cannot be null.
Throws:
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If suffix is not a composite name.

addAll sample code for javax.naming.CompositeName.addAll(int, javax.naming.Name) definition code for javax.naming.CompositeName.addAll(int, javax.naming.Name)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  addAll(int posn,
                   Name sample code for javax.naming.Name definition code for javax.naming.Name  n)
            throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Adds the components of a composite name -- in order -- at a specified position within this composite name. Components of this composite name at or after the index of the first new component are shifted up (away from index 0) to accommodate the new components.

Specified by:
addAll sample code for javax.naming.Name.addAll(int, javax.naming.Name) definition code for javax.naming.Name.addAll(int, javax.naming.Name) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
n - The non-null components to add.
posn - The index in this name at which to add the new components. Must be in the range [0,size()].
Returns:
The updated CompositeName, not a new one. Cannot be null.
Throws:
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If n is not a composite name.
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.

add sample code for javax.naming.CompositeName.add(java.lang.String) definition code for javax.naming.CompositeName.add(java.lang.String)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  add(String sample code for java.lang.String definition code for java.lang.String  comp)
         throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Adds a single component to the end of this composite name.

Specified by:
add sample code for javax.naming.Name.add(java.lang.String) definition code for javax.naming.Name.add(java.lang.String) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
comp - The non-null component to add.
Returns:
The updated CompositeName, not a new one. Cannot be null.
Throws:
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If adding comp at end of the name would violate the name's syntax.

add sample code for javax.naming.CompositeName.add(int, java.lang.String) definition code for javax.naming.CompositeName.add(int, java.lang.String)

public Name sample code for javax.naming.Name definition code for javax.naming.Name  add(int posn,
                String sample code for java.lang.String definition code for java.lang.String  comp)
         throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Adds a single component at a specified position within this composite name. Components of this composite name at or after the index of the new component are shifted up by one (away from index 0) to accommodate the new component.

Specified by:
add sample code for javax.naming.Name.add(int, java.lang.String) definition code for javax.naming.Name.add(int, java.lang.String) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
comp - The non-null component to add.
posn - The index at which to add the new component. Must be in the range [0,size()].
Returns:
The updated CompositeName, not a new one. Cannot be null.
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If adding comp at the specified position would violate the name's syntax.

remove sample code for javax.naming.CompositeName.remove(int) definition code for javax.naming.CompositeName.remove(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  remove(int posn)
              throws InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException 
Deletes a component from this composite name. The component of this composite name at position 'posn' is removed, and components at indices greater than 'posn' are shifted down (towards index 0) by one.

Specified by:
remove sample code for javax.naming.Name.remove(int) definition code for javax.naming.Name.remove(int) in interface Name sample code for javax.naming.Name definition code for javax.naming.Name
Parameters:
posn - The index of the component to delete. Must be in the range [0,size()).
Returns:
The component removed (a String).
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range (includes case where composite name is empty).
InvalidNameException sample code for javax.naming.InvalidNameException definition code for javax.naming.InvalidNameException - If deleting the component would violate the name's syntax.