org.geotools.referencing
Class AbstractIdentifiedObject

java.lang.Object
  extended byorg.geotools.referencing.wkt.Formattable
      extended byorg.geotools.referencing.AbstractIdentifiedObject
All Implemented Interfaces:
org.opengis.referencing.IdentifiedObject, java.io.Serializable
Direct Known Subclasses:
AbstractCoordinateOperation, AbstractCS, AbstractDatum, AbstractParameterDescriptor, AbstractReferenceSystem, DefaultCoordinateSystemAxis, DefaultEllipsoid, DefaultOperationMethod, DefaultPrimeMeridian, IdentifiedObject

public class AbstractIdentifiedObject
extends Formattable
implements org.opengis.referencing.IdentifiedObject, java.io.Serializable

A base class for metadata applicable to reference system objects. When AuthorityFactory is used to create an object, the authority and authority code values are set to the authority name of the factory object, and the authority code supplied by the client, respectively. When ObjectFactory creates an object, the name is set to the value supplied by the client and all of the other metadata items are left empty.

This class is conceptually abstract, even if it is technically possible to instantiate it. Typical applications should create instances of the most specific subclass with prefix instead. An exception to this rule may occurs when it is not possible to identify the exact type. For example it is not possible to infer the exact coordinate system from Well Known Text is some cases (e.g. in a element). In such exceptional situation, a plain AbstractCS object may be instantiated.

Since:
2.1
Version:
$Id$
Author:
Martin Desruisseaux
See Also:
Serialized Form

Field Summary
static java.lang.String ALIAS_PROPERTY
          Deprecated. Replaced by IdentifiedObject.ALIAS_KEY.
static org.opengis.util.GenericName[] EMPTY_ALIAS_ARRAY
          An empty array of alias.
static org.opengis.metadata.Identifier[] EMPTY_IDENTIFIER_ARRAY
          An empty array of identifiers.
static java.util.Comparator IDENTIFIER_COMPARATOR
          A comparator for sorting identified objects by identifiers.
static java.lang.String IDENTIFIERS_PROPERTY
          Deprecated. Replaced by IdentifiedObject.IDENTIFIERS_KEY.
static java.util.Comparator NAME_COMPARATOR
          A comparator for sorting identified objects by name.
static java.lang.String NAME_PROPERTY
          Deprecated. Replaced by IdentifiedObject.NAME_KEY.
static java.util.Comparator REMARKS_COMPARATOR
          A comparator for sorting identified objects by remarks.
static java.lang.String REMARKS_PROPERTY
          Deprecated. Replaced by IdentifiedObject.REMARKS_KEY.
 
Fields inherited from interface org.opengis.referencing.IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
 
Constructor Summary
  AbstractIdentifiedObject(org.opengis.referencing.IdentifiedObject object)
          Constructs a new identified object with the same values than the specified one.
  AbstractIdentifiedObject(java.util.Map properties)
          Constructs an object from a set of properties.
protected AbstractIdentifiedObject(java.util.Map properties, java.util.Map subProperties, java.lang.String[] localizables)
          Constructs an object from a set of properties and copy unrecognized properties in the specified map.
 
Method Summary
protected static java.util.Set asSet(java.lang.Object[] array)
          Returns the specified array as an immutable set, or if the array is empty or null.
protected static void ensureAngularUnit(javax.units.Unit unit)
          Makes sure that the specified unit is an angular one.
protected static void ensureLinearUnit(javax.units.Unit unit)
          Makes sure that the specified unit is a linear one.
protected static void ensureNonNull(java.lang.String name, java.lang.Object object)
          Makes sure that an argument is non-null.
protected static void ensureNonNull(java.lang.String name, java.lang.Object[] array, int index)
          Makes sure an array element is non-null.
protected static void ensureTimeUnit(javax.units.Unit unit)
          Makes sure that the specified unit is a temporal one.
 boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
          Compares this object with the specified object for equality.
protected static boolean equals(java.util.Collection collection1, java.util.Collection collection2, boolean compareMetadata)
          Compares two collectionss of OpenGIS's objects for equality.
protected static boolean equals(org.opengis.referencing.IdentifiedObject[] array1, org.opengis.referencing.IdentifiedObject[] array2, boolean compareMetadata)
          Compares two arrays of OpenGIS's objects for equality.
