Class DefaultLocalName

java.lang.Object
org.apache.sis.util.iso.AbstractName
org.apache.sis.util.iso.DefaultLocalName
All Implemented Interfaces:
Serializable, Comparable<org.opengis.util.GenericName>, org.opengis.util.GenericName, org.opengis.util.LocalName
Direct Known Subclasses:
DefaultMemberName, DefaultTypeName

public class DefaultLocalName extends AbstractName implements org.opengis.util.LocalName
Identifier within a name space for a local object. Local names are names which are directly accessible to and maintained by a name space. Names are local to one and only one name space. The name space within which they are local is indicated by the scope.

DefaultLocalName 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 LocalName state.
Since:
0.3
Version:
1.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final CharSequence
    The name, either as a String or an InternationalString.
    (package private) final org.opengis.util.NameSpace
    The scope of this name, or null if the scope is the unique GLOBAL instance.
    private static final long
    Serial number for inter-operability with different versions.

    Fields inherited from class org.apache.sis.util.iso.AbstractName

    asString, fullyQualified
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    (package private)
    Empty constructor to be used by JAXB only, or by sub-classes empty constructors themselves used only by JAXB.
    protected
    DefaultLocalName(org.opengis.util.NameSpace scope, CharSequence name)
    Constructs a local name from the given character sequence.
  • Method Summary

    Modifier and Type
    Method
    Description
    castOrCopy(org.opengis.util.LocalName object)
    Returns a SIS local name implementation with the values of the given arbitrary implementation.
    int
    compareTo(org.opengis.util.GenericName name)
    Compares this name with the specified object for order.
    (package private) int
    Invoked by AbstractName.hashCode() for computing the hash code value when first needed.
    final int
    Returns the depth, which is always 1 for a local name.
    boolean
    equals(Object object)
    Compares this local name with the specified object for equality.
    Returns the sequence of local name for this name.
    final org.opengis.util.LocalName
    Returns this since this object is already a local name.
    private Object
    If an instance already exists for the deserialized name, returns that instance.
    org.opengis.util.NameSpace
    Returns the scope (name space) in which this name is local.
    final org.opengis.util.LocalName
    tip()
    Returns this since this object is already a local name.
    org.opengis.util.InternationalString
    Returns a local-dependent string representation of this local name.
    Returns a locale-independent string representation of this local name.

    Methods inherited from class org.apache.sis.util.iso.AbstractName

    arraySize, castOrCopy, hashCode, push, toFullyQualifiedName

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opengis.util.GenericName

    push, toFullyQualifiedName
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for inter-operability with different versions.
      See Also:
    • scope

      final org.opengis.util.NameSpace scope
      The scope of this name, or null if the scope is the unique GLOBAL instance. We don't use direct reference to GLOBAL because null is used as a sentinel value for stopping iterative searches (using GLOBAL would have higher risk of never-ending loops in case of bug), and in order to reduce the stream size during serialization.
    • name

      final CharSequence name
      The name, either as a String or an InternationalString.

      Note on JAXB annotation

      The XmlElement annotation applied here is appropriate for TypeName and MemberName subtypes only. It is not appropriate when (un)marshalling directly a LocalName. The distinction between the two cases is done by GO_GenericName, which replace the LocalName instance by an internal NameValue object (so the XML element declared here is never marshalled). Example: versus
  • Constructor Details

    • DefaultLocalName

      protected DefaultLocalName(org.opengis.util.NameSpace scope, CharSequence name)
      Constructs a local name from the given character sequence. If the character sequence is an instance of InternationalString, then its toString(Locale.ROOT) method will be invoked for fetching an unlocalized name. Otherwise the CharSequence.toString() method will be used.
      Parameters:
      scope - the scope of this name, or null for a global scope.
      name - the local name (never null).
    • DefaultLocalName

      DefaultLocalName()
      Empty constructor to be used by JAXB only, or by sub-classes empty constructors themselves used only by JAXB. Despite its `final` declaration, the name field will be set by JAXB during unmarshalling.
  • Method Details

    • castOrCopy

      public static DefaultLocalName castOrCopy(org.opengis.util.LocalName object)
      Returns a SIS local name implementation with the values of the given arbitrary implementation. This method performs the first applicable action in the following choices:
      • If the given object is null, then this method returns null.
      • Otherwise if the given object is an instance of MemberName or TypeName, then this method delegates to castOrCopy(…) method of the corresponding subclass.
      • Otherwise if the given object is already an instance of DefaultLocalName, then it is returned unchanged.
      • Otherwise a new DefaultLocalName instance is created with the same values than the given name.
      Parameters:
      object - the object to get as a SIS implementation, or null if none.
      Returns:
      a SIS implementation containing the values of the given object (may be the given object itself), or null if the argument was null.
    • scope

      public org.opengis.util.NameSpace scope()
      Returns the scope (name space) in which this name is local. This method returns a non-null value in all cases, even when the scope given to the constructor was null.
      Specified by:
      scope in interface org.opengis.util.GenericName
      Specified by:
      scope in class AbstractName
      Returns:
      the scope of this name.
    • depth

      public final int depth()
      Returns the depth, which is always 1 for a local name.
      Specified by:
      depth in interface org.opengis.util.GenericName
      Specified by:
      depth in interface org.opengis.util.LocalName
      Overrides:
      depth in class AbstractName
      Returns:
      the depth of this name.
    • getParsedNames

      public final List<DefaultLocalName> getParsedNames()
      Returns the sequence of local name for this name. Since this object is itself a local name, this method always returns a singleton containing only this.
      Specified by:
      getParsedNames in interface org.opengis.util.GenericName
      Specified by:
      getParsedNames in interface org.opengis.util.LocalName
      Specified by:
      getParsedNames in class AbstractName
      Returns:
      the local names making this generic name, without the scope. Shall never be null neither empty.
    • head

      public final org.opengis.util.LocalName head()
      Returns this since this object is already a local name.
      Specified by:
      head in interface org.opengis.util.GenericName
      Specified by:
      head in interface org.opengis.util.LocalName
      Overrides:
      head in class AbstractName
      Returns:
      this.
    • tip

      public final org.opengis.util.LocalName tip()
      Returns this since this object is already a local name.
      Specified by:
      tip in interface org.opengis.util.GenericName
      Specified by:
      tip in interface org.opengis.util.LocalName
      Overrides:
      tip in class AbstractName
      Returns:
      this.
    • toString

      public String toString()
      Returns a locale-independent string representation of this local name. This string does not include the scope, which is consistent with the parsed names definition.
      Specified by:
      toString in interface org.opengis.util.GenericName
      Specified by:
      toString in interface org.opengis.util.LocalName
      Overrides:
      toString in class AbstractName
      Returns:
      a local-independent string representation of this name.
    • toInternationalString

      public org.opengis.util.InternationalString toInternationalString()
      Returns a local-dependent string representation of this local name.
      Specified by:
      toInternationalString in interface org.opengis.util.GenericName
      Overrides:
      toInternationalString in class AbstractName
      Returns:
      a localizable string representation of this name.
    • compareTo

      public int compareTo(org.opengis.util.GenericName name)
      Compares this name with the specified object for order. Returns a negative integer, zero, or a positive integer as this name lexicographically precedes, is equal to, or follows the specified object.
      Specified by:
      compareTo in interface Comparable<org.opengis.util.GenericName>
      Overrides:
      compareTo in class AbstractName
      Parameters:
      name - the other name to compare with this name.
      Returns:
      -1 if this name precedes the given one, +1 if it follows, 0 if equals.
    • equals

      public boolean equals(Object object)
      Compares this local name with the specified object for equality.
      Overrides:
      equals in class AbstractName
      Parameters:
      object - the object to compare with this name for equality.
      Returns:
      true if the given object is equal to this name.
    • computeHashCode

      int computeHashCode()
      Invoked by AbstractName.hashCode() for computing the hash code value when first needed.
      Overrides:
      computeHashCode in class AbstractName
    • readResolve

      private Object readResolve() throws ObjectStreamException
      If an instance already exists for the deserialized name, returns that instance.

      Because of its private access, this method is not invoked if the deserialized class is a subclass. This is the intended behavior since we don't want to replace an instance of a user-defined class.

      Returns:
      the unique instance.
      Throws:
      ObjectStreamException - required by specification but should never be thrown.