Top Description Fields Constructors Methods
javax.naming

public Class CompoundName

extends Object
implements Name
Class Inheritance
All Implemented Interfaces
javax.naming.Name, java.lang.Comparable, java.io.Serializable, java.lang.Cloneable
Known Direct Subclasses
com.sun.jndi.toolkit.dir.HierarchicalName
Imports
java.util.Enumeration, .Properties

This class represents a compound name -- a name from a hierarchical name space. Each component in a compound name is an atomic name.

The components of a compound name are numbered. The indexes of a compound 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 compound name has no components.

Compound Name Syntax

The syntax of a compound name is specified using a set of properties:
jndi.syntax.direction
Direction for parsing ("right_to_left", "left_to_right", "flat"). If unspecified, defaults to "flat", which means the namespace is flat with no hierarchical structure.
jndi.syntax.separator
Separator between atomic name components. Required unless direction is "flat".
jndi.syntax.ignorecase
If present, "true" means ignore the case when comparing name components. If its value is not "true", or if the property is not present, case is considered when comparing name components.
jndi.syntax.escape
If present, specifies the escape string for overriding separator, escapes and quotes.
jndi.syntax.beginquote
If present, specifies the string delimiting start of a quoted string.
jndi.syntax.endquote
String delimiting end of quoted string. If present, specifies the string delimiting the end of a quoted string. If not present, use syntax.beginquote as end quote.
jndi.syntax.beginquote2
Alternative set of begin/end quotes.
jndi.syntax.endquote2
Alternative set of begin/end quotes.
jndi.syntax.trimblanks
If present, "true" means trim any leading and trailing whitespaces in a name component for comparison purposes. If its value is not "true", or if the property is not present, blanks are significant.
jndi.syntax.separator.ava
If present, specifies the string that separates attribute-value-assertions when specifying multiple attribute/value pairs. (e.g. "," in age=65,gender=male).
jndi.syntax.separator.typeval
If present, specifies the string that separates attribute from value (e.g. "=" in "age=65")
These properties are interpreted according to the following rules:
  1. In a string without quotes or escapes, any instance of the separator delimits two atomic names. Each atomic name is referred to as a component.
  2. A separator, quote or escape is escaped if preceded immediately (on the left) by the escape.
  3. If there are two sets of quotes, a specific begin-quote must be matched by its corresponding end-quote.
  4. A non-escaped begin-quote which precedes a component must be matched by a non-escaped end-quote at the end of the component. A component thus quoted is referred to as a quoted component. It is parsed by removing the being- and end- quotes, and by treating the intervening characters as ordinary characters unless one of the rules involving quoted components listed below applies.
  5. Quotes embedded in non-quoted components are treated as ordinary strings and need not be matched.
  6. A separator that is escaped or appears between non-escaped quotes is treated as an ordinary string and not a separator.
  7. An escape string within a quoted component acts as an escape only when followed by the corresponding end-quote string. This can be used to embed an escaped quote within a quoted component.
  8. An escaped escape string is not treated as an escape string.
  9. An escape string that does not precede a meta string (quotes or separator) and is not at the end of a component is treated as an ordinary string.
  10. A leading separator (the compound name string begins with a separator) denotes a leading empty atomic component (consisting of an empty string). A trailing separator (the compound name string ends with a separator) denotes a trailing empty atomic component. Adjacent separators denote an empty atomic component.

The string form of the compound name follows the syntax described above. When the components of the compound name are turned into their string representation, the reserved syntax rules described above are applied (e.g. embedded separators are escaped or quoted) so that when the same string is parsed, it will yield the same components of the original compound name.

Multithreaded Access

A CompoundName instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a CompoundName should lock the object.
Authors
Rosanna Lee, Scott Seligman
Since
1.3

Field Summary

Modifier and TypeField and Description
private transient NameImpl
impl

Implementation of this compound name.

protected transient Properties
mySyntax

Syntax properties for this compound name.

private static final long
serialVersionUID

