|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectIdentifiedObjectFinder
@NotThreadSafe public class IdentifiedObjectFinder
Lookups an object from an authority factory which is
equal, ignoring metadata, to the specified
object. The main purpose of this class is to get a fully identified object from an incomplete one, for example from an object without
identifiers ("AUTHORITY[...]"
element in Well Known Text terminology).
The steps for using IdentifiedObjectFinder are:
AbstractAuthorityFactory.getIdentifiedObjectFinder(Class).find(IdentifiedObject) or
findIdentifier(IdentifiedObject) methods.IdentifiedObjectFinder instance for consecutive searches.
Thread safety
IdentifiedObjectFinder are not guaranteed to be thread-safe
even if the underlying factory is thread-safe. If concurrent searches are desired,
then a new instance should be created for each thread.
AbstractAuthorityFactory.getIdentifiedObjectFinder(Class),
CRS#lookupIdentifier(IdentifiedObject, boolean)
| referencing/geotk-referencing (download) | View source code for this class |
| Constructor Summary | |
|---|---|
protected |
IdentifiedObjectFinder(AuthorityFactory factory,
Class<? extends IdentifiedObject> type)
Creates a finder using the specified factory. |
| Method Summary | |
|---|---|
protected IdentifiedObject |
create(String code,
int attempt)
Creates an object for the given code. |
IdentifiedObject |
find(IdentifiedObject object)
Lookups an object which is equal, ignoring metadata, to the specified object. |
protected IdentifiedObject |
findFromParent(IdentifiedObject object,
Class<? extends IdentifiedObject> type)
Lookups an object from the parent finder, of from this finder if there is no parent. |
String |
findIdentifier(IdentifiedObject object)
Returns the identifier of the specified object, or null if none. |
Citation |
getAuthority()
Returns the authority of the factory examined by this finder. |
protected Set<String> |
getCodeCandidates(IdentifiedObject object)
Returns a set of authority codes that may identify the same object than the specified one. |
ComparisonMode |
getComparisonMode()
Returns the criterion used for determining if a candidate found by this IdentifiedObjectFinder shall be considered equals to the requested object. |
boolean |
isFullScanAllowed()
If true, an exhaustive full scan against all registered objects will be performed
(may be slow). |
void |
setComparisonMode(ComparisonMode mode)
Sets the criterion used for determining if a candidate found by this IdentifiedObjectFinder shall be considered equals to the requested object. |
void |
setFullScanAllowed(boolean fullScan)
Sets whatever an exhaustive scan against all registered objects is allowed. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected IdentifiedObjectFinder(AuthorityFactory factory,
Class<? extends IdentifiedObject> type)
AbstractAuthorityFactory.getIdentifiedObjectFinder(Class) instead.
factory - The factory to scan for the identified objects.type - The type of objects to lookup.AbstractAuthorityFactory.getIdentifiedObjectFinder(Class)| Method Detail |
|---|
public Citation getAuthority()
throws FactoryException
FactoryException - If an error occurred while fetching the authority.public ComparisonMode getComparisonMode()
IdentifiedObjectFinder shall be considered equals to the requested object.
The default value is ComparisonMode.IGNORE_METADATA.
public void setComparisonMode(ComparisonMode mode)
IdentifiedObjectFinder shall be considered equals to the requested object.
mode - The criterion to use for comparing objects.public boolean isFullScanAllowed()
true, an exhaustive full scan against all registered objects will be performed
(may be slow). Otherwise only a fast lookup based on embedded identifiers and names will
be performed. The default value is true.
true if exhaustive scans are allowed, or false for faster
but less complete searches.public void setFullScanAllowed(boolean fullScan)
true.
fullScan - true for allowing exhaustive scans, or false
for faster but less complete searches.
public IdentifiedObject find(IdentifiedObject object)
throws FactoryException
The first of the above created objects which is equal to the specified object in the
the sense of equalsIgnoreMetadata is returned.
object - The object looked up.
null if not found.
FactoryException - if an error occurred while creating an object.
public String findIdentifier(IdentifiedObject object)
throws FactoryException
null if none. The default
implementation invokes find(object) and extracts the
code from the returned identified object.
object - The object looked up.
null if none were found.
FactoryException - if an error occurred while creating an object.
protected final IdentifiedObject findFromParent(IdentifiedObject object,
Class<? extends IdentifiedObject> type)
throws FactoryException
CachingAuthorityFactory finder or AuthorityFactoryAdapter
finder.
This method should be considered as an implementation details. It is visible because it
is needed by DirectEpsgFactory, which is
defined in an other package. User should not rely on this method.
The main purpose of this method is to allow DirectAuthorityFactory implementations
to look for dependencies while leveraging the cache managed by their
CachingAuthorityFactory wrappers.
object - The object looked up.type - The type of object to look for. It doesn't need to be the type specified at
construction time. This relaxation exists in order to allow dependencies lookup,
since the dependencies may be of different kinds.
null if not found.
FactoryException - if an error occurred while creating an object.
protected IdentifiedObject create(String code,
int attempt)
throws FactoryException
find(IdentifiedObject) and findIdentifier(IdentifiedObject) methods.
The method is invoked at least once for each code returned by the
getCodeCandidates(IdentifiedObject) method, in iteration order, until an object
equals (ignoring metadata) to the requested object
is found.
This method may be invoked more than once for the same code. On the first invocation, the
attempt argument is 0. If the returned object is not equals (ignoring metadata)
to the requested object, then this method is invoked again with increasing values of the
attempt argument until this method returns null, which means that every
possible objects for the given code has been created. The purpose is to test various flavor
of the same object (for example with the axis order forced to "longitude first"
or not).
The default implementation delegates to the factory given at construction time only for
the first attempt (attempt == 0), and returns null in all other cases.
Overriding
This method is aimed to be overridden, but subclasses shall not
override it with caching service. For example do not delegate the creation to a
CachingAuthorityFactory instance.
code - The authority code for which to create an object.attempt - The number of previous attempt before this one.
null to stop attempts.
FactoryException - if an error occurred while creating the object.
protected Set<String> getCodeCandidates(IdentifiedObject object)
throws FactoryException
This method is invoked by the default find method implementation. The caller
iterates through the returned codes, instantiate the objects and compare them with the
specified one in order to determine which codes are really applicable. The iteration
stops as soon as a match is found (in other words, if more than one object is equals to
the specified one, then the find method selects the first one in iteration order).
Default implementation
The default implementation returns the same set than
getAuthorityCodes(type)
where type is the interface specified at construction type. Subclasses should
override this method in order to return a smaller set, if they can.
object - The object looked up.
FactoryException - if an error occurred while fetching the set of code candidates.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||