Package org.apache.sis.referencing
Class NameIterator
java.lang.Object
org.apache.sis.referencing.NameIterator
- All Implemented Interfaces:
Iterator<org.opengis.referencing.ReferenceIdentifier>
final class NameIterator
extends Object
implements Iterator<org.opengis.referencing.ReferenceIdentifier>
An iterator over the name of an identified object followed by
aliases which are instance of
ReferenceIdentifier
.
This iterator is used for AbstractIdentifiedObject
XML marshalling because GML merges the name
and aliases in a single <gml:name>
property. However, this iterator is useful only if the aliases
are instances of NamedIdentifier
, or any other implementation which is both a name and an identifier.
This class also opportunistically provide helper methods for AbstractIdentifiedObject
marshalling.
- Since:
- 0.4
- Version:
- 0.7
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNameIterator
(org.opengis.referencing.IdentifiedObject object) Creates a new iterator over the name and aliases of the given object. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
count
(org.opengis.referencing.IdentifiedObject object) Returns the number of name and aliases in the given object.(package private) static String
getID
(Context context, org.opengis.referencing.IdentifiedObject object, org.opengis.referencing.ReferenceIdentifier name, Collection<? extends org.opengis.util.GenericName> alias, Collection<? extends org.opengis.referencing.ReferenceIdentifier> identifiers) Implementation ofAbstractIdentifiedObject.getID()
, provided here for reducing the amount of code to load in the common case where XML support is not needed.boolean
hasNext()
Returnstrue
if there is another name or alias to return.(package private) static boolean
isUnnamed
(org.opengis.referencing.ReferenceIdentifier name) Returnstrue
if the given identifier is null or theNilReferencingObject.UNNAMED
instance.org.opengis.referencing.ReferenceIdentifier
next()
Returns the next name or alias in the iteration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Field Details
-
next
private org.opengis.referencing.ReferenceIdentifier nextThe next element to return, ornull
if we reached the end of iteration. -
alias
An iterator over the aliases.
-
-
Constructor Details
-
NameIterator
NameIterator(org.opengis.referencing.IdentifiedObject object) Creates a new iterator over the name and aliases of the given object.
-
-
Method Details
-
isUnnamed
static boolean isUnnamed(org.opengis.referencing.ReferenceIdentifier name) Returnstrue
if the given identifier is null or theNilReferencingObject.UNNAMED
instance. -
hasNext
public boolean hasNext()Returnstrue
if there is another name or alias to return. -
next
public org.opengis.referencing.ReferenceIdentifier next()Returns the next name or alias in the iteration. Note: we do not bother checking forNoSuchElementException
because this iterator will be used only by JAXB, which is presumed checking forhasNext()
correctly. -
count
public static int count(org.opengis.referencing.IdentifiedObject object) Returns the number of name and aliases in the given object. -
getID
static String getID(Context context, org.opengis.referencing.IdentifiedObject object, org.opengis.referencing.ReferenceIdentifier name, Collection<? extends org.opengis.util.GenericName> alias, Collection<? extends org.opengis.referencing.ReferenceIdentifier> identifiers) Implementation ofAbstractIdentifiedObject.getID()
, provided here for reducing the amount of code to load in the common case where XML support is not needed.The current implementation searches for the first identifier, regardless its authority. If no identifier is found, then the name and aliases are used. Then, this method returns the concatenation of the following elements separated by hyphens:
- The code space in lower case, retaining only characters that are valid for Unicode identifiers.
- The object type as defined in OGC's URN (see
DefinitionURI
) - The object code, retaining only characters that are valid for Unicode identifiers.
"epsg-crs-4326"
.The returned ID needs to be unique only in the XML document being marshalled. Consecutive invocations of this method do not need to return the same value, since it may depends on the marshalling context.
- Parameters:
context
- the (un)marshalling context.object
- the object for which to get agml:id
.name
- the identified object name, ornull
if none.alias
- the identified object aliases, ornull
if none.identifiers
- the identifiers, ornull
if none.- Returns:
- proposed value for
gml:id
attribute, ornull
if none.
-