|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractCollection<E>
AbstractSet<T>
IdentifiedObjectSet<T>
T - The type of objects to be included in this set.@NotThreadSafe public class IdentifiedObjectSet<T extends IdentifiedObject>
A lazy set of identified objects. This set creates
IdentifiedObjects from authority codes only when first needed. This class
is typically used as the set returned by implementations of the
CoordinateOperationAuthorityFactory.createFromCoordinateReferenceSystemCodes(String, String)
method. Deferred creation in this case may have great performance impact since a set can contains
about 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 (e.g. the default
AuthorityBackedFactory implementation).
Note:
This is mostly a helper class for implementors, especially the
org.geotoolkit.referencing.factory.epsg package.
This class is not expected to be useful to users.
Exception handling
If the underlying factory failed to creates an object because of an unsupported
operation method (NoSuchIdentifierException), the exception is logged with
the FINE level (because this is a recoverable failure) and
the iteration continue. If the operation creation failed for any other kind of
reason (FactoryException), then the exception is rethrown as an unchecked
BackingStoreException. This default behavior can be changed if a subclass
overrides the isRecoverableFailure method.
Serialization
Serialization of this class forces the immediate creation of all
identified objects not yet created.
The serialized set is disconnected from the underlying factory.
| referencing/geotk-referencing (download) | View source code for this class |
| Field Summary | |
|---|---|
protected Class<T> |
type
The type of objects included in this set. |
| Constructor Summary | |
|---|---|
IdentifiedObjectSet(AuthorityFactory factory,
Class<T> type)
Creates an initially empty set. |
|
| Method Summary | |
|---|---|
boolean |
add(T object)
Ensures that this collection contains the specified object. |
boolean |
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 object. |
protected T |
createObject(String code)
Creates an object for the specified authority code. |
protected String |
getAuthorityCode(T object)
Returns the code to uses as a key for the specified object. |
String[] |
getAuthorityCodes()
Returns the authority code of all objects in this set. |
protected AuthorityFactory |
getAuthorityFactory()
Returns the authority factory used by the createObject method. |
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 a single instance of the specified element 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 set as an array of authority codes. |
int |
size()
Returns the number of objects available in this set. |
protected Object |
writeReplace()
Returns a serializable copy of this set. |
| Methods inherited from class AbstractSet |
|---|
equals, hashCode |
| Methods inherited from class AbstractCollection |
|---|
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Set |
|---|
addAll, containsAll, isEmpty, retainAll, toArray, toArray |
| Field Detail |
|---|
protected final Class<T extends IdentifiedObject> type
| Constructor Detail |
|---|
public IdentifiedObjectSet(AuthorityFactory factory,
Class<T> type)
factory - The factory to use for deferred IdentifiedObjects creations.type - The type of objects included in this set.| Method Detail |
|---|
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()
size in interface Collection<T extends IdentifiedObject>size in interface Set<T extends IdentifiedObject>size in class AbstractCollection<T extends IdentifiedObject>public boolean addAuthorityCode(String code)
code - The code authority code that shall be included in this set.
true if this set changed as a result of this call.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.public boolean contains(Object object)
true if this collection contains the specified object.
contains in interface Collection<T extends IdentifiedObject>contains in interface Set<T extends IdentifiedObject>contains in class AbstractCollection<T extends IdentifiedObject>object - The object to test for presence in this set.
true if the given object is presents in this set.public boolean remove(Object object)
remove in interface Collection<T extends IdentifiedObject>remove in interface Set<T extends IdentifiedObject>remove in class AbstractCollection<T extends IdentifiedObject>object - The object 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 objects 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 rethrown as an unchecked BackingStoreException.
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>BackingStoreException - if the underlying factory failed to creates the
first coordinate operation in the set.
public void resolve(int n)
throws FactoryException
addAuthorityCode(java.lang.String) in order to make sure
that the underlying factory is really capable to
create at least one object. 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 the
set's size, then the creation of all objects is guaranteed
successful.
FactoryException - if an object creation failed.public String[] getAuthorityCodes()
This method is typically used together with setAuthorityCodes(java.lang.String[]) for altering the
iteration order on the basis of authority codes.
public void setAuthorityCodes(String[] codes)
IdentifiedObjectSet implementation.
This method is typically used together with getAuthorityCodes() for altering the
iteration order on the basis of authority codes. If the specified codes array
contains the same elements than getAuthorityCodes() in a different order, then
this method just set the new ordering.
codes - The authority codes of identified objects to store in this set.addAuthorityCode(java.lang.String)protected String getAuthorityCode(T object)
object - The object for which to get the authority code.
protected AuthorityFactory getAuthorityFactory()
createObject method.
This is the factory given at construction time.
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 in the Geotk factory logger
with the FINE level. If this method returns false, then the
exception will be retrown as a BackingStoreException.
The default implementation returns true if the given exception is one of the
following types:
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.
protected Object writeReplace()
throws ObjectStreamException
ObjectStreamException - If this set can not be serialized.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||