Hides javax.naming.Name.serialVersionUID.

Use serialVersionUID from JNDI 1.1.1 for interoperability

Constructor Summary

AccessConstructor and Description
protected
CompoundName(Enumeration<String>
A non-null enumeration of the components to add. Each element of the enumeration is of class String. The enumeration will be consumed to extract its elements.
comps
,
Properties
A non-null properties that specify the syntax of this compound name. See class description for contents of properties.
syntax
)

Constructs a new compound name instance using the components specified in comps and syntax.

public
CompoundName(String
The non-null string to parse.
n
,
Properties
A non-null list of properties that specify the syntax of this compound name. See class description for contents of properties.
syntax
)

Constructs a new compound name instance by parsing the string n using the syntax specified by the syntax properties supplied.

Method Summary

Modifier and TypeMethod and Description
public Name

Returns:

The updated CompoundName, not a new one. Cannot be null.
add
(String
The non-null component to add.
comp
)

Implements javax.naming.Name.add.

Adds a single component to the end of this compound name.
public Name

Returns:

The updated CompoundName, not a new one. Cannot be null.
add
(int
The index at which to add the new component. Must be in the range [0,size()].
posn
,
String
The non-null component to add.
comp
)

Implements javax.naming.Name.add.

Adds a single component at a specified position within this compound name.
public Name

Returns:

The updated CompoundName, not a new one. Cannot be null.
addAll
(Name
The non-null components to add.
suffix
)

Implements javax.naming.Name.addAll.

Adds the components of a compound name -- in order -- to the end of this compound name.
public Name

Returns:

The updated CompoundName, not a new one. Cannot be null.
addAll
(int
The index in this name at which to add the new components. Must be in the range [0,size()].
posn
,
Name
The non-null components to add.
n
)

Implements javax.naming.Name.addAll.

Adds the components of a compound name -- in order -- at a specified position within this compound name.
public Object

Returns:

A non-null copy of this compound name.
clone
()

Overrides java.lang.Object.clone.

Implements javax.naming.Name.clone.

Creates a copy of this compound name.
public int

Returns:

a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object.
compareTo
(Object
The non-null object to compare against.
obj
)

Implements javax.naming.Name.compareTo.

Compares this CompoundName with the specified Object for order.
public boolean

Returns:

true if n is a CompoundName and is a suffix of this compound name, false otherwise.
endsWith
(Name
The possibly null compound name to check.
n
)

Implements javax.naming.Name.endsWith.

Determines whether a compound name is a suffix of this compound name.
public boolean

Returns:

true if obj is equal to this compound name, false otherwise.
equals
(Object
The possibly null object to compare against.
obj
)

Overrides java.lang.Object.equals.

Determines whether obj is syntactically equal to this compound name.
public String

Returns:

The component at index posn.
get
(int
The 0-based index of the component to retrieve. Must be in the range [0,size()).
posn
)

Implements javax.naming.Name.get.

Retrieves a component of this compound name.
public Enumeration<String>

Returns:

A non-null enumeration of the components of this compound name. Each element of the enumeration is of class String.
getAll
()

Implements javax.naming.Name.getAll.

Retrieves the components of this compound name as an enumeration of strings.
public Name

Returns:

A compound name consisting of the components at indexes in the range [0,posn).
getPrefix
(int
The 0-based index of the component at which to stop. Must be in the range [0,size()].
posn
)

Implements javax.naming.Name.getPrefix.

Creates a compound name whose components consist of a prefix of the components in this compound name.
public Name

Returns:

A compound name consisting of the components at indexes in the range [posn,size()). If posn is equal to size(), an empty compound name is returned.
getSuffix
(int
The 0-based index of the component at which to start. Must be in the range [0,size()].
posn
)

Implements javax.naming.Name.getSuffix.

Creates a compound name whose components consist of a suffix of the components in this compound name.
public int

Returns:

An int representing the hash code of this name.
hashCode
()

Overrides java.lang.Object.hashCode.

