/** * Copies the hints from the supplied factory. Note that we do not expose the factories themself * (at the contrary of what we usually do) because it is a little bit strange to declare that * this factory depends on an other {@link DatumFactory}. It is only a trick for getting the WKT * paser to work with aliases. * * @todo We should remove this trick if we can. Possible alternatives may be: make DatumAliases * to implements CRSFactory with appropriate createWKT(String) method; move the * createWKT(String) method out of CRSFactory interface. */ private void addHints(final Object factory) { if (factory instanceof Factory) { hints.putAll(((Factory) factory).getImplementationHints()); } }
/** Adds all hints from the specified factory into the specified set of hints. */ private static void addAll(final AuthorityFactory factory, final Hints hints) { if (factory instanceof Factory) { hints.putAll(((Factory) factory).getImplementationHints()); } }
/** * Creates a new factory using the specified set of user factories. Any call to a {@code * createFoo(code)} method will scan the supplied factories in their iteration order. The first * factory implementing the appropriate interface and having the expected {@linkplain * AuthorityFactory#getAuthority authority name} will be used. * * <p>If the {@code factories} collection contains more than one factory for the same authority * and interface, then all additional factories will be {@linkplain FallbackAuthorityFactory * fallbacks}, to be tried in iteration order only if the first acceptable factory failed to * create the requested object. * * @param factories A set of user-specified factories to try before to delegate to {@link * GeometryFactoryFinder}. */ public ManyAuthoritiesFactory(final Collection<? extends AuthorityFactory> factories) { super(NORMAL_PRIORITY); inProgress = new ThreadLocal<Boolean>(); if (factories != null && !factories.isEmpty()) { for (final AuthorityFactory factory : factories) { if (factory instanceof Factory) { hints.putAll(((Factory) factory).getImplementationHints()); } } this.factories = createFallbacks(factories); } }
/** * Returns the version number of the specified authority database, or {@code null} if not * available. * * @param authority The authority name (typically {@code "EPSG"}). * @return The version number of the authority database, or {@code null} if unknown. * @throws FactoryRegistryException if no {@link CRSAuthorityFactory} implementation was found * for the specified authority. * @since 2.4 */ public static Version getVersion(final String authority) throws FactoryRegistryException { Object candidate = ReferencingFactoryFinder.getCRSAuthorityFactory(authority, null); final Set<Factory> guard = new HashSet<Factory>(); while (candidate instanceof Factory) { final Factory factory = (Factory) candidate; if (!guard.add(factory)) { break; // Safety against never-ending recursivity. } final Map hints = factory.getImplementationHints(); final Object version = hints.get(Hints.VERSION); if (version instanceof Version) { return (Version) version; } candidate = hints.get(Hints.CRS_AUTHORITY_FACTORY); } return null; }
/** * Returns a coordinate operation factory for this adapter. This method will try to fetch this * information from the coordinate operation authority factory, or will returns the default one * if no explicit factory were found. */ final CoordinateOperationFactory getCoordinateOperationFactory() throws FactoryException { if (operationFactory instanceof Factory) { final Factory factory = (Factory) operationFactory; final Map hints = factory.getImplementationHints(); final Object candidate = hints.get(Hints.COORDINATE_OPERATION_FACTORY); if (candidate instanceof CoordinateOperationFactory) { return (CoordinateOperationFactory) candidate; } } return ReferencingFactoryFinder.getCoordinateOperationFactory(hints()); }
/** * Returns {@code true} if {@code f1} and {@code f2} are equals. * * @param done An initially empty set. Used internally for preventing infinite recursivity. */ boolean compare(final Set<FactoryComparator> done) { if (done.add(this)) { final Map<RenderingHints.Key, ?> m1 = f1.getImplementationHints(); final Map<RenderingHints.Key, ?> m2 = f2.getImplementationHints(); if (m1.size() != m2.size()) { return false; } for (final Map.Entry<RenderingHints.Key, ?> entry : m1.entrySet()) { final Object key = entry.getKey(); final Object v1 = entry.getValue(); final Object v2 = m2.get(key); if (v1 == v2) continue; if (v1 instanceof Factory) { if (v2 == null || !v1.getClass().equals(v2.getClass()) || !new FactoryComparator((Factory) v1, (Factory) v2).compare(done)) { return false; } } else if (!Utilities.equals(v1, v2)) { return false; } } } return true; }
if (recursive != null) { final String nextIndent = Utilities.spaces(indent.length() + 2); format(table, recursive.getImplementationHints(), nextIndent, done);
implementationHints = Hints.stripNonKeys(factory.getImplementationHints()); } finally { testingHints.removeAndCheck(factory);