/** * Returns the set of authority codes. * * @throws FactoryException if access to the underlying database failed. */ public final Set /*<String>*/ getAuthorityCodes() throws FactoryException { return getAuthorityFactory().getAuthorityCodes(getType()); }
/** 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; }
/** Tests {@link AuthorityFactoryProxy#getType(Class)}. */ @Test public void testType() { assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getType(ProjectedCRS.class)); assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getType(DefaultProjectedCRS.class)); assertEquals(GeographicCRS.class, AuthorityFactoryProxy.getType(GeographicCRS.class)); assertEquals( GeographicCRS.class, AuthorityFactoryProxy.getType(DefaultGeographicCRS.class)); assertEquals(DerivedCRS.class, AuthorityFactoryProxy.getType(DefaultDerivedCRS.class)); assertEquals( CoordinateReferenceSystem.class, AuthorityFactoryProxy.getType(AbstractDerivedCRS.class)); assertEquals( GeodeticDatum.class, AuthorityFactoryProxy.getType(DefaultGeodeticDatum.class)); }
/** Returns all factories to try. */ private Set<AuthorityFactory> fromFactoryRegistry() { final ManyAuthoritiesFactory factory = (ManyAuthoritiesFactory) getProxy().getAuthorityFactory(); final Class<? extends AuthorityFactory> type = getProxy().getType(); final Set<AuthorityFactory> factories = new LinkedHashSet<AuthorityFactory>(); for (final String authority : ReferencingFactoryFinder.getAuthorityNames()) { factory.fromFactoryRegistry(authority, type, factories); } // Removes the factories already tried by super-class. final Collection<AuthorityFactory> done = getFactories(); if (done != null) { factories.removeAll(done); } return factories; }
/** Makes sure that {@link #fallback} is initialized. */ private void ensureFallback() throws FactoryException { if (fallback == null) { fallback = FallbackAuthorityFactory.this.fallback.getIdentifiedObjectFinder( getProxy().getType()); } fallback.setFullScanAllowed(isFullScanAllowed()); }
/** * Returns a proxy instance which will create objects of the specified type using the specified * factory. * * @param factory The factory to use for object creations. * @param type The type of objects to be created by the proxy. */ public static AuthorityFactoryProxy getInstance( final AuthorityFactory factory, Class /*<? extends IdentifiedObject>*/ type) { AbstractAuthorityFactory.ensureNonNull("type", type); AbstractAuthorityFactory.ensureNonNull("factory", factory); type = getType(type); /* * Checks for some special cases for which a fast implementation is available. */ if (factory instanceof CRSAuthorityFactory) { final CRSAuthorityFactory crsFactory = (CRSAuthorityFactory) factory; if (type.equals(ProjectedCRS.class)) return new Projected(crsFactory); if (type.equals(GeographicCRS.class)) return new Geographic(crsFactory); if (type.equals(CoordinateReferenceSystem.class)) return new CRS(crsFactory); } /* * Fallback on the generic case using reflection. */ return new Default(factory, type); }
/** Returns a string representation of the specified object, for debugging purpose only. */ final String toString(final Class owner) { final AuthorityFactory factory = getAuthorityFactory(); return Classes.getShortName(owner) + '[' + Classes.getShortName(getType()) + " in " + Classes.getShortClassName(factory) + "(\"" + factory.getAuthority().getTitle() + "\")]"; }