Computes the hash code of this compound name.
public boolean

Returns:

true if this compound name is empty, false otherwise.
isEmpty
()

Implements javax.naming.Name.isEmpty.

Determines whether this compound name is empty.
private void
readObject(ObjectInputStream
the ObjectInputStream to read from
s
)

The readObject method is called to restore the state of the CompoundName from a stream.

public Object

Returns:

The component removed (a String).
remove
(int
The index of the component to delete. Must be in the range [0,size()).
posn
)

Implements javax.naming.Name.remove.

Deletes a component from this compound name.
public int

Returns:

The nonnegative number of components in this compound name.
size
()

Implements javax.naming.Name.size.

Retrieves the number of components in this compound name.
public boolean

Returns:

true if n is a CompoundName and is a prefix of this compound name, false otherwise.
startsWith
(Name
The possibly null compound name to check.
n
)

Implements javax.naming.Name.startsWith.

Determines whether a compound name is a prefix of this compound name.
public String

Returns:

A non-null string representation of this compound name.
toString
()

Overrides java.lang.Object.toString.

Generates the string representation of this compound name, using the syntax rules of the compound name.
private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write to
s
)

The writeObject method is called to save the state of the CompoundName to a stream.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

implback to summary
private transient NameImpl impl

Implementation of this compound name. This field is initialized by the constructors and cannot be null.

mySyntaxback to summary
protected transient Properties mySyntax

Syntax properties for this compound name. This field is initialized by the constructors and cannot be null. It should be treated as a read-only variable by subclasses. Any necessary changes to mySyntax should be made within constructors and not after the compound name has been instantiated.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.naming.Name.serialVersionUID.

Use serialVersionUID from JNDI 1.1.1 for interoperability

Annotations
@Serial

Constructor Detail

CompoundNameback to summary
protected CompoundName(Enumeration<String> comps, Properties syntax)

Constructs a new compound name instance using the components specified in comps and syntax. This protected method is intended to be used by subclasses of CompoundName when they override methods such as clone(), getPrefix(), getSuffix().

Parameters
comps:Enumeration<String>

A non-null enumeration of the components to add. Each element of the enumeration is of class String. The enumeration will be consumed to extract its elements.

syntax:Properties

A non-null properties that specify the syntax of this compound name. See class description for contents of properties.

CompoundNameback to summary
public CompoundName(String n, Properties syntax) throws InvalidNameException

Constructs a new compound name instance by parsing the string n using the syntax specified by the syntax properties supplied.

Parameters
n:String

The non-null string to parse.

syntax:Properties

A non-null list of properties that specify the syntax of this compound name. See class description for contents of properties.

Exceptions
InvalidNameException:
If 'n' violates the syntax specified by syntax.

Method Detail

addback to summary
public Name add(String comp) throws InvalidNameException

Implements javax.naming.Name.add.

Adds a single component to the end of this compound name.

Parameters
comp:String

The non-null component to add.

Returns:Name

The updated CompoundName, not a new one. Cannot be null.

Exceptions
InvalidNameException:
If adding comp at end of the name would violate the compound name's syntax.
addback to summary
public Name add(int posn, String comp) throws InvalidNameException

Implements javax.naming.Name.add.

Adds a single component at a specified position within this compound name. Components of this compound 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
posn:int

The index at which to add the new component. Must be in the range [0,size()].

comp:String

The non-null component to add.

Returns:Name

The updated CompoundName, not a new one. Cannot be null.

Exceptions
InvalidNameException:
If adding comp at the specified position would violate the compound name's syntax.
ArrayIndexOutOfBoundsException:
If posn is outside the specified range.
addAllback to summary
public Name addAll(Name suffix) throws InvalidNameException

Implements javax.naming.Name.addAll.

Adds the components of a compound name -- in order -- to the end of this compound name.

Implementation Note

Currently the syntax properties of suffix is not used or checked. They might be in the future.

Parameters
suffix:Name

The non-null components to add.

Returns:Name

