org.geotools.referencing.factory
Class IdentifiedObjectFinder

Object
  extended by IdentifiedObjectFinder

public class IdentifiedObjectFinder
extends Object

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
static Logger LOGGER
           
 
Constructor Summary
protected IdentifiedObjectFinder()
          Default constructor, subclass should provide an override for getProxy
protected IdentifiedObjectFinder(AuthorityFactory factory, Class type)
          Creates a finder using the specified factory.
 
Method Summary
protected  IdentifiedObject deriveEquivalent(IdentifiedObject candidate, IdentifiedObject model)
          Returns candidate, or an object derived from candidate, if it is equals ignoring metadata to the specified model.
 IdentifiedObject find(IdentifiedObject object)
          Lookups an object which is equals, ignoring metadata, to the specified object.
 String findIdentifier(IdentifiedObject object)
          Returns the identifier of the specified object, or null if none.
protected  Citation getAuthority()
          The Authority for this Finder; used during get Identifier.
protected  Set getCodeCandidates(IdentifiedObject object)
          Returns a set of authority codes that may identify the same object than the specified one.
protected  AuthorityFactoryProxy getProxy()
           
 boolean isFullScanAllowed()
          If true, 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)
           
 String toString()
          Returns a string representation of this finder, for debugging purpose only.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

public static final Logger LOGGER
Constructor Detail

IdentifiedObjectFinder

protected IdentifiedObjectFinder()
Default constructor, subclass should provide an override for getProxy


IdentifiedObjectFinder

protected IdentifiedObjectFinder(AuthorityFactory factory,
                                 Class type)
Creates a finder using the specified factory. This constructor is protected because instances of this class should not be created directly. Use AbstractAuthorityFactory.getIdentifiedObjectFinder(java.lang.Class) instead.

Parameters:
factory - The factory to scan for the identified objects.
type - The type of objects to lookup.
Method Detail

getProxy

protected AuthorityFactoryProxy getProxy()
Returns:
the proxy

isFullScanAllowed

public boolean isFullScanAllowed()
If 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.


setFullScanAllowed

public void setFullScanAllowed(boolean fullScan)
Set whatever an exhaustive scan against all registered objects is allowed. The default value is true.


find

public IdentifiedObject find(IdentifiedObject object)
                      throws FactoryException
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:

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

public String findIdentifier(IdentifiedObject object)
                      throws FactoryException
Returns the identifier of the specified object, or null if none. The default implementation invokes find(object) and extracts the code from the returned identified object.

Throws:
FactoryException

getAuthority

protected Citation getAuthority()
The Authority for this Finder; used during get Identifier.

Returns:
Citation for the authority being represented.

getCodeCandidates

protected Set getCodeCandidates(IdentifiedObject object)
                         throws FactoryException
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) where type 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
Returns candidate, or an object derived from candidate, if it is equals ignoring metadata to the specified model. Otherwise returns null.

This method is overriden by factories that may test many flavors of candidate, for example TransformedAuthorityFactory.

Parameters:
candidate - An object created by the factory specified at construction time.
Returns:
candidate, or an object derived from candidate (for example with axis order forced to (longitude, latitude), or null 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

public String toString()
Returns a string representation of this finder, for debugging purpose only.

Overrides:
toString in class Object

setProxy

public void setProxy(AuthorityFactoryProxy proxy)
Parameters:
proxy - the proxy to set


Copyright © 1996-2014 Geotools. All Rights Reserved.