CompoundName (Java SE 11 & JDK 11 ) (original) (raw)
Field Detail
* #### mySyntax
protected transient [Properties](../../../java.base/java/util/Properties.html "class in java.util") 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.
Constructor Detail
* #### CompoundName
protected CompoundName([Enumeration](../../../java.base/java/util/Enumeration.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang")> comps,
[Properties](../../../java.base/java/util/Properties.html "class in java.util") 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` \- 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` \- A non-null properties that specify the syntax of this compound name. See class description for contents of properties.
* #### CompoundName
public CompoundName([String](../../../java.base/java/lang/String.html "class in java.lang") n,
[Properties](../../../java.base/java/util/Properties.html "class in java.util") syntax)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
Constructs a new compound name instance by parsing the string n using the syntax specified by the syntax properties supplied.
Parameters:
`n` \- The non-null string to parse.
`syntax` \- A non-null list of properties that specify the syntax of this compound name. See class description for contents of properties.
Throws:
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- If 'n' violates the syntax specified by `syntax`.
Method Detail
* #### toString
public [String](../../../java.base/java/lang/String.html "class in java.lang") 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.
Overrides:
`[toString](../../../java.base/java/lang/Object.html#toString%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")`
Returns:
A non-null string representation of this compound name.
* #### equals
public boolean equals([Object](../../../java.base/java/lang/Object.html "class in java.lang") obj)
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.
Overrides:
`[equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")`
Parameters:
`obj` \- The possibly null object to compare against.
Returns:
true if obj is equal to this compound name, false otherwise.
See Also:
[compareTo(java.lang.Object obj)](#compareTo%28java.lang.Object%29)
* #### hashCode
public int 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.
Overrides:
`[hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")`
Returns:
An int representing the hash code of this name.
See Also:
[Object.equals(java.lang.Object)](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [System.identityHashCode(java.lang.Object)](../../../java.base/java/lang/System.html#identityHashCode%28java.lang.Object%29)
* #### clone
public [Object](../../../java.base/java/lang/Object.html "class in java.lang") 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.
Specified by:
`[clone](Name.html#clone%28%29)` in interface `[Name](Name.html "interface in javax.naming")`
Overrides:
`[clone](../../../java.base/java/lang/Object.html#clone%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")`
Returns:
A non-null copy of this compound name.
See Also:
[Cloneable](../../../java.base/java/lang/Cloneable.html "interface in java.lang")
* #### compareTo
public int compareTo([Object](../../../java.base/java/lang/Object.html "class in java.lang") obj)
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.
Specified by:
`[compareTo](../../../java.base/java/lang/Comparable.html#compareTo%28T%29)` in interface `[Comparable](../../../java.base/java/lang/Comparable.html "interface in java.lang")<[Object](../../../java.base/java/lang/Object.html "class in java.lang")>`
Specified by:
`[compareTo](Name.html#compareTo%28java.lang.Object%29)` in interface `[Name](Name.html "interface in javax.naming")`
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 Object.
Throws:
`[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")` \- if obj is not a CompoundName.
See Also:
[equals(java.lang.Object)](#equals%28java.lang.Object%29)
* #### size
public int size()
Retrieves the number of components in this compound name.
Specified by:
`[size](Name.html#size%28%29)` in interface `[Name](Name.html "interface in javax.naming")`
Returns:
The nonnegative number of components in this compound name.
* #### isEmpty
public boolean isEmpty()
Determines whether this compound name is empty. A compound name is empty if it has zero components.
Specified by:
`[isEmpty](Name.html#isEmpty%28%29)` in interface `[Name](Name.html "interface in javax.naming")`
Returns:
true if this compound name is empty, false otherwise.
* #### getAll
public [Enumeration](../../../java.base/java/util/Enumeration.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang")> 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.
Specified by:
`[getAll](Name.html#getAll%28%29)` in interface `[Name](Name.html "interface in javax.naming")`
Returns:
A non-null enumeration of the components of this compound name. Each element of the enumeration is of class String.
* #### get
public [String](../../../java.base/java/lang/String.html "class in java.lang") get(int posn)
Retrieves a component of this compound name.
Specified by:
`[get](Name.html#get%28int%29)` in interface `[Name](Name.html "interface in javax.naming")`
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](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- if posn is outside the specified range.
* #### getPrefix
public [Name](Name.html "interface in javax.naming") getPrefix(int posn)
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.
Specified by:
`[getPrefix](Name.html#getPrefix%28int%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`posn` \- The 0-based index of the component at which to stop. Must be in the range \[0,size()\].
Returns:
A compound name consisting of the components at indexes in the range \[0,posn).
Throws:
`[ArrayIndexOutOfBoundsException](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- If posn is outside the specified range.
* #### getSuffix
public [Name](Name.html "interface in javax.naming") getSuffix(int posn)
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.
Specified by:
`[getSuffix](Name.html#getSuffix%28int%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`posn` \- The 0-based index of the component at which to start. Must be in the range \[0,size()\].
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.
Throws:
`[ArrayIndexOutOfBoundsException](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- If posn is outside the specified range.
* #### startsWith
public boolean startsWith([Name](Name.html "interface in javax.naming") n)
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.
Specified by:
`[startsWith](Name.html#startsWith%28javax.naming.Name%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`n` \- The possibly null compound name to check.
Returns:
true if n is a CompoundName and is a prefix of this compound name, false otherwise.
* #### endsWith
public boolean endsWith([Name](Name.html "interface in javax.naming") n)
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.
Specified by:
`[endsWith](Name.html#endsWith%28javax.naming.Name%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`n` \- The possibly null compound name to check.
Returns:
true if n is a CompoundName and is a suffix of this compound name, false otherwise.
* #### addAll
public [Name](Name.html "interface in javax.naming") addAll([Name](Name.html "interface in javax.naming") suffix)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
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.
Specified by:
`[addAll](Name.html#addAll%28javax.naming.Name%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`suffix` \- The non-null components to add.
Returns:
The updated CompoundName, not a new one. Cannot be null.
Throws:
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- 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).
* #### addAll
public [Name](Name.html "interface in javax.naming") addAll(int posn,
[Name](Name.html "interface in javax.naming") n)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
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.
Specified by:
`[addAll](Name.html#addAll%28int,javax.naming.Name%29)` in interface `[Name](Name.html "interface in javax.naming")`
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 CompoundName, not a new one. Cannot be null.
Throws:
`[ArrayIndexOutOfBoundsException](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- If posn is outside the specified range.
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- 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).
* #### add
public [Name](Name.html "interface in javax.naming") add([String](../../../java.base/java/lang/String.html "class in java.lang") comp)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
Adds a single component to the end of this compound name.
Specified by:
`[add](Name.html#add%28java.lang.String%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`comp` \- The non-null component to add.
Returns:
The updated CompoundName, not a new one. Cannot be null.
Throws:
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- If adding comp at end of the name would violate the compound name's syntax.
* #### add
public [Name](Name.html "interface in javax.naming") add(int posn,
[String](../../../java.base/java/lang/String.html "class in java.lang") comp)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
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.
Specified by:
`[add](Name.html#add%28int,java.lang.String%29)` in interface `[Name](Name.html "interface in javax.naming")`
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 CompoundName, not a new one. Cannot be null.
Throws:
`[ArrayIndexOutOfBoundsException](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- If posn is outside the specified range.
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- If adding comp at the specified position would violate the compound name's syntax.
* #### remove
public [Object](../../../java.base/java/lang/Object.html "class in java.lang") remove(int posn)
throws [InvalidNameException](InvalidNameException.html "class in javax.naming")
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.
Specified by:
`[remove](Name.html#remove%28int%29)` in interface `[Name](Name.html "interface in javax.naming")`
Parameters:
`posn` \- The index of the component to delete. Must be in the range \[0,size()).
Returns:
The component removed (a String).
Throws:
`[ArrayIndexOutOfBoundsException](../../../java.base/java/lang/ArrayIndexOutOfBoundsException.html "class in java.lang")` \- If posn is outside the specified range (includes case where compound name is empty).
`[InvalidNameException](InvalidNameException.html "class in javax.naming")` \- If deleting the component would violate the compound name's syntax.