The updated CompoundName, not a new one. Cannot be null.

Exceptions
InvalidNameException:
If suffix is not a compound name, or if the addition of the components violates the syntax of this compound name (e.g. exceeding number of components).
addAllback to summary
public Name addAll(int posn, Name n) throws InvalidNameException

Implements javax.naming.Name.addAll.

Adds the components of a compound name -- in order -- at a specified position within this compound name. Components of this compound name at or after the index of the first new component are shifted up (away from index 0) to accommodate the new components.

Implementation Note

Currently the syntax properties of suffix is not used or checked. They might be in the future.

Parameters
posn:int

The index in this name at which to add the new components. Must be in the range [0,size()].

n:Name

The non-null components to add.

Returns:Name

The updated CompoundName, not a new one. Cannot be null.

Exceptions
InvalidNameException:
If n is not a compound name, or if the addition of the components violates the syntax of this compound name (e.g. exceeding number of components).
ArrayIndexOutOfBoundsException:
If posn is outside the specified range.
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements javax.naming.Name.clone.

Creates a copy of this compound name. Changes to the components of this compound name won't affect the new copy and vice versa. The clone and this compound name share the same syntax.

Returns:Object

A non-null copy of this compound name.

compareToback to summary
public int compareTo(Object obj)

Implements javax.naming.Name.compareTo.

Compares this CompoundName 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 CompoundName, ClassCastException is thrown.

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

Ordering of compound names depend on the syntax of the compound name. By default, they follow lexicographical rules for string comparison with the extension that this applies to all the components in the compound name and that comparison of individual components is affected by the jndi.syntax.ignorecase and jndi.syntax.trimblanks properties, identical to how they affect equals(). If this compound name is "lexicographically" lesser than obj, a negative number is returned. If this compound name is "lexicographically" greater than obj, a positive number is returned.

Implementation Note

Currently the syntax properties of the two compound names are not compared when checking order. They might be in the future.

Parameters
obj:Object

The non-null object to compare against.

Returns:int

a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object.

Exceptions
ClassCastException:
if obj is not a CompoundName.
See Also
equals(java.lang.Object)
endsWithback to summary
public boolean endsWith(Name n)

Implements javax.naming.Name.endsWith.

Determines whether a compound name is a suffix of this compound name. A compound name 'n' is a suffix if it is equal to getSuffix(size()-n.size())--in other words, this compound name ends with 'n'. If n is null or not a compound name, false is returned.

Implementation Note

Currently the syntax properties of n are not used when doing the comparison. They might be in the future.

Parameters
n:Name

The possibly null compound name to check.

Returns:boolean

true if n is a CompoundName and is a suffix of this compound name, false otherwise.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Determines whether obj is syntactically equal to this compound name. If obj is null or not a CompoundName, false is returned. Two compound names are equal if each component in one is "equal" to the corresponding component in the other.

Equality is also defined in terms of the syntax of this compound name. The default implementation of CompoundName uses the syntax properties jndi.syntax.ignorecase and jndi.syntax.trimblanks when comparing two components for equality. If case is ignored, two strings with the same sequence of characters but with different cases are considered equal. If blanks are being trimmed, leading and trailing blanks are ignored for the purpose of the comparison.

Both compound names must have the same number of components.

Implementation Note

Currently the syntax properties of the two compound names are not compared for equality. They might be in the future.

Parameters
obj:Object

The possibly null object to compare against.

Returns:boolean

true if obj is equal to this compound name, false otherwise.

See Also
compareTo(java.lang.Object obj)
getback to summary
public String get(int posn)

Implements javax.naming.Name.get.

Retrieves a component of this compound name.

Parameters
posn:int

The 0-based index of the component to retrieve. Must be in the range [0,size()).

Returns:String

The component at index posn.

Exceptions
ArrayIndexOutOfBoundsException:
if posn is outside the specified range.
getAllback to summary
public Enumeration<String> getAll()

Implements javax.naming.Name.getAll.