protected static boolean equals(org.opengis.referencing.IdentifiedObject object1, org.opengis.referencing.IdentifiedObject object2, boolean compareMetadata)
          Compares two OpenGIS's objects for equality.
 boolean equals(java.lang.Object object)
          Compares the specified object with this object for equality.
 java.util.Collection getAlias()
          An alternative name by which this object is identified.
 java.util.Set getIdentifiers()
          An identifier which references elsewhere the object's defining information.
 org.opengis.metadata.Identifier getName()
          The primary name by which this object is identified.
static java.util.Map getProperties(org.opengis.referencing.IdentifiedObject info)
          Returns the informations provided in the specified indentified object as a map of properties.
 org.opengis.util.InternationalString getRemarks()
          Comments on or information about this object, including data source information.
 int hashCode()
          Returns a hash value for this identified object.
static boolean nameMatches(org.opengis.referencing.IdentifiedObject object, java.lang.String name)
          Returns if either the primary name or at least one alias matches the specified string.
 boolean nameMatches(java.lang.String name)
          Returns if either the primary name or at least one alias matches the specified string.
 
Methods inherited from class org.geotools.referencing.wkt.Formattable
formatWKT, toString, toWKT, toWKT, toWKT
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.referencing.IdentifiedObject
toWKT
 

Field Detail

EMPTY_IDENTIFIER_ARRAY

public static final org.opengis.metadata.Identifier[] EMPTY_IDENTIFIER_ARRAY
An empty array of identifiers. This is usefull for fetching identifiers as an array, using the following idiom:
 getIdentifiers().toArray(EMPTY_IDENTIFIER_ARRAY);
 


EMPTY_ALIAS_ARRAY

public static final org.opengis.util.GenericName[] EMPTY_ALIAS_ARRAY
An empty array of alias. This is usefull for fetching alias as an array, using the following idiom:
 getAlias().toArray(EMPTY_ALIAS_ARRAY);
 


NAME_PROPERTY

public static final java.lang.String NAME_PROPERTY
Deprecated. Replaced by IdentifiedObject.NAME_KEY.

Key for the "name" property to be given to the constructor. This is used for setting the value to be returned by getName().

See Also:
Constant Field Values

ALIAS_PROPERTY

public static final java.lang.String ALIAS_PROPERTY
Deprecated. Replaced by IdentifiedObject.ALIAS_KEY.

Key for the "alias" property to be given to the constructor. This is used for setting the value to be returned by getAlias().

See Also:
Constant Field Values

IDENTIFIERS_PROPERTY

public static final java.lang.String IDENTIFIERS_PROPERTY
Deprecated. Replaced by IdentifiedObject.IDENTIFIERS_KEY.

Key for the "identifiers" property to be given to the constructor. This is used for setting the value to be returned by getIdentifiers().

See Also:
Constant Field Values

REMARKS_PROPERTY

public static final java.lang.String REMARKS_PROPERTY
Deprecated. Replaced by IdentifiedObject.REMARKS_KEY.

Key for the "remarks" property to be given to the constructor. This is used for setting the value to be returned by getRemarks().

See Also:
Constant Field Values

NAME_COMPARATOR

public static final java.util.Comparator NAME_COMPARATOR
A comparator for sorting identified objects by name.


IDENTIFIER_COMPARATOR

public static final java.util.Comparator IDENTIFIER_COMPARATOR
A comparator for sorting identified objects by identifiers.


REMARKS_COMPARATOR

public static final java.util.Comparator REMARKS_COMPARATOR
A comparator for sorting identified objects by remarks.

Constructor Detail

AbstractIdentifiedObject

public AbstractIdentifiedObject(org.opengis.referencing.IdentifiedObject object)
Constructs a new identified object with the same values than the specified one.


AbstractIdentifiedObject

public AbstractIdentifiedObject(java.util.Map properties)
                         throws java.lang.IllegalArgumentException
Constructs an object from a set of properties. Keys are strings from the table below. Key are case-insensitive, and leading and trailing spaces are ignored. The map given in argument shall contains at least a "name" property. Other properties listed in the table below are optional.

