Class CompositeName
java.lang.Object
javax.naming.CompositeName
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Object>
,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:- escape (backward slash \),
- quote characters (single (') and double quotes (")), and
- component separator (forward slash character (/)).
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 correspondingCompositeName
s. 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
ACompositeName
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:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs a new empty composite name.Constructs a new composite name instance by parsing the string n using the composite name syntax (left-to-right, slash separated).protected
CompositeName
(Enumeration<String> comps) Constructs a new composite name instance using the components specified by 'comps'. -
Method Summary
Modifier and TypeMethodDescriptionAdds a single component at a specified position within this composite name.Adds a single component to the end of this composite name.Adds the components of a composite name -- in order -- at a specified position within this composite name.Adds the components of a composite name -- in order -- to the end of this composite name.clone()
Generates a copy of this composite name.int
Compares this CompositeName with the specified Object for order.boolean
Determines whether a composite name is a suffix of this composite name.boolean
Determines whether two composite names are equal.get
(int posn) Retrieves a component of this composite name.getAll()
Retrieves the components of this composite name as an enumeration of strings.getPrefix
(int posn) Creates a composite name whose components consist of a prefix of the components in this composite name.getSuffix
(int posn) Creates a composite name whose components consist of a suffix of the components in this composite name.int
hashCode()
Computes the hash code of this composite name.boolean
isEmpty()
Determines whether this composite name is empty.remove
(int posn) Deletes a component from this composite name.int
size()
Retrieves the number of components in this composite name.boolean
startsWith
(Name n) Determines whether a composite name is a prefix of this composite name.toString()
Generates the string representation of this composite name.
-
Constructor Details
-
CompositeName
Constructs a new composite name instance using the components specified by 'comps'. This protected method is intended 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
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:
-