Class IdentifiedObjectFinder

Object
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 Details

    • LOGGER

      public static final Logger LOGGER
  • Constructor Details

  • Method Details

    • 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:

      • 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

      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.
    • getSpecificCodeCandidates

      protected Set getSpecificCodeCandidates(IdentifiedObject object) throws FactoryException
      Throws:
      FactoryException
    • getCodeCandidates

      protected Set<String> 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