Property name Value type Value given to
 "name"   String or Identifier   getName()
 "alias"   String, String[], GenericName or GenericName[]   getAlias()
 "authority"   String or Citation   NamedIdentifier.getAuthority() on the name
 "version"   String   NamedIdentifier.getVersion() on the name
 "identifiers"   Identifier or Identifier[]   getIdentifiers()
 "remarks"   String or InternationalString   getRemarks()

Additionally, all localizable attributes like "remarks" may have a language and country code suffix. For example the "remarks_fr" property stands for remarks in French and the "remarks_fr_CA" property stands for remarks in French Canadian.

Note that the "authority" and "version" properties are ignored if the "name" property is already a Citation object instead of a String.

Throws:
org.opengis.parameter.InvalidParameterValueException - if a property has an invalid value.
java.lang.IllegalArgumentException - if a property is invalid for some other reason.

AbstractIdentifiedObject

protected AbstractIdentifiedObject(java.util.Map properties,
                                   java.util.Map subProperties,
                                   java.lang.String[] localizables)
                            throws java.lang.IllegalArgumentException
Constructs an object from a set of properties and copy unrecognized properties in the specified map. The argument is treated as in the one argument constructor. All properties unknow to this constructor are copied in the map, after their key has been normalized (usually lower case, leading and trailing space removed).

If is non-null, then all keys listed in this argument are treated as localizable one (i.e. may have a suffix like "_fr", "_de", etc.). Localizable properties are stored in the map as InternationalString objects.

Parameters:
properties - Set of properties. Should contains at least "name".
subProperties - The map in which to copy unrecognized properties.
localizables - Optional list of localized properties.
Throws:
org.opengis.parameter.InvalidParameterValueException - if a property has an invalid value.
java.lang.IllegalArgumentException - if a property is invalid for some other reason.
Method Detail

getName

public org.opengis.metadata.Identifier getName()
The primary name by which this object is identified.

Specified by:
getName in interface org.opengis.referencing.IdentifiedObject

getAlias

public java.util.Collection getAlias()
An alternative name by which this object is identified.

Specified by:
getAlias in interface org.opengis.referencing.IdentifiedObject
Returns:
The aliases, or an empty array if there is none.

getIdentifiers

public java.util.Set getIdentifiers()
An identifier which references elsewhere the object's defining information. Alternatively an identifier by which this object can be referenced.

Specified by:
getIdentifiers in interface org.opengis.referencing.IdentifiedObject
Returns:
This object identifiers, or an empty array if there is none.

getRemarks

public org.opengis.util.InternationalString getRemarks()
Comments on or information about this object, including data source information.

Specified by:
getRemarks in interface org.opengis.referencing.IdentifiedObject

getProperties

public static java.util.Map getProperties(org.opengis.referencing.IdentifiedObject info)
Returns the informations provided in the specified indentified object as a map of properties. The returned map contains key such as IdentifiedObject.NAME_KEY, and values from methods such as getName().

Parameters:
info - The identified object to view as a properties map.
Returns:
An view of the identified object as an immutable map.

hashCode

public int hashCode()
Returns a hash value for this identified object. Name, identifiers and remarks are not taken in account. In other words, two identified objects will return the same hash value if they are equal in the sense of equals(AbstractIdentifiedObject, false).

Returns:
The hash code value. This value doesn't need to be the same in past or future versions of this class.

nameMatches

public boolean nameMatches(java.lang.String name)
Returns if either the primary name or at least one alias matches the specified string. This method performs the search in the following order:

Parameters:
name - The name to compare.
Returns:
if the primary name of at least one alias matches the specified .

nameMatches

public static boolean nameMatches(org.opengis.referencing.IdentifiedObject object,
                                  java.lang.String name)
Returns if either the primary name or at least one alias matches the specified string. This method performs the same check than the non-static method on arbitrary object implementing the OpenGIS interface.

Parameters:
object - The object to check.
name - The name.
Returns:
if the primary name of at least one alias matches the specified .

equals

public final boolean equals(java.lang.Object object)
Compares the specified object with this object for equality.

Parameters:
object - The other object (may be ).
Returns:
if both objects are equal.

equals

public boolean equals(AbstractIdentifiedObject object,
                      boolean compareMetadata)
Compares this object with the specified object for equality. If is , then all available properties are compared including name, remarks, identifiers code, etc. If is , then this method compare only the properties needed for computing transformations. In other words, returns only if the transformation from to is the identity transform, no matter what getName() saids.

