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. AScopedNamecontains aLocalNameas head and a GenericName, which may be aLocalNameor 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 booleanequals(Object object)Compares this scoped name with the specified object for equality.protected GenericNamegetInternalScope()Returns the scope (name space) of this generic name.List<LocalName>getParsedNames()Returns the sequence of local name for this generic name.chargetSeparator()Returns the separator character.inthashCode()Returns a hash code value for this generic name.LocalNamehead()Returns the head of this scoped name.GenericNamepath()Returns a name which contains every element of the parsed names list except for the last element.ScopedNamepush(GenericName scope)Returns this name expanded with the specified scope.GenericNametail()Returns the tail of this scoped name.LocalNametip()Returns a view of this object as a local name.GenericNametoFullyQualifiedName()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:
headin interfaceGenericName- Specified by:
headin interfaceScopedName- Overrides:
headin 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
equalsmethod instead of the Java identity comparator==.- Specified by:
tailin 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:
pathin 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:
tipin interfaceGenericName- Specified by:
tipin interfaceScopedName- Overrides:
tipin classGenericName- Returns:
- The last element of this name.
-
getInternalScope
protected GenericName getInternalScope()
Description copied from class:GenericNameReturns 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:
getInternalScopein classGenericName
-
getParsedNames
public List<LocalName> getParsedNames()
Returns the sequence of local name for this generic name.- Specified by:
getParsedNamesin interfaceGenericName- Specified by:
getParsedNamesin 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:
toFullyQualifiedNamein 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 specifiednamewiththis. 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
equalsmethod instead of the Java identity comparator==.- Specified by:
pushin 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:
equalsin classGenericName- Parameters:
object- The object to compare with this name.- Returns:
trueif the given object is equals to this one.
-
hashCode
public int hashCode()
Returns a hash code value for this generic name.- Overrides:
hashCodein classGenericName
-
-