/** 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; } }
/** 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; }