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
AGenericNamebacked by a JNDINameinstance. This name can be the basis ofLocalNameorScopedNameimplementations, 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
SimpleNamewrapper. Note however thatGenericNameare 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 classSimpleName.LocalALocalNamespecialization ofSimpleName.static classSimpleName.MemberAMemberNamespecialization ofSimpleName.Local.static classSimpleName.ScopedAScopedNamespecialization ofSimpleName.static classSimpleName.TypeATypeNamespecialization ofSimpleName.Local.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleName(SimpleNameSpace scope, Name name)Creates a new instance backed by the given JNDI name.
-
Method Summary
Modifier and Type Method Description intcompareTo(GenericName other)Compares this name with the given object for lexicographical order.intdepth()Returns the number of levels specified by this name.booleanequals(Object other)Compares the given object to this name for equality.List<LocalName>getParsedNames()Returns the sequence of local names making this generic name.inthashCode()Returns a hash code value for this name.LocalNamehead()Returns the first element in the sequence of parsed names.NamejndiName()Returns a clone of the JNDI name wrapped by this object.ScopedNamepush(GenericName scope)Returns this name expanded with the specified scope.NameSpacescope()Returns the scope (name space) in which this name is local.LocalNametip()Returns the last element in the sequence of parsed names.GenericNametoFullyQualifiedName()Returns a view of this name as a fully-qualified name.InternationalStringtoInternationalString()Returns a local-dependent string representation of this generic name.StringtoString()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,GenericNameare 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 afterSimpleNameconstruction.- 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:
scopein 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:
depthin 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:
getParsedNamesin interfaceGenericName- See Also:
Name.getAll()
-
head
public LocalName head()
Returns the first element in the sequence of parsed names.- Specified by:
headin interfaceGenericName- See Also:
Name.get(int)
-
tip
public LocalName tip()
Returns the last element in the sequence of parsed names.- Specified by:
tipin 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:
toFullyQualifiedNamein 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 specifiedscopewiththis.- Specified by:
pushin 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:
toStringin interfaceGenericName- Overrides:
toStringin 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:
toInternationalStringin 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:
compareToin interfaceComparable<GenericName>- Specified by:
compareToin interfaceGenericName- Parameters:
other- the other object to compare to this name.
-
equals
public boolean equals(Object other)
-
-