Class IdentifierMapAdapter.Iter

java.lang.Object
java.util.AbstractMap<org.opengis.metadata.citation.Citation,Boolean>
java.util.HashMap<org.opengis.metadata.citation.Citation,Boolean>
org.apache.sis.internal.jaxb.IdentifierMapAdapter.Iter
All Implemented Interfaces:
Serializable, Cloneable, Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>, Map<org.opengis.metadata.citation.Citation,Boolean>
Enclosing class:
IdentifierMapAdapter

private static final class IdentifierMapAdapter.Iter extends HashMap<org.opengis.metadata.citation.Citation,Boolean> implements Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>
The iterator over the (citation, code) entries. This iterator is created by the HashMap.entrySet() collection. It extends HashMap as an opportunist implementation strategy, but users do not need to know this detail.

This iterator supports the remove() operation if the underlying collection supports it.

The map entries are used as a safety against duplicated authority values. The map values are non-null only after we iterated over an authority. Then the value is Boolean.TRUE if the identifier has been removed, of Boolean#FALSE otherwise.

Since:
0.3
Version:
0.7
  • Field Details

    • identifiers

      private Iterator<? extends org.opengis.metadata.Identifier> identifiers
      An iterator over the IdentifierMapAdapter.identifiers collection, or (@code null} if we have reached the iteration end.
    • next

      private transient Map.Entry<org.opengis.metadata.citation.Citation,String> next
      The next entry to be returned by next(), or null if not yet computed. This field will be computed only when next() or hasNext() is invoked.
    • authority

      private transient org.opengis.metadata.citation.Citation authority
      The current authority. Used only for removal operations.
    • isModifiable

      private final boolean isModifiable
      true if the iterator should support the remove() operation.
  • Constructor Details

    • Iter

      Iter(Collection<? extends org.opengis.metadata.Identifier> identifiers, boolean isModifiable)
      Creates a new iterator for the given collection of identifiers.
  • Method Details

    • toNext

      private void toNext()
      Advances to the next non-null identifier, skips duplicated authorities, wraps the identifier in an entry if needed and stores the result in the next field. If we reach the iteration end, then this method set the identifiers iterator to null.
    • hasNext

      public boolean hasNext()
      If we need to search for the next element, fetches it now. Then returns true if we didn't reached the iteration end.
      Specified by:
      hasNext in interface Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>
    • next

      public Map.Entry<org.opengis.metadata.citation.Citation,String> next() throws NoSuchElementException
      If we need to search for the next element, searches it now. Then set next to null as a flag meaning that next invocations will need to search again for an element, and returns the element that we got.
      Specified by:
      next in interface Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>
      Throws:
      NoSuchElementException
    • remove

      public void remove() throws IllegalStateException
      Removes the last element returned by next(). Note that if the next field is non-null, that would mean that the iteration has moved since the last call to the next() method, in which case the iterator is invalid.
      Specified by:
      remove in interface Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>
      Throws:
      IllegalStateException
    • clone

      public Object clone()
      Iterators are not intended to be cloned.
      Overrides:
      clone in class HashMap<org.opengis.metadata.citation.Citation,Boolean>
    • toString

      public String toString()
      Returns the next value to be returned, for debugging purpose only.
      Overrides:
      toString in class AbstractMap<org.opengis.metadata.citation.Citation,Boolean>