/** Lookups for the specified object. */ @Override public IdentifiedObject find(final IdentifiedObject object) throws FactoryException { /* * Try to create from the identifier before to scan over every factories, * because the identifier may contains the authority name, in which case * we can pickup directly the right factory instead of trying them all. */ IdentifiedObject candidate = createFromIdentifiers(object); if (candidate != null) { return candidate; } final Collection<AuthorityFactory> factories = getFactories(); if (factories != null) { IdentifiedObjectFinder finder; final Iterator<AuthorityFactory> it = factories.iterator(); while ((finder = next(it)) != null) { candidate = finder.find(object); if (candidate != null) { break; } } } return candidate; }
/** Lookups for the specified object. */ @Override public IdentifiedObject find(final IdentifiedObject object) throws FactoryException { IdentifiedObject candidate = super.find(object); if (candidate != null) { return candidate; } IdentifiedObjectFinder finder; final Iterator<AuthorityFactory> it = fromFactoryRegistry().iterator(); while ((finder = next(it)) != null) { candidate = finder.find(object); if (candidate != null) { break; } } return candidate; }
/** Returns the identifier of the specified object, or {@code null} if none. */ @Override public String findIdentifier(final IdentifiedObject object) throws FactoryException { String candidate = super.findIdentifier(object); if (candidate != null) { return candidate; } IdentifiedObjectFinder finder; final Iterator<AuthorityFactory> it = fromFactoryRegistry().iterator(); while ((finder = next(it)) != null) { candidate = finder.findIdentifier(object); if (candidate != null) { break; } } return candidate; } }
/** Returns the identifier of the specified object, or {@code null} if none. */ @Override public String findIdentifier(final IdentifiedObject object) throws FactoryException { /* * Try to create from the identifier for the same reason than find(IdentifiedObject). * Note that we returns directly the primary name; we don't try to locate a name for * a given authority since the "All" authority do not really exists. */ IdentifiedObject candidate = createFromIdentifiers(object); if (candidate != null) { return candidate.getName().toString(); } final Collection<AuthorityFactory> factories = getFactories(); if (factories != null) { IdentifiedObjectFinder finder; final Iterator<AuthorityFactory> it = factories.iterator(); while ((finder = next(it)) != null) { final String id = finder.findIdentifier(object); if (id != null) { return id; } } } return null; } }
/** Returns the next finder in the specified set of factories, or {@code null} if none. */ final IdentifiedObjectFinder next(final Iterator<AuthorityFactory> it) throws FactoryException { while (it.hasNext()) { final AuthorityFactory factory = it.next(); if (exclude(factory)) { continue; } if (factory instanceof AbstractAuthorityFactory) { final IdentifiedObjectFinder finder = ((AbstractAuthorityFactory) factory) .getIdentifiedObjectFinder(getProxy().getType()); if (finder != null) { finder.setFullScanAllowed(isFullScanAllowed()); return finder; } } } return null; }
/** Returns the user-supplied factories. */ final Collection<AuthorityFactory> getFactories() { return ((ManyAuthoritiesFactory) getProxy().getAuthorityFactory()).getFactories(); }
/** * Returns a finder which can be used for looking up unidentified objects. The default * implementation delegates the lookups to the underlying factories. */ @Override public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) throws FactoryException { return new Finder(this, type); }