Package org.opengis.example.util
Class SimpleName
- Object
-
- SimpleName
-
- All Implemented Interfaces:
Serializable
,Comparable<GenericName>
,GenericName
- Direct Known Subclasses:
SimpleName.Local
,SimpleName.Scoped
public class SimpleName extends Object implements GenericName, Serializable
AGenericName
backed by a JNDIName
instance. This name can be the basis ofLocalName
orScopedName
implementations, depending on whether the size of the wrapped JNDI name is 1 or more, respectively.This implementation is a view: any change applied on the wrapped JNDI object will be immediately reflected in the
SimpleName
wrapper. Note however thatGenericName
are usually expected to be immutable, so users are advised to not modify the wrapped JNDI name.- See Also:
jndiName()
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleName.Local
ALocalName
specialization ofSimpleName
.static class
SimpleName.Member
AMemberName
specialization ofSimpleName.Local
.static class
SimpleName.Scoped
AScopedName
specialization ofSimpleName
.static class
SimpleName.Type
ATypeName
specialization ofSimpleName.Local
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleName(SimpleNameSpace scope, Name name)
Creates a new instance backed by the given JNDI name.
-
Method Summary
Modifier and Type Method Description int
compareTo(GenericName other)
Compares this name with the given object for lexicographical order.int
depth()
Returns the number of levels specified by this name.boolean
equals(Object other)
Compares the given object to this name for equality.List<LocalName>
getParsedNames()
Returns the sequence of local names making this generic name.int
hashCode()
Returns a hash code value for this name.LocalName
head()
Returns the first element in the sequence of parsed names.Name
jndiName()
Returns a clone of the JNDI name wrapped by this object.ScopedName
push(GenericName scope)
Returns this name expanded with the specified scope.NameSpace
scope()
Returns the scope (name space) in which this name is local.LocalName
tip()
Returns the last element in the sequence of parsed names.GenericName
toFullyQualifiedName()
Returns a view of this name as a fully-qualified name.InternationalString
toInternationalString()
Returns a local-dependent string representation of this generic name.String
toString()
Returns a string representation of this generic name.
-
-
-
Field Detail
-
name
protected final Name name
The JNDI name wrapped by thisSimpleName
. While JNDI names are mutable,GenericName
are expected to be immutable. Consequently users are advised to not modify this object.- See Also:
jndiName()
-
-
Constructor Detail
-
SimpleName
protected SimpleName(SimpleNameSpace scope, Name name)
Creates a new instance backed by the given JNDI name. This constructor does not clone the given JNDI name. While this implementation is robust to change in the wrapped object, it is a better practice to keep the JNDI name unmodified afterSimpleName
construction.- Parameters:
scope
- the scope (name space) in which the given name is local, ornull
.name
- the JNDI name wrapped by thisSimpleName
(not cloned).
-
-
Method Detail
-
jndiName
public Name jndiName()
Returns a clone of the JNDI name wrapped by this object.- Returns:
- a clone of
name
.
-
scope
public NameSpace scope()
Returns the scope (name space) in which this name is local. The scope of a name determines where a name starts. The scope is set on creation and is not modifiable.- Specified by:
scope
in interfaceGenericName
-
depth
public int depth()
Returns the number of levels specified by this name. The default implementation returns the size of the wrapped JNDI name.- Specified by:
depth
in interfaceGenericName
- See Also:
Name.size()
-
getParsedNames
public List<LocalName> getParsedNames()
Returns the sequence of local names making this generic name. The length of this sequence is the depth. It does not include the scope.- Specified by:
getParsedNames
in interfaceGenericName
- See Also:
Name.getAll()
-
head
public LocalName head()
Returns the first element in the sequence of parsed names.- Specified by:
head
in interfaceGenericName
- See Also:
Name.get(int)
-
tip
public LocalName tip()
Returns the last element in the sequence of parsed names.- Specified by:
tip
in interfaceGenericName
- See Also:
Name.get(int)
-
toFullyQualifiedName
public GenericName toFullyQualifiedName()
Returns a view of this name as a fully-qualified name. The scope of a fully qualified name will be global. If the scope of this name is already global, then this method returnsthis
.- Specified by:
toFullyQualifiedName
in interfaceGenericName
- Returns:
- the fully-qualified name (never
null
).
-
push
public ScopedName push(GenericName scope)
Returns this name expanded with the specified scope. One may represent this operation as a concatenation of the specifiedscope
withthis
.- Specified by:
push
in interfaceGenericName
- Parameters:
scope
- The name to use as prefix.- Returns:
- a concatenation of the given name with this name.
- See Also:
Name.addAll(Name)
-
toString
public String toString()
Returns a string representation of this generic name. Note that the scope is not part of this string representation.- Specified by:
toString
in interfaceGenericName
- Overrides:
toString
in classObject
- Returns:
- a string representation of this name.
-
toInternationalString
public InternationalString toInternationalString()
Returns a local-dependent string representation of this generic name. The default implementation wraps thetoString()
value.- Specified by:
toInternationalString
in interfaceGenericName
- Returns:
- a localizable string representation of this name.
-
compareTo
public int compareTo(GenericName other)
Compares this name with the given object for lexicographical order. Note that the scope is not part of this comparison.- Specified by:
compareTo
in interfaceComparable<GenericName>
- Specified by:
compareTo
in interfaceGenericName
- Parameters:
other
- the other object to compare to this name.
-
equals
public boolean equals(Object other)
-
-