Class 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 Detail

      • LOGGER

        public static final Logger LOGGER
    • 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:

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

        protected Citation getAuthority()
        The Authority for this Finder; used during get Identifier.
        Returns:
        Citation for the authority being represented.
      • 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.
      • 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