org.geotoolkit.referencing
Class NamedIdentifier

Object
  extended by DefaultReferenceIdentifier
      extended by NamedIdentifier
All Implemented Interfaces:
Serializable, Comparable<GenericName>, Identifier, ReferenceIdentifier, GenericName

@Immutable
public class NamedIdentifier
extends DefaultReferenceIdentifier
implements GenericName

An identification of a CRS object which is both an identifier and a name. The main interface implemented by this class is ReferenceIdentifier. However, this class also implements GenericName in order to make it possible to reuse the same identifiers in the list of aliases. Casting an alias GenericName to an ReferenceIdentifier gives access to more informations, like the URL of the authority.

The generic name will be inferred from ReferenceIdentifier attributes. More specifically, a scoped name will be created using the shortest authority's alternate titles (or the main title if there is no alternate titles) as the scope, and the code as the tip. This heuristic rule seems reasonable since, according ISO 19115, the alternate titles often contains abbreviation (for example "DCW" as an alternative title for "Digital Chart of the World").

Since:
2.0
Version:
3.16
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 
Fields inherited from interface ReferenceIdentifier
CODESPACE_KEY, VERSION_KEY
 
Fields inherited from interface Identifier
AUTHORITY_KEY, CODE_KEY
 
Constructor Summary
NamedIdentifier(Citation authority, InternationalString code)
          Constructs an identifier from an authority and code informations.
NamedIdentifier(Citation authority, String code)
          Constructs an identifier from an authority and code informations.
NamedIdentifier(Citation authority, String code, String version)
          Constructs an identifier from an authority and code informations.
NamedIdentifier(Map<String,?> properties)
          Constructs an identifier from a set of properties.
NamedIdentifier(ReferenceIdentifier identifier)
          Creates a new identifier from the specified one.
 
Method Summary
 int compareTo(GenericName object)
          Compares this name with the specified object for order.
 int depth()
          Returns the depth of this name within the namespace hierarchy.
 boolean equals(Object object)
          Compares this identifier with the specified object for equality.
 List<? extends LocalName> getParsedNames()
          Returns the sequence of local names making this generic name.
 LocalName head()
          Returns the first element in the sequence of parsed names.
 ScopedName push(GenericName scope)
          Returns this name expanded with the specified scope.
 NameSpace scope()
          Returns the scope (name space) in which this name is local.
 LocalName tip()
          The last element in the sequence of parsed names.
 GenericName toFullyQualifiedName()
          Returns a view of this name as a fully-qualified name.
 InternationalString toInternationalString()
          Returns a local-dependent string representation of this generic name.
 String toString()
          Returns a string representation of this generic name.
 
Methods inherited from class DefaultReferenceIdentifier
getAuthority, getCode, getCodeSpace, getRemarks, getVersion, hashCode, isDeprecated
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedIdentifier

public NamedIdentifier(ReferenceIdentifier identifier)
Creates a new identifier from the specified one. This is a copy constructor which will get the code, codespace, authority, version and (if available) the remarks from the given identifier.

If the given identifier implements the GenericName interface, then calls to tip(), head(), scope() and similar methods will delegates to that name.

Parameters:
identifier - The identifier to copy.
Since:
3.16

NamedIdentifier

public NamedIdentifier(Map<String,?> properties)
                throws IllegalArgumentException
Constructs an identifier from a set of properties. The content of the properties map is used as described in the super-class constructor.

Parameters:
properties - The properties to be given to this identifier.
Throws:
InvalidParameterValueException - if a property has an invalid value.
IllegalArgumentException - if a property is invalid for some other reason.

NamedIdentifier

public NamedIdentifier(Citation authority,
                       InternationalString code)
Constructs an identifier from an authority and code informations. This is a convenience constructor for commonly-used parameters. If more control are wanted (for example adding remarks), use the constructor with a properties map.

Parameters:
authority - The authority (e.g. OGC or EPSG), or null if not available.
code - The code. The toString(null) method is invoked for the code, and the complete international string is retained for the generic name.

NamedIdentifier

public NamedIdentifier(Citation authority,
                       String code)
Constructs an identifier from an authority and code informations. This is a convenience constructor for commonly-used parameters. If more control are wanted (for example adding remarks), use the constructor with a properties map.

Parameters:
authority - The authority (e.g. OGC or EPSG), or null if not available.
code - The code. This parameter is mandatory.

NamedIdentifier

public NamedIdentifier(Citation authority,
                       String code,
                       String version)
Constructs an identifier from an authority and code informations. This is a convenience constructor for commonly-used parameters. If more control are wanted (for example adding remarks), use the constructor with a properties map.

Parameters:
authority - The authority (e.g. OGC or EPSG), or null if not available.
code - The code. This parameter is mandatory.
version - The version, or null if none.
Method Detail

tip

public LocalName tip()
The last element in the sequence of parsed names. By default, this is the same value than DefaultReferenceIdentifier.getCode() provided as a local name.

Specified by:
tip in interface GenericName
See Also:
DefaultReferenceIdentifier.getCode()

head

public LocalName head()
Returns the first element in the sequence of parsed names. By default, this is the same value than DefaultReferenceIdentifier.getCodeSpace(org.opengis.metadata.citation.Citation) provided as a local name.

Specified by:
head in interface GenericName
See Also:
scope(), DefaultReferenceIdentifier.getCodeSpace(org.opengis.metadata.citation.Citation)

scope

public NameSpace scope()
Returns the scope (name space) in which this name is local. By default, this is the same value than DefaultReferenceIdentifier.getCodeSpace(org.opengis.metadata.citation.Citation) provided as a name space.

Specified by:
scope in interface GenericName
Since:
2.3
See Also:
head(), DefaultReferenceIdentifier.getCodeSpace(org.opengis.metadata.citation.Citation)

depth

public int depth()
Returns the depth of this name within the namespace hierarchy.

Specified by:
depth in interface GenericName
Since:
2.3

getParsedNames

public List<? extends LocalName> getParsedNames()
Returns the sequence of local names making this generic name. The length of this sequence is the depth. It does not include the scope.

Specified by:
getParsedNames in interface GenericName

push

public ScopedName push(GenericName scope)
Returns this name expanded with the specified scope. One may represent this operation as a concatenation of the specified name with this.

Specified by:
push in interface GenericName
Since:
2.3

toFullyQualifiedName

public GenericName toFullyQualifiedName()
Returns a view of this name as a fully-qualified name.

Specified by:
toFullyQualifiedName in interface GenericName
Since:
2.3

toInternationalString

public InternationalString toInternationalString()
Returns a local-dependent string representation of this generic name. This string is similar to the one returned by toString() except that each element has been localized in the specified locale. If no international string is available, then this method returns an implementation mapping to toString() for all locales.

Specified by:
toInternationalString in interface GenericName

toString

public String toString()
Returns a string representation of this generic name. This string representation is local-independent. It contains all elements listed by getParsedNames() separated by an arbitrary character (usually : or /).

Specified by:
toString in interface GenericName
Overrides:
toString in class DefaultReferenceIdentifier

compareTo

public int compareTo(GenericName object)
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<GenericName>
Parameters:
object - The object to compare with.
Returns:
-1 if this identifier precedes the given object, +1 if it follows it.

equals

public boolean equals(Object object)
Compares this identifier with the specified object for equality.

Overrides:
equals in class DefaultReferenceIdentifier
Parameters:
object - The object to compare with this name.
Returns:
true if the given object is equal to this name.


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.