Package org.geotools.util
Class GenericName
- Object
-
- GenericName
-
- All Implemented Interfaces:
Serializable
,Comparable<GenericName>
,GenericName
- Direct Known Subclasses:
LocalName
,ScopedName
public abstract class GenericName extends Object implements GenericName, Serializable
Base class for generic scoped and local name structure for type and attribute name in the context of name spaces.Note: this class has a natural ordering that is inconsistent with
equals
. The natural ordering may be case-insensitive and ignores the character separator between name elements.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
NameFactory
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static char
DEFAULT_SEPARATOR
The default separator character.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GenericName()
Creates a new instance of generic name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(GenericName that)
Compares this name with the specified object for order.int
depth()
Returns the depth of this name within the namespace hierarchy.boolean
equals(Object object)
Compares this generic name with the specified object for equality.protected abstract GenericName
getInternalScope()
Returns the scope (name space) of this generic name.abstract List<LocalName>
getParsedNames()
Returns the sequence of local names making this generic name.int
hashCode()
Returns a hash code value for this generic name.LocalName
head()
Returns the first element in the sequence of parsed names.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.InternationalString
toInternationalString()
Returns a local-dependent string representation of this generic name.String
toString()
Returns a string representation of this generic name.-
Methods inherited from interface GenericName
push, toFullyQualifiedName
-
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
The default separator character.- See Also:
- Constant Field Values
-
-
Method Detail
-
scope
public NameSpace scope()
Returns the scope (name space) in which this name is local. The scope is set on creation and is not modifiable. The scope of a name determines where a name "starts". For instance, if a name has a depth of two ("util.GenericName"
) and is associated with a name space having the name"org.opengis"
, then the fully qualified name would be"org.geotools.api.util.GenericName"
.- Specified by:
scope
in interfaceGenericName
- Returns:
- The name space.
- Since:
- 2.3
-
getInternalScope
protected abstract GenericName getInternalScope()
Returns the scope (name space) of this generic name. If this name has no scope (e.g. is the * root), then this method returnsnull
. Can be a no-op if the subclass overridesscope()
-
depth
public int depth()
Returns the depth of this name within the namespace hierarchy. This indicates the number of levels specified by this name. For anyLocalName
, it is always one. For aScopedName
it is some number greater than or equal to 2.The depth is the length of the list returned by the
getParsedNames()
method. As such it is a derived parameter.- Specified by:
depth
in interfaceGenericName
- Returns:
- The depth of this name.
- Since:
- 2.3
-
getParsedNames
public abstract List<LocalName> getParsedNames()
Returns the sequence of local names making this generic name. Each element in this list is like a directory name in a file path name. The length of this sequence is the generic name depth.- Specified by:
getParsedNames
in interfaceGenericName
- Returns:
- The sequence of local names.
-
head
public LocalName head()
- Specified by:
head
in interfaceGenericName
- Returns:
- The first element of this name.
- Since:
- 2.6
-
tip
public LocalName tip()
- Specified by:
tip
in interfaceGenericName
- Returns:
- The last element of this name.
- Since:
- 2.6
-
toString
public String toString()
Returns a string representation of this generic name. This string representation is local-independant. It contains all elements listed bygetParsedNames()
separated by an arbitrary character (usually:
or/
). This rule implies that thetoString()
method for a scoped name will contains the scope, while thetoString()
method for the local version of the same name will not contains the scope.- 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. This string is similar to the one returned bytoString()
except that each element has been localized in the specified locale. If no international string is available, then this method should returns an implementation mapping totoString()
for all locales.- Specified by:
toInternationalString
in interfaceGenericName
- Returns:
- A localizable string representation of this name.
-
compareTo
public int compareTo(GenericName that)
Compares this name with the specified object for order. Returns a negative integer, zero, or a positive integer as this name lexicographically precedes, is equals to, or follows the specified object. The comparaison is performed in the following order:- Compares each element in the list of parsed names. If an element of this name lexicographically precedes or follows the corresponding element of the specified name, returns a negative or a positive integer respectively.
- If all elements in both names are lexicographically equal, then if this name has less or more elements than the specified name, returns a negative or a positive integer respectively.
- Otherwise, returns 0.
- Specified by:
compareTo
in interfaceComparable<GenericName>
- Parameters:
that
- The name to compare with this name.- Returns:
- -1 if this name precedes the given one, +1 if it follows, 0 if equals.
-
equals
public boolean equals(Object object)
Compares this generic name with the specified object for equality.
-
-