Class Identifiers

java.lang.Object
org.apache.sis.util.Static
org.apache.sis.internal.metadata.Identifiers

public final class Identifiers extends Static
Methods working on Identifier instances.
Since:
1.2
Version:
1.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Do not allow instantiation of this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static boolean
    authorityMatches(org.opengis.metadata.Identifier identifier, org.opengis.metadata.citation.Citation authority, String codeSpace)
    Returns true if the given identifier authority matches the given authority.
    static String
    getIdentifier(org.opengis.metadata.citation.Citation citation, boolean strict)
    Infers an identifier from the given citation, or returns null if no identifier has been found.
    static Boolean
    hasCommonIdentifier(Iterable<? extends org.opengis.referencing.ReferenceIdentifier> id1, Iterable<? extends org.opengis.referencing.ReferenceIdentifier> id2)
    Determines whether a match or mismatch is found between the two given collections of identifiers.
    private static boolean
    Return true if the given object is deprecated.
    static boolean
    isEPSG(String codeSpace, String code)
    Returns true if the given code is "EPSG" while the codespace is "IOGP" or "OGP" (ignoring case).
    static String
    missingValueForProperty(org.opengis.metadata.Identifier owner, String property)
    Returns a message saying that a property is missing for an object having the given identifier.
    private static String
    toString(org.opengis.util.InternationalString title)
    Returns a "unlocalized" string representation of the given international string, or null if none or if the string is deprecated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Identifiers

      private Identifiers()
      Do not allow instantiation of this class.
  • Method Details

    • isEPSG

      public static boolean isEPSG(String codeSpace, String code)
      Returns true if the given code is "EPSG" while the codespace is "IOGP" or "OGP" (ignoring case). This particular combination of code and codespace is handled in a special way.

      This method can be used for identifying where in Apache SIS source code the relationship between EPSG authority and IOGP code space is hard-coded.

      Parameters:
      codeSpace - the identifier code space, or null.
      code - the identifier code, or null.
      Returns:
      true if the given identifier is "IOGP:EPSG".
      See Also:
    • isDeprecated

      private static boolean isDeprecated(Object object)
      Return true if the given object is deprecated.
    • toString

      private static String toString(org.opengis.util.InternationalString title)
      Returns a "unlocalized" string representation of the given international string, or null if none or if the string is deprecated. This method is used by getIdentifier(Citation, boolean), which is why we don't want the localized string.
    • getIdentifier

      public static String getIdentifier(org.opengis.metadata.citation.Citation citation, boolean strict)
      Infers an identifier from the given citation, or returns null if no identifier has been found. This method removes leading and trailing whitespaces. See Citations.getIdentifier(Citation) for the public documentation of this method.

      Which method to use

      Guidelines:
      • For information purpose (e.g. some toString() methods), use getIdentifier(…, false).
      • For WKT formatting, use getIdentifier(…, true) in order to preserve formatting characters.
      • For assigning a value to a codeSpace field, use Citations.toCodeSpace(Citation).
      Use toCodeSpace(…) method when assigning values to be returned by methods like ReferenceIdentifier.getCodeSpace(), since those values are likely to be compared without special care about ignorable identifier characters. But if the intent is to format a more complex string like WKT or toString(), then we suggest to use getIdentifier(citation, true) instead, which will produce the same result but preserving the ignorable characters, which can be useful for formatting purpose.
      Parameters:
      citation - the citation for which to get the identifier, or null.
      strict - true for returning a non-null value only if the identifier is a valid Unicode identifier.
      Returns:
      a non-empty identifier for the given citation without leading or trailing whitespaces, or null if the given citation is null or does not declare any identifier or title.
      See Also:
    • authorityMatches

      private static boolean authorityMatches(org.opengis.metadata.Identifier identifier, org.opengis.metadata.citation.Citation authority, String codeSpace)
      Returns true if the given identifier authority matches the given authority. If one of the authority is null, then the comparison fallback on the given codeSpace. If the code spaces are also null, then this method conservatively returns false.
      Parameters:
      identifier - the identifier to compare.
      authority - the desired authority, or null.
      codeSpace - the desired code space or null, used as a fallback if an authority is null.
      Returns:
      true if the authority or code space (as a fallback only) matches.
    • hasCommonIdentifier

      public static Boolean hasCommonIdentifier(Iterable<? extends org.opengis.referencing.ReferenceIdentifier> id1, Iterable<? extends org.opengis.referencing.ReferenceIdentifier> id2)
      Determines whether a match or mismatch is found between the two given collections of identifiers. If any of the given collections is null or empty, then this method returns null.

      According ISO 19162 (Well known text representation of coordinate reference systems), identifiers should have precedence over name for identifying IdentifiedObjects, at least in the case of operation methods and parameters.

      Parameters:
      id1 - the first collection of identifiers, or null.
      id2 - the second collection of identifiers, or null.
      Returns:
      TRUE or FALSE on match or mismatch respectively, or null if this method cannot determine if there is a match or mismatch.
    • missingValueForProperty

      public static String missingValueForProperty(org.opengis.metadata.Identifier owner, String property)
      Returns a message saying that a property is missing for an object having the given identifier.
      Parameters:
      owner - identifier of the object for which a property is missing.
      property - name of the missing property.
      Returns:
      a message saying that a value is missing for the given property in the specified identified object.
      Since:
      1.2