All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface javax.naming.Name

public interface Name
extends Cloneable, Serializable
The Name interface represents a generic name -- an ordered sequence of components. It can be a composite name (names that span multiple namespaces), or a compound name (names that are used within hierarchical naming systems).

There can be different implementations of Name (e.g. composite names, URLs, namespace-specific compound names).

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


Method Index

 o add(int, String)
Adds a single component at a specified position within this name.
 o add(String)
Adds a single component to the end of this name.
 o addAll(int, Name)
Adds the components of a name -- in order -- at a specified position within this name.
 o addAll(Name)
Adds the components of a name -- in order -- to the end of this name.
 o clone()
Generates a copy of this name.
 o compareTo(Object)
Compares this Name with the specified Object for order.
 o endsWith(Name)
Determines whether this name ends with a specified suffix.
 o get(int)
Retrieves a component of this name.
 o getAll()
Retrieves the components of this name as an enumeration of strings.
 o getPrefix(int)
Creates a name whose components consist of a prefix of the components in this name.
 o getSuffix(int)
Creates a name whose components consist of a suffix of the components in this name.
 o isEmpty()
Determines whether this name is empty.
 o remove(int)
Removes a component from this name.
 o size()
Retrieves the number of components in this name.
 o startsWith(Name)
Determines whether this name starts with a specified prefix.

Methods

 o clone
 public abstract Object clone()
Generates a copy of this name. Implementations of Name defines what a "copy" is.

Returns:
A non-null copy of this name.
Overrides:
clone in class Object
See Also:
clone
 o compareTo
 public abstract int compareTo(Object obj)
Compares this Name 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. Similar to Object.equals(), the notion of ordering for names depends on the class that implements the Name interface. For example, a common ordering scheme is based on lexicographical ordering of strings. Specific attributes of the name, such as how it treats letter cases, may affect the order.

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
if obj is not a Name.
See Also:
equals
 o size
 public abstract int size()
Retrieves the number of components in this name.

Returns:
The nonnegative number of components in this name.
 o isEmpty
 public abstract boolean isEmpty()
Determines whether this name is empty. A name with zero components is empty.

Returns:
true if this name is empty, false otherwise.
 o getAll
 public abstract Enumeration getAll()
Retrieves the components of this name as an enumeration of strings. The effects of updates to this Name on this enumeration are undefined. If the name has zero components, an empty (non-null) enumeration is returned.

Returns:
A non-null enumeration of the components of this name.
 o get
 public abstract String get(int posn)
Retrieves a component of this 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
if posn is outside the specified range.
 o getPrefix
 public abstract Name getPrefix(int posn)
Creates a name whose components consist of a prefix of the components in this name. Subsequent changes to this name do not affect the name that is returned and vice versa.

Parameters:
posn - The 0-based index of the component at which to stop. Must be in the range [0,size()].
Returns:
A non-null name consisting of the components at indexes in the range [0,posn).
Throws: ArrayIndexOutOfBoundsException
if posn is outside the specified range.
 o getSuffix
 public abstract Name getSuffix(int posn)
Creates a name whose components consist of a suffix of the components in this name. Subsequent changes to this name do not affect the name that is returned and vice versa.

Parameters:
posn - The 0-based index of the component at which to start. Must be in the range [0,size()].
Returns:
A name consisting of the components at indexes in the range [posn,size()). If posn is equal to size(), an empty name is returned.
Throws: ArrayIndexOutOfBoundsException
If posn is outside the specified range.
 o startsWith
 public abstract boolean startsWith(Name n)
Determines whether this name starts with a specified prefix. A name 'n' is a prefix if it is equal to getPrefix(n.size()).

Parameters:
n - The possibly null name to check.
Returns:
true if n is a prefix of this name, false otherwise.
 o endsWith
 public abstract boolean endsWith(Name n)
Determines whether this name ends with a specified suffix. A name 'n' is a suffix if it it is equal to getSuffix(size()-n.size()).

Parameters:
n - The possibly null name to check.
Returns:
true if n is a suffix of this name, false otherwise.
 o addAll
 public abstract Name addAll(Name suffix) throws InvalidNameException
Adds the components of a name -- in order -- to the end of this name.

Parameters:
suffix - The components to add.
Returns:
The updated Name, not a new one. Cannot be null.
Throws: InvalidNameException
If suffix is not a valid name, or if the addition of the components violates the syntax of the name (e.g. exceeding number of components).
 o addAll
 public abstract Name addAll(int posn,
                             Name n) throws InvalidNameException
Adds the components of a name -- in order -- at a specified position within this name. Components of this name at or after the index of the first new component are shifted up (away from 0) to accommodate the new components.

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 Name, not a new one. Cannot be null.
Throws: ArrayIndexOutOfBoundsException
If posn is outside the specified range.
Throws: InvalidNameException
If n is not a valid name, or if the addition of the components violates the syntax of the name (e.g. exceeding number of components).
 o add
 public abstract Name add(String comp) throws InvalidNameException
Adds a single component to the end of this name.

Parameters:
comp - The non-null component to add.
Returns:
The updated Name, not a new one. Cannot be null.
Throws: InvalidNameException
If adding comp at end of the name would violate the name's syntax.
 o add
 public abstract Name add(int posn,
                          String comp) throws InvalidNameException
Adds a single component at a specified position within this name. Components of this name at or after the index of the new component are shifted up by one (away from index 0) to accommodate the new component.

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 Name, not a new one. Cannot be null.
Throws: ArrayIndexOutOfBoundsException
If posn is outside the specified range.
Throws: InvalidNameException
If adding comp at the specified position would violate the name's syntax.
 o remove
 public abstract Object remove(int posn) throws InvalidNameException
Removes a component from this name. The component of this name at position 'posn' is removed, and components at indices greater than 'posn' are shifted down (towards index 0) by one.

Parameters:
posn - The index of the component to delete. Must be in the range [0,size()).
Returns:
The object removed; null if not there.
Throws: ArrayIndexOutOfBoundsException
If posn is outside the specified range (includes case where name is empty).
Throws: InvalidNameException
If deleting the component would violate the name's syntax.

All Packages  Class Hierarchy  This Package  Previous  Next  Index