Some subclasses (especially AbstractDatum and AbstractParameterDescriptor) will test for the name, since objects with different name have completly different meaning. For example nothing differentiate the "semi_major" and "semi_minor" parameters except the name. The name comparaison may be loose however, i.e. we may accept a name matching an alias.

Parameters:
object - The object to compare to .
compareMetadata - for performing a strict comparaison, or for comparing only properties relevant to transformations.
Returns:
if both objects are equal.

equals

protected static boolean equals(org.opengis.referencing.IdentifiedObject object1,
                                org.opengis.referencing.IdentifiedObject object2,
                                boolean compareMetadata)
Compares two OpenGIS's objects for equality. This convenience method is provided for implementation of in subclasses.

Parameters:
object1 - The first object to compare (may be ).
object2 - The second object to compare (may be ).
compareMetadata - for performing a strict comparaison, or for comparing only properties relevant to transformations.
Returns:
if both objects are equal.

equals

protected static boolean equals(org.opengis.referencing.IdentifiedObject[] array1,
                                org.opengis.referencing.IdentifiedObject[] array2,
                                boolean compareMetadata)
Compares two arrays of OpenGIS's objects for equality. This convenience method is provided for implementation of method in subclasses.

Parameters:
array1 - The first array to compare (may be ).
array2 - The second array to compare (may be ).
compareMetadata - for performing a strict comparaison, or for comparing only properties relevant to transformations.
Returns:
if both arrays are equal.

equals

protected static boolean equals(java.util.Collection collection1,
                                java.util.Collection collection2,
                                boolean compareMetadata)
Compares two collectionss of OpenGIS's objects for equality. The comparaison take order in account, which make it more appropriate for List or LinkedHashSet comparaisons. This convenience method is provided for implementation of method in subclasses.

Parameters:
collection1 - The first collection to compare (may be ).
collection2 - The second collection to compare (may be ).
compareMetadata - for performing a strict comparaison, or for comparing only properties relevant to transformations.
Returns:
if both collections are equal.

asSet

protected static java.util.Set asSet(java.lang.Object[] array)
Returns the specified array as an immutable set, or if the array is empty or null. This is a convenience method for sub-classes constructors.

Parameters:
array - The array to copy in a set. May be .
Returns:
A set containing the array elements, or if none or empty.

ensureNonNull

protected static void ensureNonNull(java.lang.String name,
                                    java.lang.Object object)
                             throws java.lang.IllegalArgumentException
Makes sure that an argument is non-null. This is a convenience method for subclass constructors.

Parameters:
name - Argument name.
object - User argument.
Throws:
org.opengis.parameter.InvalidParameterValueException - if is null.
java.lang.IllegalArgumentException

ensureNonNull

protected static void ensureNonNull(java.lang.String name,
                                    java.lang.Object[] array,
                                    int index)
                             throws java.lang.IllegalArgumentException
Makes sure an array element is non-null. This is a convenience method for subclass constructors.

Parameters:
name - Argument name.
array - User argument.
index - Index of the element to check.
Throws:
org.opengis.parameter.InvalidParameterValueException - if is null.
java.lang.IllegalArgumentException

ensureTimeUnit

protected static void ensureTimeUnit(javax.units.Unit unit)
                              throws java.lang.IllegalArgumentException
Makes sure that the specified unit is a temporal one. This is a convenience method for subclass constructors.

Parameters:
unit - Unit to check.
Throws:
java.lang.IllegalArgumentException - if is not a temporal unit.

ensureLinearUnit

protected static void ensureLinearUnit(javax.units.Unit unit)
                                throws java.lang.IllegalArgumentException
Makes sure that the specified unit is a linear one. This is a convenience method for subclass constructors.

Parameters:
unit - Unit to check.
Throws:
java.lang.IllegalArgumentException - if is not a linear unit.

ensureAngularUnit

protected static void ensureAngularUnit(javax.units.Unit unit)
                                 throws java.lang.IllegalArgumentException
Makes sure that the specified unit is an angular one. This is a convenience method for subclass constructors.

Parameters:
unit - Unit to check.
Throws:
java.lang.IllegalArgumentException - if is not an angular unit.


Copyright © GeoTools. All Rights Reserved.