T - the type of objects to be included in this set.public class IdentifiedObjectSet<T extends IdentifiedObject> extends AbstractSet<T> implements CheckedContainer<T>, Localized
IdentifiedObject instances created from their authority codes only when first needed.
This set delegates IdentifiedObject creation to the most appropriate createFoo(String) method
of the AuthorityFactory given at construction time.
Elements can be added to this collection with calls to addAuthorityCode(String) for deferred
object creation, or to add(IdentifiedObject) for objects
that are already instantiated. This collection can not contain two IdentifiedObject instances
having the same identifier. However the identifiers used by this class can be controlled by overriding
getAuthorityCode(IdentifiedObject).
Iterations over elements in this collection preserve insertion order.
IdentifiedObjectSet can be used as the set returned by implementations of the
GeodeticAuthorityFactory.createFromCoordinateReferenceSystemCodes(String, String) method.
Deferred creation can have great performance impact since some set may contain as much as 40 entries
(e.g. transformations from "ED50" (EPSG:4230) to "WGS 84" (EPSG:4326))
while some users only want to look for the first entry.
NoSuchIdentifierException), the exception is logged at Level.WARNING and the iteration continue.
If the operation creation failed for any other kind of reason (FactoryException), then the exception is
re-thrown as an unchecked BackingStoreException. This default behavior can be changed by overriding
the isRecoverableFailure(FactoryException) method.
IdentifiedObjectSet instances.Defined in the sis-referencing module
| Modifier and Type | Field and Description |
|---|---|
protected AuthorityFactory |
factory
The factory to use for creating
IdentifiedObjects when first needed. |
| Constructor and Description |
|---|
IdentifiedObjectSet(AuthorityFactory factory,
Class<T> type)
Creates an initially empty set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T object)
Ensures that this collection contains the specified object.
|
void |
addAuthorityCode(String code)
Ensures that this collection contains an object for the specified authority code.
|
void |
clear()
Removes all of the elements from this collection.
|
boolean |
contains(Object object)
Returns
true if this collection contains the specified IdentifiedObject. |
protected T |
createObject(String code)
Creates an object for the specified authority code.
|
protected String |
getAuthorityCode(T object)
Returns the identifier for the specified object.
|
String[] |
getAuthorityCodes()
Returns the authority codes of all
IdentifiedObjects contained in this collection, in insertion order. |
Class<T> |
getElementType()
Returns the type of
IdentifiedObject included in this set. |
Locale |
getLocale()
Returns the locale to use for error messages and warnings.
|
protected boolean |
isRecoverableFailure(FactoryException exception)
Returns
true if the specified exception should be handled as a recoverable failure. |
Iterator<T> |
iterator()
Returns an iterator over the objects in this set.
|
boolean |
remove(Object object)
Removes the specified
IdentifiedObject from this collection, if it is present. |
boolean |
removeAll(Collection<?> collection)
Removes from this collection all of its elements that are contained in the specified collection.
|
void |
resolve(int n)
Ensures that the n first objects in this set are created.
|
void |
setAuthorityCodes(String... codes)
Sets the content of this collection to the object identified by the given codes.
|
int |
size()
Returns the number of objects available in this set.
|
equals, hashCodeaddAll, containsAll, isEmpty, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streamprotected final AuthorityFactory factory
IdentifiedObjects when first needed.
This is the authority factory given at construction time.public IdentifiedObjectSet(AuthorityFactory factory, Class<T> type)
addAuthorityCode(String) for deferred IdentifiedObject creation,
or to add(IdentifiedObject) for already instantiated objects.factory - the factory to use for deferred IdentifiedObject instances creation.type - the type of objects included in this set.public Locale getLocale()
factory locale, if any.getLocale in interface Localizednull if not explicitly defined.public Class<T> getElementType()
IdentifiedObject included in this set.getElementType in interface CheckedContainer<T extends IdentifiedObject>IdentifiedObject included in this set.public void clear()
clear in interface Collection<T extends IdentifiedObject>clear in interface Set<T extends IdentifiedObject>clear in class AbstractCollection<T extends IdentifiedObject>public int size()
IdentifiedObjects failed.size in interface Collection<T extends IdentifiedObject>size in interface Set<T extends IdentifiedObject>size in class AbstractCollection<T extends IdentifiedObject>public String[] getAuthorityCodes()
IdentifiedObjects contained in this collection, in insertion order.
This method does not trig the creation of any object.public void setAuthorityCodes(String... codes)
IdentifiedObject
instance if it was already created. Otherwise objects will be created
only when first needed.
getAuthorityCodes() for altering the iteration order
on the basis of authority codes. If the specified codes sequence contains the same elements than
the ones in the array returned by getAuthorityCodes() but in a different order, then this method
just sets the new ordering.codes - the authority codes of identified objects to store in this set.addAuthorityCode(String)public void addAuthorityCode(String code)
IdentifiedObject for the given code only when first needed.
Otherwise this collection is unchanged.code - the code authority code of the IdentifiedObject to include in this set.public boolean add(T object)
add in interface Collection<T extends IdentifiedObject>add in interface Set<T extends IdentifiedObject>add in class AbstractCollection<T extends IdentifiedObject>object - the object to add to the set.true if this set changed as a result of this call.getAuthorityCode(IdentifiedObject)public boolean contains(Object object)
true if this collection contains the specified IdentifiedObject.contains in interface Collection<T extends IdentifiedObject>contains in interface Set<T extends IdentifiedObject>contains in class AbstractCollection<T extends IdentifiedObject>object - the IdentifiedObject to test for presence in this set.true if the given object is presents in this set.public boolean remove(Object object)
IdentifiedObject from this collection, if it is present.remove in interface Collection<T extends IdentifiedObject>remove in interface Set<T extends IdentifiedObject>remove in class AbstractCollection<T extends IdentifiedObject>object - the IdentifiedObject to remove from this set.true if this set changed as a result of this call.public boolean removeAll(Collection<?> collection)
removeAll in interface Collection<T extends IdentifiedObject>removeAll in interface Set<T extends IdentifiedObject>removeAll in class AbstractSet<T extends IdentifiedObject>collection - the IdentifiedObjects to remove from this set.true if this set changed as a result of this call.public Iterator<T> iterator() throws BackingStoreException
FactoryException other than NoSuchIdentifierException, then the exception
will be re-thrown as an unchecked BackingStoreException.
This iterator is not thread safe – iteration should be done in a single thread.
However the iterator is robust to concurrent changes in IdentifiedObjectSet during iteration.
iterator in interface Iterable<T extends IdentifiedObject>iterator in interface Collection<T extends IdentifiedObject>iterator in interface Set<T extends IdentifiedObject>iterator in class AbstractCollection<T extends IdentifiedObject>IdentifiedObject instances in this set, in insertion order.BackingStoreException - if an error occurred while creating the iterator.public void resolve(int n)
throws FactoryException
FactoryException (except the ones accepted as recoverable failures)
are thrown as if they were never wrapped into BackingStoreException.n - the number of object to resolve. If this number is equals or greater than size(), then
this method ensures that all IdentifiedObject instances in this collection are created.FactoryException - if an object creation failed.protected String getAuthorityCode(T object)
factory.getAuthority().object - the object for which to get the authority code.protected T createObject(String code) throws FactoryException
code - the code for which to create the identified object.FactoryException - if the object creation failed.protected boolean isRecoverableFailure(FactoryException exception)
true if the specified exception should be handled as a recoverable failure.
This method is invoked during the iteration process if the factory failed to create some objects.
If this method returns true for the given exception, then the exception will be logged
at Level.WARNING. If this method returns false, then the exception will be re-thrown
as a BackingStoreException.
The default implementation applies the following rules:
NoSuchAuthorityCodeException, returns false since failure to find a code declared
in the collection would be an inconsistency. Note that this exception is a subtype of
NoSuchIdentifierException, so it must be tested before the last case below.NoSuchIdentifierException, returns true since this exception is caused by an attempt to
create a parameterized transform for an unimplemented operation.MissingFactoryResourceException, returns true.false.exception - the exception that occurred while creating an object.true if the given exception should be considered recoverable,
or false if it should be considered fatal.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.