Package org.geotools.util
Class ScopedName
- Object
-
- GenericName
-
- ScopedName
-
- All Implemented Interfaces:
Serializable
,Comparable<GenericName>
,GenericName
,ScopedName
public class ScopedName extends GenericName implements ScopedName
Fully qualified identifier for an object. AScopedName
contains aLocalName
as head and a GenericName, which may be aLocalName
or an otherScopedName
.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
NameFactory
, Serialized Form
-
-
Field Summary
-
Fields inherited from class GenericName
DEFAULT_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description ScopedName(GenericName scope, char separator, CharSequence name)
Constructs a scoped name from the specified international string.ScopedName(GenericName scope, CharSequence name)
Constructs a scoped name from the specified international string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
Compares this scoped name with the specified object for equality.protected GenericName
getInternalScope()
Returns the scope (name space) of this generic name.List<LocalName>
getParsedNames()
Returns the sequence of local name for this generic name.char
getSeparator()
Returns the separator character.int
hashCode()
Returns a hash code value for this generic name.LocalName
head()
Returns the head of this scoped name.GenericName
path()
Returns a name which contains every element of the parsed names list except for the last element.ScopedName
push(GenericName scope)
Returns this name expanded with the specified scope.GenericName
tail()
Returns the tail of this scoped name.LocalName
tip()
Returns a view of this object as a local name.GenericName
toFullyQualifiedName()
Returns a view of this name as a fully-qualified name.-
Methods inherited from class GenericName
compareTo, depth, scope, toInternationalString, toString
-
Methods inherited from interface Comparable
compareTo
-
Methods inherited from interface GenericName
depth, scope, toInternationalString
-
Methods inherited from interface ScopedName
toString
-
-
-
-
Constructor Detail
-
ScopedName
public ScopedName(GenericName scope, CharSequence name)
Constructs a scoped name from the specified international string. If the specified name is anInternationalString
, then thetoString(null)
method will be used in order to fetch an unlocalized name. Otherwise, thetoString()
method will be used.- Parameters:
scope
- The scope (or "tail") of the variable.name
- The head (nevernull
).
-
ScopedName
public ScopedName(GenericName scope, char separator, CharSequence name)
Constructs a scoped name from the specified international string. If the specified name is anInternationalString
, then thetoString(null)
method will be used in order to fetch an unlocalized name. Otherwise, thetoString()
method will be used.- Parameters:
scope
- The scope (or "tail") of the variable.separator
- The separator character (usually':'
or'/'
).name
- The head (nevernull
).
-
-
Method Detail
-
head
public LocalName head()
Returns the head of this scoped name. This is the first elements in the sequence of parsed names. The head element must exists in the same name space than this scoped name. In other words, the following relationship must holds:head().scope() == this.scope()
- Specified by:
head
in interfaceGenericName
- Specified by:
head
in interfaceScopedName
- Overrides:
head
in classGenericName
- Returns:
- The first element of this name.
- Since:
- 2.3
-
tail
public GenericName tail()
Returns the tail of this scoped name. The returned name contains every elements of the parsed names list except for the first one, which is the head. In other words, the following relationship must holds:tail().getParsedNames() == this.getParsedNames().sublist(1,end)
Note: This condition can be understood in terms of the Java
equals
method instead of the Java identity comparator==
.- Specified by:
tail
in interfaceScopedName
- Returns:
- All elements except the first one in the in the list of parsed names.
- Since:
- 2.3
-
path
public GenericName path()
Returns a name which contains every element of the parsed names list except for the last element.- Specified by:
path
in interfaceScopedName
- Returns:
- All elements except the last one in the in the list of parsed names.
- Since:
- 2.3
- See Also:
File.getPath()
-
getSeparator
public char getSeparator()
Returns the separator character.
-
tip
public LocalName tip()
Returns a view of this object as a local name. This is the last element in the sequence of parsed names. The local name returned by this method will still have the same scope than this scoped name. Note however that the string returned byLocalName.toString()
will differs.- Specified by:
tip
in interfaceGenericName
- Specified by:
tip
in interfaceScopedName
- Overrides:
tip
in classGenericName
- Returns:
- The last element of this name.
-
getInternalScope
protected GenericName getInternalScope()
Description copied from class:GenericName
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 overridesGenericName.scope()
- Specified by:
getInternalScope
in classGenericName
-
getParsedNames
public List<LocalName> getParsedNames()
Returns the sequence of local name for this generic name.- Specified by:
getParsedNames
in interfaceGenericName
- Specified by:
getParsedNames
in classGenericName
- Returns:
- The sequence of local names.
-
toFullyQualifiedName
public GenericName toFullyQualifiedName()
Returns a view of this name as a fully-qualified name. The scope of a fully qualified name must be global. This method never returnsnull
.- Specified by:
toFullyQualifiedName
in interfaceGenericName
- Returns:
- The fully-qualified name (never
null
). - Since:
- 2.3
-
push
public ScopedName push(GenericName scope)
Returns this name expanded with the specified scope. One may represent this operation as a concatenation of the specifiedname
withthis
. In pseudo-code, the following relationships must hold:push(name).getParsedList() == name.getParsedList().addAll(getParsedNames())
push(name).scope() == name.GenericName.scope()
push(head()).tail() == this
Note: Those conditions can be understood in terms of the Java
equals
method instead of the Java identity comparator==
.- Specified by:
push
in interfaceGenericName
- Parameters:
scope
- The name to use as prefix.- Returns:
- A concatenation of the given name with this name.
- Since:
- 2.3
-
equals
public boolean equals(Object object)
Compares this scoped name with the specified object for equality.- Overrides:
equals
in classGenericName
- Parameters:
object
- The object to compare with this name.- Returns:
true
if the given object is equals to this one.
-
hashCode
public int hashCode()
Returns a hash code value for this generic name.- Overrides:
hashCode
in classGenericName
-
-