Class DefaultNameSpace

java.lang.Object
org.apache.sis.util.iso.DefaultNameSpace
All Implemented Interfaces:
Serializable, org.opengis.util.NameSpace

public class DefaultNameSpace extends Object implements org.opengis.util.NameSpace, Serializable
A domain in which names given by character strings are defined. This implementation does not support localization in order to avoid ambiguity when testing two namespaces for equality.

DefaultNameSpace can be instantiated by any of the following methods:

Immutability and thread safety

This class is immutable and thus inherently thread-safe if the NameSpace and CharSequence arguments given to the constructor are also immutable. Subclasses shall make sure that any overridden methods remain safe to call from multiple threads and do not change any public NameSpace state.
Since:
0.3
Version:
1.3
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The default separator, which is ':'.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    DefaultNameSpace(DefaultNameSpace parent, CharSequence name, String headSeparator, String separator)
    Creates a new namespace with the given separator.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    Returns true if this namespace is equal to the given object.
    static String
    getSeparator(org.opengis.util.NameSpace ns, boolean head)
    Returns the separator between name components in the given namespace.
    int
    Returns a hash code value for this namespace.
    boolean
    Indicates whether this namespace is a "top level" namespace.
    org.opengis.util.GenericName
    Represents the identifier of this namespace.
    Returns a JCR-like lexical form representation of this namespace.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_SEPARATOR

      public static final char DEFAULT_SEPARATOR
      The default separator, which is ':'. The separator is inserted between the namespace and any generic name in that namespace.
      See Also:
  • Constructor Details

    • DefaultNameSpace

      protected DefaultNameSpace(DefaultNameSpace parent, CharSequence name, String headSeparator, String separator)
      Creates a new namespace with the given separator.
      Parameters:
      parent - the parent namespace, or null if none.
      name - the name of the new namespace, usually as a String or an InternationalString.
      headSeparator - the separator to insert between the namespace and the head of any name in that namespace.
      separator - the separator to insert between the parsed names of any name in that namespace.
  • Method Details

    • getSeparator

      public static String getSeparator(org.opengis.util.NameSpace ns, boolean head)
      Returns the separator between name components in the given namespace. If the given namespace is an instance of DefaultNameSpace, then this method returns the headSeparator or separator argument given to the constructor. Otherwise this method returns the default separator.
      API note: this method is static because the getSeparator(…) method is not part of GeoAPI interfaces. A static method makes easier to use without (if (x instanceof DefaultNameSpace) checks.
      Parameters:
      ns - the namespace for which to get the separator. May be null.
      head - true for the separator between namespace and head, or false for the separator between parsed names.
      Returns:
      separator between name components.
      Since:
      1.3
    • isGlobal

      public boolean isGlobal()
      Indicates whether this namespace is a "top level" namespace. Global, or top-level namespaces are not contained within another namespace. The global namespace has no parent.
      Specified by:
      isGlobal in interface org.opengis.util.NameSpace
      Returns:
      true if this namespace is the global namespace.
    • name

      public org.opengis.util.GenericName name()
      Represents the identifier of this namespace. Namespace identifiers shall be fully-qualified names where the following condition holds:
      Specified by:
      name in interface org.opengis.util.NameSpace
      Returns:
      the identifier of this namespace.
    • toString

      public String toString()
      Returns a JCR-like lexical form representation of this namespace. Following the Java Content Repository (JCR) convention, this method returns the string representation of name() between curly brackets.
      Example: if the name of this namespace is “org.apache.sis”, then this method returns “{org.apache.sis}”.

      Usage

      With this convention, it would be possible to create an expanded form of a generic name (except for escaping of illegal characters) with a simple concatenation as in the following code example: However, the convention followed by this DefaultNameSpace implementation is not specified in the NameSpace contract. This implementation follows the JCR convention for debugging convenience, but applications needing better guarantees should use Names.toExpandedString(GenericName) instead.
      Overrides:
      toString in class Object
      Returns:
      a JCR-like lexical form of this namespace.
      See Also:
    • equals

      public boolean equals(Object object)
      Returns true if this namespace is equal to the given object.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare with this namespace.
      Returns:
      true if the given object is equal to this namespace.
    • hashCode

      public int hashCode()
      Returns a hash code value for this namespace.
      Overrides:
      hashCode in class Object