Interface Name
- All Superinterfaces:
-
Cloneable
,Comparable<Object>
,Serializable
- All Known Implementing Classes:
-
CompositeName
,CompoundName
,LdapName
public interface Name extends Cloneable, Serializable, Comparable<Object>
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 individual hierarchical naming systems). There can be different implementations of Name
; for example, composite names, URLs, or 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). The most significant component is at index 0. An empty name has no components.
None of the methods in this interface accept null as a valid value for a parameter that is a name or a name component. Likewise, methods that return a name or name component never return null.
An instance of a Name
may not be synchronized against concurrent multithreaded access if that access is not read-only.
- Since:
- 1.3
Field Summary
Modifier and Type | Field | Description |
---|---|---|
static final long |
serialVersionUID |
Deprecated. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Name |
add |
Adds a single component at a specified position within this name. |
Name |
add |
Adds a single component to the end of this name. |
Name |
addAll |
Adds the components of a name -- in order -- at a specified position within this name. |
Name |
addAll |
Adds the components of a name -- in order -- to the end of this name. |
Object |
clone() |
Generates a new copy of this name. |
int |
compareTo |
Compares this name with another name for order. |
boolean |
endsWith |
Determines whether this name ends with a specified suffix. |
String |
get |
Retrieves a component of this name. |
Enumeration<String> |
getAll() |
Retrieves the components of this name as an enumeration of strings. |
Name |
getPrefix |
Creates a name whose components consist of a prefix of the components of this name. |
Name |
getSuffix |
Creates a name whose components consist of a suffix of the components in this name. |
boolean |
isEmpty() |
Determines whether this name is empty. |
Object |
remove |
Removes a component from this name. |
int |
size() |
Returns the number of components in this name. |
boolean |
startsWith |
Determines whether this name starts with a specified prefix. |
Field Details
serialVersionUID
@Deprecated static final long serialVersionUID
serialVersionUID
field in an interface is ineffectual. Do not use; no replacement.- See Also:
Method Details
clone
Object clone()
- Returns:
- a copy of this name
- See Also:
compareTo
int compareTo(Object obj)
As with Object.equals()
, the notion of ordering for names depends on the class that implements this interface. For example, the ordering may be based on lexicographical ordering of the name components. Specific attributes of the name, such as how it treats case, may affect the ordering. In general, two names of different classes may not be compared.
- Specified by:
-
compareTo
in interfaceComparable<Object>
- 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 name
- Throws:
-
ClassCastException
- if obj is not aName
of a type that may be compared with this name - See Also:
size
int size()
- Returns:
- the number of components in this name
isEmpty
boolean isEmpty()
- Returns:
- true if this name is empty, false otherwise
getAll
Enumeration<String> getAll()
- Returns:
- an enumeration of the components of this name, each a string
get
String get(int posn)
- Parameters:
-
posn
- the 0-based index of the component to retrieve. Must be in the range [0,size()). - Returns:
- the component at index posn
- Throws:
-
ArrayIndexOutOfBoundsException
- if posn is outside the specified range
getPrefix
Name getPrefix(int posn)
- Parameters:
-
posn
- the 0-based index of the component at which to stop. Must be in the range [0,size()]. - Returns:
- a name consisting of the components at indexes in the range [0,posn).
- Throws:
-
ArrayIndexOutOfBoundsException
- if posn is outside the specified range
getSuffix
Name getSuffix(int posn)
- 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
startsWith
boolean startsWith(Name n)
n
is a prefix if it is equal to getPrefix(n.size())
.- Parameters:
-
n
- the name to check - Returns:
- true if
n
is a prefix of this name, false otherwise
endsWith
boolean endsWith(Name n)
n
is a suffix if it is equal to getSuffix(size()-n.size())
.- Parameters:
-
n
- the name to check - Returns:
- true if
n
is a suffix of this name, false otherwise
addAll
Name addAll(Name suffix) throws InvalidNameException
- Parameters:
-
suffix
- the components to add - Returns:
- the updated name (not a new one)
- Throws:
-
InvalidNameException
- ifsuffix
is not a valid name, or if the addition of the components would violate the syntax rules of this name
addAll
Name addAll(int posn, Name n) throws InvalidNameException
- Parameters:
-
n
- the 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)
- Throws:
-
ArrayIndexOutOfBoundsException
- if posn is outside the specified range -
InvalidNameException
- ifn
is not a valid name, or if the addition of the components would violate the syntax rules of this name
add
Name add(String comp) throws InvalidNameException
- Parameters:
-
comp
- the component to add - Returns:
- the updated name (not a new one)
- Throws:
-
InvalidNameException
- if addingcomp
would violate the syntax rules of this name
add
Name add(int posn, String comp) throws InvalidNameException
- Parameters:
-
comp
- the 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)
- Throws:
-
ArrayIndexOutOfBoundsException
- if posn is outside the specified range -
InvalidNameException
- if addingcomp
would violate the syntax rules of this name
remove
Object remove(int posn) throws InvalidNameException
- Parameters:
-
posn
- the index of the component to remove. Must be in the range [0,size()). - Returns:
- the component removed (a String)
- Throws:
-
ArrayIndexOutOfBoundsException
- if posn is outside the specified range -
InvalidNameException
- if deleting the component would violate the syntax rules of the name
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.naming/javax/naming/Name.html
serialVersionUID
field in an interface is ineffectual.