|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFormattable
AbstractIdentifiedObject
public class AbstractIdentifiedObject
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
Default
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 LOCAL_CS
element). In such exceptional
situation, a plain AbstractCS
object may be instantiated.
modules/library/referencing (gt-referencing.jar)
Field Summary | |
---|---|
static GenericName[] |
EMPTY_ALIAS_ARRAY
An empty array of alias. |
static ReferenceIdentifier[] |
EMPTY_IDENTIFIER_ARRAY
An empty array of identifiers. |
static Comparator<IdentifiedObject> |
IDENTIFIER_COMPARATOR
A comparator for sorting identified objects by identifiers. |
static Comparator<IdentifiedObject> |
NAME_COMPARATOR
A comparator for sorting identified objects by name. |
static Comparator<IdentifiedObject> |
REMARKS_COMPARATOR
A comparator for sorting identified objects by remarks. |
Fields inherited from class Formattable |
---|
SINGLE_LINE |
Fields inherited from interface IdentifiedObject |
---|
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY |
Constructor Summary | |
---|---|
|
AbstractIdentifiedObject(IdentifiedObject object)
Constructs a new identified object with the same values than the specified one. |
|
AbstractIdentifiedObject(Map<String,?> properties)
Constructs an object from a set of properties. |
protected |
AbstractIdentifiedObject(Map<String,?> properties,
Map<String,Object> subProperties,
String[] localizables)
Constructs an object from a set of properties and copy unrecognized properties in the specified map. |
Method Summary | ||
---|---|---|
protected static
|
asSet(E[] array)
Returns the specified array as an immutable set, or null if the
array is empty or null. |
|
protected static void |
ensureAngularUnit(Unit<?> unit)
Makes sure that the specified unit is an angular one. |
|
protected static void |
ensureLinearUnit(Unit<?> unit)
Makes sure that the specified unit is a linear one. |
|
protected static void |
ensureNonNull(String name,
Object object)
Makes sure that an argument is non-null. |
|
protected static void |
ensureNonNull(String name,
Object[] array,
int index)
Makes sure an array element is non-null. |
|
protected static void |
ensureTimeUnit(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(Collection<? extends IdentifiedObject> collection1,
Collection<? extends IdentifiedObject> collection2,
boolean compareMetadata)
Compares two collectionss of OpenGIS's IdentifiedObject objects for equality. |
|
protected static boolean |
equals(IdentifiedObject[] array1,
IdentifiedObject[] array2,
boolean compareMetadata)
Compares two arrays of OpenGIS's IdentifiedObject objects for equality. |
|
protected static boolean |
equals(IdentifiedObject object1,
IdentifiedObject object2,
boolean compareMetadata)
Compares two OpenGIS's IdentifiedObject objects for equality. |
|
boolean |
equals(Object object)
Compares the specified object with this object for equality. |
|
Collection<GenericName> |
getAlias()
An alternative name by which this object is identified. |
|
ReferenceIdentifier |
getIdentifier(Citation authority)
Returns an identifier according the given authority. |
|
static ReferenceIdentifier |
getIdentifier(IdentifiedObject info,
Citation authority)
Returns an identifier according the given authority. |
|
Set<ReferenceIdentifier> |
getIdentifiers()
An identifier which references elsewhere the object's defining information. |
|
ReferenceIdentifier |
getName()
The primary name by which this object is identified. |
|
String |
getName(Citation authority)
Returns this object's name according the given authority. |
|
static String |
getName(IdentifiedObject info,
Citation authority)
Returns an object's name according the given authority. |
|
static Map<String,?> |
getProperties(IdentifiedObject info)
Returns the informations provided in the specified indentified object as a map of properties. |
|
static Map<String,Object> |
getProperties(IdentifiedObject info,
Citation authority)
Returns the properties to be given to an identified object derived from the specified one. |
|
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(IdentifiedObject o1,
IdentifiedObject o2)
Returns true if the primary name of an object matches
the primary name of one alias of the other object. |
|
static boolean |
nameMatches(IdentifiedObject object,
String name)
Returns true if either the primary name or at least
one alias matches the specified string. |
|
boolean |
nameMatches(String name)
Returns true if either the primary name or at least
one alias matches the specified string. |
Methods inherited from class Formattable |
---|
cleanupThreadLocals, formatWKT, toString, toWKT, toWKT, toWKT |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface IdentifiedObject |
---|
toWKT |
Field Detail |
---|
public static final ReferenceIdentifier[] EMPTY_IDENTIFIER_ARRAY
getIdentifiers().toArray(EMPTY_IDENTIFIER_ARRAY);
public static final GenericName[] EMPTY_ALIAS_ARRAY
getAlias().toArray(EMPTY_ALIAS_ARRAY);
public static final Comparator<IdentifiedObject> NAME_COMPARATOR
public static final Comparator<IdentifiedObject> IDENTIFIER_COMPARATOR
public static final Comparator<IdentifiedObject> REMARKS_COMPARATOR
Constructor Detail |
---|
public AbstractIdentifiedObject(IdentifiedObject object)
object
- The object to copy.public AbstractIdentifiedObject(Map<String,?> properties) throws IllegalArgumentException
"name"
property. Other properties listed
in the table below are optional.
Property name | Value type | Value given to |
---|---|---|
"name" | String or ReferenceIdentifier |
getName() |
"alias" | String , String[] ,
GenericName or GenericName[] |
getAlias() |
"authority" | String or Citation |
Identifier.getAuthority() on the name |
"codespace" | String |
ReferenceIdentifier.getCodeSpace() on the name |
"version" | String |
ReferenceIdentifier.getVersion() on the name |
"identifiers" | ReferenceIdentifier or ReferenceIdentifier[] |
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
.
properties
- The properties to be given to this identified object.
InvalidParameterValueException
- if a property has an invalid value.
IllegalArgumentException
- if a property is invalid for some other reason.protected AbstractIdentifiedObject(Map<String,?> properties, Map<String,Object> subProperties, String[] localizables) throws IllegalArgumentException
properties
argument is treated as in the one argument constructor. All
properties unknow to this AbstractIdentifiedObject
constructor are copied
in the subProperties
map, after their key has been normalized (usually
lower case, leading and trailing space removed).
If localizables
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 subProperties
map as InternationalString
objects.
properties
- Set of properties. Should contains at least "name"
.subProperties
- The map in which to copy unrecognized properties.localizables
- Optional list of localized properties.
InvalidParameterValueException
- if a property has an invalid value.
IllegalArgumentException
- if a property is invalid for some other reason.Method Detail |
---|
public ReferenceIdentifier getName()
getName
in interface IdentifiedObject
getName(Citation)
public Collection<GenericName> getAlias()
getAlias
in interface IdentifiedObject
getName(Citation)
public Set<ReferenceIdentifier> getIdentifiers()
getIdentifiers
in interface IdentifiedObject
getIdentifier(Citation)
public InternationalString getRemarks()
getRemarks
in interface IdentifiedObject
public static Map<String,?> getProperties(IdentifiedObject info)
NAME_KEY
, and
values from methods such as getName()
.
info
- The identified object to view as a properties map.
public static Map<String,Object> getProperties(IdentifiedObject info, Citation authority)
getProperties(info)
), except for
the following:
This method returns a mutable map. Consequently, callers can add their own identifiers directly to this map if they wish.
info
- The identified object to view as a properties map.authority
- The new authority for the object to be created, or null
if it
is not going to have any declared authority.
public ReferenceIdentifier getIdentifier(Citation authority)
authority
- The authority for the identifier to return, or null
for
the first identifier regarless its authority.
null
if no identifier matching the specified
authority was found.public static ReferenceIdentifier getIdentifier(IdentifiedObject info, Citation authority)
getIdentifier(Citation)
on arbitrary implementations of GeoAPI interface.
info
- The object to get the identifier from.authority
- The authority for the identifier to return, or null
for
the first identifier regarless its authority.
null
if no identifier matching the specified
authority was found.public String getName(Citation authority)
If the name or alias implements the ReferenceIdentifier
interface,
then this method compares the identifier authority against the specified citation using the
identifierMatches
method. If a matching is found, then this method returns the
identifier code of this object.
Otherwise, if the alias implements the GenericName
interface, then this
method compares the name scope against the specified
citation using the identifierMatches method. If a matching is found, then this method returns the
local name of this object.
ReferenceIdentifier
and GenericName
interfaces (for example NamedIdentifier
). In such cases, the identifier view has
precedence.
authority
- The authority for the name to return.
null
if
no name matching the specified authority was found.getName()
,
getAlias()
public static String getName(IdentifiedObject info, Citation authority)
getName(Citation)
on arbitrary implementations of GeoAPI interface.
info
- The object to get the name from.authority
- The authority for the name to return.
null
if
no name matching the specified authority was found.public boolean nameMatches(String name)
true
if either the primary name or at least
one alias matches the specified string. This method performs
the search in the following order, regardless of any authority:
name
- The name to compare.
true
if the primary name of at least one alias
matches the specified name
.public static boolean nameMatches(IdentifiedObject object, String name)
true
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 GeoAPI interface.
object
- The object to check.name
- The name.
true
if the primary name of at least one alias
matches the specified name
.public static boolean nameMatches(IdentifiedObject o1, IdentifiedObject o2)
true
if the primary name of an object matches
the primary name of one alias of the other object.
o1
- The first object to compare by name.o2
- The second object to compare by name.
true
if both objects have a common name.public final boolean equals(Object object)
equals
in class Object
object
- The other object (may be null
).
true
if both objects are equal.public boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
compareMetadata
is true
, then all available properties are
compared including name, remarks,
identifiers code, etc.
If compareMetadata
is false
, then this method compare
only the properties needed for computing transformations. In other words,
sourceCS.equals(targetCS, false)
returns true
only if
the transformation from sourceCS
to targetCS
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.
object
- The object to compare to this
.compareMetadata
- true
for performing a strict comparaison, or
false
for comparing only properties relevant to transformations.
true
if both objects are equal.protected static boolean equals(IdentifiedObject object1, IdentifiedObject object2, boolean compareMetadata)
IdentifiedObject
objects for equality. This convenience
method is provided for implementation of equals
in subclasses.
object1
- The first object to compare (may be null
).object2
- The second object to compare (may be null
).compareMetadata
- true
for performing a strict comparaison, or
false
for comparing only properties relevant to transformations.
true
if both objects are equal.protected static boolean equals(IdentifiedObject[] array1, IdentifiedObject[] array2, boolean compareMetadata)
IdentifiedObject
objects for equality. This
convenience method is provided for implementation of equals
method in subclasses.
array1
- The first array to compare (may be null
).array2
- The second array to compare (may be null
).compareMetadata
- true
for performing a strict comparaison, or
false
for comparing only properties relevant to transformations.
true
if both arrays are equal.protected static boolean equals(Collection<? extends IdentifiedObject> collection1, Collection<? extends IdentifiedObject> collection2, boolean compareMetadata)
IdentifiedObject
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 equals
method in subclasses.
collection1
- The first collection to compare (may be null
).collection2
- The second collection to compare (may be null
).compareMetadata
- true
for performing a strict comparaison, or
false
for comparing only properties relevant to transformations.
true
if both collections are equal.public int hashCode()
equals(AbstractIdentifiedObject,
false)
.
hashCode
in class Object
protected static <E> Set<E> asSet(E[] array)
null
if the
array is empty or null. This is a convenience method for sub-classes
constructors.
E
- The type of array elements.array
- The array to copy in a set. May be null
.
null
if none or empty.protected static void ensureNonNull(String name, Object object) throws InvalidParameterValueException
name
- Argument name.object
- User argument.
InvalidParameterValueException
- if object
is null.protected static void ensureNonNull(String name, Object[] array, int index) throws InvalidParameterValueException
name
- Argument name.array
- User argument.index
- Index of the element to check.
InvalidParameterValueException
- if array[i]
is null.protected static void ensureTimeUnit(Unit<?> unit) throws IllegalArgumentException
unit
- Unit to check.
IllegalArgumentException
- if unit
is not a temporal unit.protected static void ensureLinearUnit(Unit<?> unit) throws IllegalArgumentException
unit
- Unit to check.
IllegalArgumentException
- if unit
is not a linear unit.protected static void ensureAngularUnit(Unit<?> unit) throws IllegalArgumentException
unit
- Unit to check.
IllegalArgumentException
- if unit
is not an angular unit.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |