Package org.apache.sis.util.iso
Class DefaultScopedName
java.lang.Object
org.apache.sis.util.iso.AbstractName
org.apache.sis.util.iso.DefaultScopedName
- All Implemented Interfaces:
Serializable
,Comparable<org.opengis.util.GenericName>
,org.opengis.util.GenericName
,org.opengis.util.ScopedName
A composite of a name space (as a local name)
and a generic name valid in that name space.
See the GeoAPI javadoc for more information.
DefaultScopedName
can be instantiated by any of the following methods:
DefaultNameFactory.createGenericName(NameSpace, CharSequence[])
with an array of length 2 or more.DefaultNameFactory.parseGenericName(NameSpace, CharSequence)
with at least one occurrence of the separator in the path.- Similar static convenience methods in
Names
.
Immutability and thread safety
This class is immutable and thus inherently thread-safe if theNameSpace
and all CharSequence
elements in the arguments given to the constructor are also immutable. Subclasses shall make sure that any
overridden methods remain safe to call from multiple threads and do not change any public LocalName
state.- Since:
- 0.3
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final UnmodifiableArrayList<? extends org.opengis.util.LocalName>
The immutable list of parsed names.private org.opengis.util.GenericName
The tail or path, computed when first needed.private static final long
Serial number for inter-operability with different versions.private org.opengis.util.GenericName
The tail or path, computed when first needed.Fields inherited from class org.apache.sis.util.iso.AbstractName
asString, fullyQualified
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
DefaultScopedName
(UnmodifiableArrayList<? extends org.opengis.util.LocalName> names) Creates a new scoped names from the given list of local names.protected
DefaultScopedName
(org.opengis.util.GenericName path, String separator, CharSequence tail) Constructs a scoped name as the concatenation of the given generic name with a single character sequence.protected
DefaultScopedName
(org.opengis.util.GenericName path, org.opengis.util.GenericName tail) Constructs a scoped name as the concatenation of the given generic names.protected
DefaultScopedName
(org.opengis.util.NameSpace scope, List<? extends CharSequence> names) Constructs a scoped name from the specified list of strings. -
Method Summary
Modifier and TypeMethodDescription(package private) final int
Returns the size of the backing array.(package private) static AbstractName
create
(UnmodifiableArrayList<? extends DefaultLocalName> names) Creates a new scoped names from the given list of local names.List<? extends org.opengis.util.LocalName>
Returns the sequence of local name for this generic name.private static CharSequence
name
(org.opengis.util.GenericName name) Returns the name to be given toDefaultLocalName
constructors.org.opengis.util.GenericName
path()
Returns every element in the sequence of parsed names except for the tip.org.opengis.util.NameSpace
scope()
Returns the scope (name space) in which this name is local.org.opengis.util.GenericName
tail()
Returns every elements in the sequence of parsed names except for the head.Methods inherited from class org.apache.sis.util.iso.AbstractName
castOrCopy, compareTo, computeHashCode, depth, equals, hashCode, head, push, tip, toFullyQualifiedName, toInternationalString, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface org.opengis.util.GenericName
depth, push, toFullyQualifiedName, toInternationalString
Methods inherited from interface org.opengis.util.ScopedName
head, tip, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
parsedNames
The immutable list of parsed names. -
tail
private transient org.opengis.util.GenericName tailThe tail or path, computed when first needed. -
path
private transient org.opengis.util.GenericName pathThe tail or path, computed when first needed.
-
-
Constructor Details
-
DefaultScopedName
Creates a new scoped names from the given list of local names. This constructor is not public because it does not check if the given local names have the proper scope.- Parameters:
names
- the names to gives to the new scoped name.
-
DefaultScopedName
Constructs a scoped name from the specified list of strings. If any of the given names is an instance ofInternationalString
, then itstoString(Locale.ROOT)
method will be invoked for fetching an unlocalized name. Otherwise theCharSequence.toString()
method will be used.- Parameters:
scope
- the scope of this name, ornull
for the global scope.names
- the local names. This list must have at least two elements.
-
DefaultScopedName
protected DefaultScopedName(org.opengis.util.GenericName path, org.opengis.util.GenericName tail) Constructs a scoped name as the concatenation of the given generic names. The scope of the new name will be the scope of thepath
argument.- Parameters:
path
- the first part to concatenate.tail
- the second part to concatenate.
-
DefaultScopedName
Constructs a scoped name as the concatenation of the given generic name with a single character sequence. The scope of the new name will be the scope of thepath
argument. The tail is a local name created from the given character sequence.- Parameters:
path
- the first part to concatenate.separator
- the separator between the head and the tail, ornull
for inheriting the same separator than the given path.tail
- the second part to concatenate.- Since:
- 0.8
- See Also:
-
-
Method Details
-
create
Creates a new scoped names from the given list of local names. This constructor is not public because we do not check if the given local names have the proper scope.- Parameters:
names
- the names to gives to the new scoped name.
-
name
Returns the name to be given toDefaultLocalName
constructors. -
arraySize
final int arraySize()Returns the size of the backing array. This is used only has a hint for optimizations in attempts to share internal arrays.- Overrides:
arraySize
in classAbstractName
-
scope
public org.opengis.util.NameSpace scope()Returns the scope (name space) in which this name is local. For example if a fully qualified name is"org.opengis.util.Record"
and if this instance is the"util.Record"
part, then its scope is named"org.opengis"
.Continuing with the above example, the full
"org.opengis.util.Record"
name has no scope. If this method is invoked on such name, then the SIS implementation returns a global scope instance (i.e. an instance for whichDefaultNameSpace.isGlobal()
returnstrue
) which is unique and named"global"
.- Specified by:
scope
in interfaceorg.opengis.util.GenericName
- Specified by:
scope
in classAbstractName
- Returns:
- the scope of this name.
-
tail
public org.opengis.util.GenericName tail()Returns every elements in the sequence of parsed names except for the head.- Specified by:
tail
in interfaceorg.opengis.util.ScopedName
- Returns:
- all elements except the first one in the in the list of parsed names.
-
path
public org.opengis.util.GenericName path()Returns every element in the sequence of parsed names except for the tip.- Specified by:
path
in interfaceorg.opengis.util.ScopedName
- Returns:
- all elements except the last one in the in the list of parsed names.
-
getParsedNames
Returns the sequence of local name for this generic name.- Specified by:
getParsedNames
in interfaceorg.opengis.util.GenericName
- Specified by:
getParsedNames
in classAbstractName
- Returns:
- the local names making this generic name, without the scope.
Shall never be
null
neither empty.
-