javax.naming
Interface Name
- All Known Implementing Classes:
- CompoundName, CompositeName
- public abstract interface Name
- extends java.lang.Cloneable, java.io.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.
Fields inherited from class java.io.Serializable |
serialVersionUID |
Method Summary |
Name |
add(int posn,
java.lang.String comp)
Adds a single component at a specified position within this name. |
Name |
add(java.lang.String comp)
Adds a single component to the end of this name. |
Name |
addAll(int posn,
Name n)
Adds the components of a name -- in order -- at a specified position
within this name. |
Name |
addAll(Name suffix)
Adds the components of a name -- in order -- to the end of this name. |
java.lang.Object |
clone()
Generates a copy of this name. |
int |
compareTo(java.lang.Object obj)
Compares this Name with the specified Object for order. |
boolean |
endsWith(Name n)
Determines whether this name ends with a specified suffix. |
java.lang.String |
get(int posn)
Retrieves a component of this name. |
java.util.Enumeration |
getAll()
Retrieves the components of this name as an enumeration
of strings. |
Name |
getPrefix(int posn)
Creates a name whose components consist of a prefix of the
components in this name. |
Name |
getSuffix(int posn)
Creates a name whose components consist of a suffix of the
components in this name. |
boolean |
isEmpty()
Determines whether this name is empty. |
java.lang.Object |
remove(int posn)
Removes a component from this name. |
int |
size()
Retrieves the number of components in this name. |
boolean |
startsWith(Name n)
Determines whether this name starts with a specified prefix. |
clone
public java.lang.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 java.lang.Object
- See Also:
Object.clone()
compareTo
public int compareTo(java.lang.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:
Object.equals(java.lang.Object)
size
public int size()
- Retrieves the number of components in this name.
- Returns:
- The nonnegative number of components in this name.
isEmpty
public boolean isEmpty()
- Determines whether this name is empty.
A name with zero components is empty.
- Returns:
- true if this name is empty, false otherwise.
getAll
public java.util.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.
get
public java.lang.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:
- java.lang.ArrayIndexOutOfBoundsException - if posn is outside the
specified range.
getPrefix
public 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:
- java.lang.ArrayIndexOutOfBoundsException - if posn is outside the
specified range.
getSuffix
public 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:
- java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.
startsWith
public 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.
endsWith
public 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.
addAll
public 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).
addAll
public 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:
- java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.
- 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).
add
public Name add(java.lang.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.
add
public Name add(int posn,
java.lang.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:
- java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range.
- InvalidNameException - If adding comp at the specified position
would violate the name's syntax.
remove
public java.lang.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:
- java.lang.ArrayIndexOutOfBoundsException - If posn is outside the specified range (includes case where
name is empty).
- InvalidNameException - If deleting the component
would violate the name's syntax.
For more information on JNDI, please see http://java.sun.com/products/jndi