Package org.geotools.referencing.factory
Class IdentifiedObjectFinder
Object
IdentifiedObjectFinder
Looks up an object from an authority factory which is
equals, 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 or "
AUTHORITY[...]
" element in
Well Known Text terminology.- Since:
- 2.4
- Author:
- Martin Desruisseaux
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default constructor, subclass should provide an override for getProxyprotected
IdentifiedObjectFinder
(AuthorityFactory factory, Class<? extends IdentifiedObject> type) Creates a finder using the specified factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected IdentifiedObject
deriveEquivalent
(IdentifiedObject candidate, IdentifiedObject model) Returnscandidate
, or an object derived fromcandidate
, if it is equals ignoring metadata to the specified model.find
(IdentifiedObject object) Lookups an object which is equals, ignoring metadata, to the specified object.findIdentifier
(IdentifiedObject object) Returns the identifier of the specified object, ornull
if none.protected Citation
The Authority for this Finder; used during get Identifier.getCodeCandidates
(IdentifiedObject object) Returns a set of authority codes that may identify the same object than the specified one.protected AuthorityFactoryProxy
getProxy()
protected Set
boolean
Iftrue
, an exhaustive full scan against all registered objects will be performed (may be slow).void
setFullScanAllowed
(boolean fullScan) Set whatever an exhaustive scan against all registered objects is allowed.void
setProxy
(AuthorityFactoryProxy proxy) toString()
Returns a string representation of this finder, for debugging purpose only.
-
Field Details
-
LOGGER
-
-
Constructor Details
-
IdentifiedObjectFinder
protected IdentifiedObjectFinder()Default constructor, subclass should provide an override for getProxy -
IdentifiedObjectFinder
Creates a finder using the specified factory. This constructor is protected because instances of this class should not be created directly. UseAbstractAuthorityFactory.getIdentifiedObjectFinder(java.lang.Class<? extends org.geotools.api.referencing.IdentifiedObject>)
instead.- Parameters:
factory
- The factory to scan for the identified objects.type
- The type of objects to lookup.
-
-
Method Details
-
getProxy
protected AuthorityFactoryProxy getProxy()- Returns:
- the proxy
-
isFullScanAllowed
public boolean isFullScanAllowed()Iftrue
, 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 istrue
. -
setFullScanAllowed
public void setFullScanAllowed(boolean fullScan) Set whatever an exhaustive scan against all registered objects is allowed. The default value istrue
. -
find
Lookups an object which is equals, ignoring metadata, to the specified object. The default implementation tries to instantiate some identified objects from the authority factory specified at construction time, in the following order:- If the specified object contains identifiers associated to the same authority than the factory, then those identifiers are used for creating objects to be tested.
- If the authority factory can create objects from their name in addition of identifiers, then the name and aliases are used for creating objects to be tested.
- If full scan is allowed, then full set of authority codes are used for creating objects to be tested.
The first of the above created objects which is equals to the specified object in the the sense of
equalsIgnoreMetadata
is returned.- Parameters:
object
- The object looked up.- Returns:
- The identified object, or
null
if not found. - Throws:
FactoryException
- if an error occured while creating an object.
-
findIdentifier
Returns the identifier of the specified object, ornull
if none. The default implementation invokesfind(object)
and extracts the code from the returned identified object.- Throws:
FactoryException
-
getAuthority
The Authority for this Finder; used during get Identifier.- Returns:
- Citation for the authority being represented.
-
getSpecificCodeCandidates
- Throws:
FactoryException
-
getCodeCandidates
Returns a set of authority codes that may identify the same object than the specified one. The returned set must contains the code of every objects that are equals, ignoring metadata, to the specified one. However the set is not required to contains only the codes of those objects; it may conservatively contains the code for more objects if an exact search is too expensive.This method is invoked by the default
find
method implementation. The caller may iterates through every returned codes, instantiate the objects and compare them with the specified one in order to determine which codes are really applicable.The default implementation returns the same set than
getAuthorityCodes(type)
wheretype
is the interface specified at construction type. Subclasses should override this method in order to return a smaller set, if they can.- Parameters:
object
- The object looked up.- Returns:
- A set of code candidates.
- Throws:
FactoryException
- if an error occured while fetching the set of code candidates.
-
deriveEquivalent
protected IdentifiedObject deriveEquivalent(IdentifiedObject candidate, IdentifiedObject model) throws FactoryException Returnscandidate
, or an object derived fromcandidate
, if it is equals ignoring metadata to the specified model. Otherwise returnsnull
.This method is overriden by factories that may test many flavors of
candidate
, for exampleTransformedAuthorityFactory
.- Parameters:
candidate
- An object created by the factory specified at construction time.- Returns:
candidate
, or an object derived fromcandidate
(for example with axis order forced to (longitude, latitude), ornull
if none of the above is equals ignoring metadata to the specified model.- Throws:
FactoryException
- if an error occured while creating a derived object.
-
toString
Returns a string representation of this finder, for debugging purpose only. -
setProxy
public void setProxy(AuthorityFactoryProxy proxy) - Parameters:
proxy
- the proxy to set
-