Class AbstractIdentifiedObject.Names

java.lang.Object
java.util.AbstractCollection<org.opengis.referencing.ReferenceIdentifier>
org.apache.sis.referencing.AbstractIdentifiedObject.Names
All Implemented Interfaces:
Iterable<org.opengis.referencing.ReferenceIdentifier>, Collection<org.opengis.referencing.ReferenceIdentifier>
Enclosing class:
AbstractIdentifiedObject

private final class AbstractIdentifiedObject.Names extends AbstractCollection<org.opengis.referencing.ReferenceIdentifier>
A writable view over the name of the enclosing object followed by all aliases which are instance of Identifier. Used by JAXB only at (un)marshalling time because GML merges the name and aliases in a single <gml:name> property.

Why we do not use Identifier[] array instead

It would be easier to define a getNames() method returning all identifiers in an array, and let JAXB invoke setNames(Identifier[]) at unmarshalling time. But methods expecting an array in argument are invoked by JAXB only after the full element has been unmarshalled. For some AbstractIdentifiedObject subclasses, this is too late. For example, DefaultOperationMethod may need to know the operation name before to parse the parameters.
  • Constructor Details

    • Names

      private Names()
  • Method Details

    • clear

      public void clear()
      Invoked by JAXB before to write in the collection at unmarshalling time. Do nothing since our object is already empty.
      Specified by:
      clear in interface Collection<org.opengis.referencing.ReferenceIdentifier>
      Overrides:
      clear in class AbstractCollection<org.opengis.referencing.ReferenceIdentifier>
    • size

      public int size()
      Returns the number of name and aliases that are instance of Identifier.
      Specified by:
      size in interface Collection<org.opengis.referencing.ReferenceIdentifier>
      Specified by:
      size in class AbstractCollection<org.opengis.referencing.ReferenceIdentifier>
    • iterator

      public Iterator<org.opengis.referencing.ReferenceIdentifier> iterator()
      Returns an iterator over the name and aliases that are instance of Identifier.
      Specified by:
      iterator in interface Collection<org.opengis.referencing.ReferenceIdentifier>
      Specified by:
      iterator in interface Iterable<org.opengis.referencing.ReferenceIdentifier>
      Specified by:
      iterator in class AbstractCollection<org.opengis.referencing.ReferenceIdentifier>
    • add

      public boolean add(org.opengis.referencing.ReferenceIdentifier id)
      Invoked by JAXB at unmarshalling time for each identifier. The first identifier will be taken as the name and all other identifiers (if any) as aliases.

      Some (but not all) JAXB implementations never invoke setter method for collections. Instead, they invoke AbstractIdentifiedObject.getNames() and add directly the identifiers in the returned collection. Consequently, this method must writes directly in the enclosing object. See JAXB-488 for more information.

      Specified by:
      add in interface Collection<org.opengis.referencing.ReferenceIdentifier>
      Overrides:
      add in class AbstractCollection<org.opengis.referencing.ReferenceIdentifier>