Class ModifiableIdentifierMap

java.lang.Object
java.util.AbstractMap<org.opengis.metadata.citation.Citation,String>
org.apache.sis.internal.jaxb.IdentifierMapAdapter
org.apache.sis.internal.jaxb.ModifiableIdentifierMap
All Implemented Interfaces:
Serializable, Map<org.opengis.metadata.citation.Citation,String>, IdentifierMap

public final class ModifiableIdentifierMap extends IdentifierMapAdapter
A map of identifiers which support put and remove operations.

Thread safety

This class is thread safe if the underlying identifier collection is thread safe.
Since:
0.7
Version:
0.7
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
  • Constructor Details

    • ModifiableIdentifierMap

      public ModifiableIdentifierMap(Collection<org.opengis.metadata.Identifier> identifiers)
      Creates a new map which will be a view over the given identifiers.
      Parameters:
      identifiers - the identifiers to wrap in a map view.
  • Method Details

    • setHRef

      private URI setHRef(URI href)
      Sets the xlink:href value, which may be null. If an explicit xlink:href identifier exists, then it will removed before to set the new href in the XLink object. The intent is to give precedence to the XLink.getHRef() property in every cases where the href is parsable as a URI, and use the value associated to the HREF key only as a fallback when the string cannot be parsed.
      Parameters:
      href - the new value, or null for removing the value.
      Returns:
      the previous value, or null if none.
      See Also:
    • isModifiable

      final boolean isModifiable()
      Returns true since this map support put and remove operations.
      Overrides:
      isModifiable in class IdentifierMapAdapter
    • clear

      public void clear()
      Removes every entries in the underlying collection.
      Specified by:
      clear in interface Map<org.opengis.metadata.citation.Citation,String>
      Overrides:
      clear in class IdentifierMapAdapter
    • remove

      public String remove(Object authority)
      Removes all identifiers associated with the given authority. The default implementation delegates to put(Citation, String) with a null value.
      Specified by:
      remove in interface Map<org.opengis.metadata.citation.Citation,String>
      Overrides:
      remove in class IdentifierMapAdapter
      Parameters:
      authority - the authority to search, which should be an instance of Citation.
      Returns:
      the code of the identifier for the given authority, or null if none.
    • put

      public String put(org.opengis.metadata.citation.Citation authority, String code)
      Sets the code of the identifier having the given authority to the given value. If no identifier is found for the given authority, a new one is created. If more than one identifier is found for the given authority, then all previous identifiers may be removed in order to ensure that the new entry will be the first entry, so it can be find by the get method.

      If the given authority is HREF and if the given string is parsable as a URI, then this method will actually store the value as the XLink.getHRef() property of the XLink associated to the XLINK key. Only if the given string cannot be parsed, then the value is stored as-is under the HREF key.

      Specified by:
      put in interface Map<org.opengis.metadata.citation.Citation,String>
      Overrides:
      put in class IdentifierMapAdapter
      Parameters:
      authority - the authority for which to set the code.
      code - the new code for the given authority, or null for removing the entry.
      Returns:
      the previous code for the given authority, or null if none.
    • putSpecialized

      public <T> T putSpecialized(IdentifierSpace<T> authority, T value)
      Sets the identifier associated with the given authority, and returns the previous value.

      If the given authority is HREF, then this method will actually store the value as the XLink.getHRef() property of the XLink associated to the XLINK key. The previous HREF value, if any, is discarded.

      Specified by:
      putSpecialized in interface IdentifierMap
      Overrides:
      putSpecialized in class IdentifierMapAdapter
      Type Parameters:
      T - the identifier type.
      Parameters:
      authority - the namespace with which the given identifier is to be associated.
      value - the identifier to be associated with the given namespace.
      Returns:
      the previous identifier associated with authority, or null if there was no mapping of the specialized type for authority.
    • store

      private <T> T store(IdentifierSpace<T> authority, T value)
      Sets the identifier associated with the given authority, without processing for special cases.
      Type Parameters:
      T - the identifier type.
      Parameters:
      authority - the namespace with which the given identifier is to be associated.
      value - the identifier to be associated with the given namespace.
      Returns:
      the previous identifier associated with authority, or null if there was no mapping of the specialized type for authority.