Retrieves the components of this compound name as an enumeration of strings. The effects of updates to this compound name on this enumeration is undefined.

Returns:Enumeration<String>

A non-null enumeration of the components of this compound name. Each element of the enumeration is of class String.

getPrefixback to summary
public Name getPrefix(int posn)

Implements javax.naming.Name.getPrefix.

Creates a compound name whose components consist of a prefix of the components in this compound name. The result and this compound name share the same syntax. Subsequent changes to this compound name do not affect the name that is returned and vice versa.

Parameters
posn:int

The 0-based index of the component at which to stop. Must be in the range [0,size()].

Returns:Name

A compound name consisting of the components at indexes in the range [0,posn).

Exceptions
ArrayIndexOutOfBoundsException:
If posn is outside the specified range.
getSuffixback to summary
public Name getSuffix(int posn)

Implements javax.naming.Name.getSuffix.

Creates a compound name whose components consist of a suffix of the components in this compound name. The result and this compound name share the same syntax. Subsequent changes to this compound name do not affect the name that is returned.

Parameters
posn:int

The 0-based index of the component at which to start. Must be in the range [0,size()].

Returns:Name

A compound name consisting of the components at indexes in the range [posn,size()). If posn is equal to size(), an empty compound name is returned.

Exceptions
ArrayIndexOutOfBoundsException:
If posn is outside the specified range.
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Computes the hash code of this compound name. The hash code is the sum of the hash codes of the "canonicalized" forms of individual components of this compound name. Each component is "canonicalized" according to the compound name's syntax before its hash code is computed. For a case-insensitive name, for example, the uppercased form of a name has the same hash code as its lowercased equivalent.

Returns:int

An int representing the hash code of this name.

isEmptyback to summary
public boolean isEmpty()

Implements javax.naming.Name.isEmpty.

Determines whether this compound name is empty. A compound name is empty if it has zero components.

Returns:boolean

true if this compound name is empty, false otherwise.

readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

The readObject method is called to restore the state of the CompoundName from a stream. See writeObject for a description of the serial form.

Parameters
s:ObjectInputStream

the ObjectInputStream to read from

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if the class of a serialized object could not be found
removeback to summary
public Object remove(int posn) throws InvalidNameException

Implements javax.naming.Name.remove.

Deletes a component from this compound name. The component of this compound name at position 'posn' is removed, and components at indices greater than 'posn' are shifted down (towards index 0) by one.

Parameters
posn:int

The index of the component to delete. Must be in the range [0,size()).

Returns:Object

The component removed (a String).

Exceptions
InvalidNameException:
If deleting the component would violate the compound name's syntax.
ArrayIndexOutOfBoundsException:
If posn is outside the specified range (includes case where compound name is empty).
sizeback to summary
public int size()

Implements javax.naming.Name.size.

Retrieves the number of components in this compound name.

Returns:int

The nonnegative number of components in this compound name.

startsWithback to summary
public boolean startsWith(Name n)

Implements javax.naming.Name.startsWith.

Determines whether a compound name is a prefix of this compound name. A compound name 'n' is a prefix if it is equal to getPrefix(n.size())--in other words, this compound name starts with 'n'. If n is null or not a compound name, false is returned.

Implementation Note

Currently the syntax properties of n are not used when doing the comparison. They might be in the future.

Parameters
n:Name

The possibly null compound name to check.

Returns:boolean

true if n is a CompoundName and is a prefix of this compound name, false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Generates the string representation of this compound name, using the syntax rules of the compound name. The syntax rules are described in the class description. An empty component is represented by an empty string. The string representation thus generated can be passed to the CompoundName constructor with the same syntax properties to create a new equivalent compound name.

Returns:String

A non-null string representation of this compound name.

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

The writeObject method is called to save the state of the CompoundName to a stream.

Parameters
s:ObjectOutputStream

the ObjectOutputStream to write to

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
Serial data
The syntax Properties, followed by the number of components (an int), and the individual components (each a String).