/** * Wraps a primary and a fallback authority factories. * * <p>This constructor is protected because subclasses must declare which of the {@link * DatumAuthorityFactory}, {@link CSAuthorityFactory}, {@link CRSAuthorityFactory} and {@link * CoordinateOperationAuthorityFactory} interfaces they choose to implement. * * @param primary The primary factory. * @param fallback The factory to use as a fallback if the primary factory failed. * @see #create */ protected FallbackAuthorityFactory( final AuthorityFactory primary, final AuthorityFactory fallback) { super(primary, fallback); ensureNonNull("fallback", fallback); this.fallback = (fallback instanceof AbstractAuthorityFactory) ? (AbstractAuthorityFactory) fallback : new AuthorityFactoryAdapter(fallback); }
/** Returns the {@linkplain #hints hints} extented will all hints specified in dependencies. */ private Hints hints() { final Hints extended = new Hints(hints); addAll(operationFactory, extended); addAll(datumFactory, extended); addAll(csFactory, extended); addAll(crsFactory, extended); extended.putAll(hints); // Gives precedence to the hints from this class. return extended; }
/** * Returns an arbitrary {@linkplain CoordinateSystem coordinate system} from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CoordinateSystem createCoordinateSystem(final String code) throws FactoryException { try { return super.createCoordinateSystem(code); } catch (FactoryException exception) { notifyFailure("createCoordinateSystem", exception); try { return fallback.createCoordinateSystem(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Returns an arbitrary {@linkplain org.opengis.referencing.datum.Datum datum} from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public org.opengis.referencing.datum.Datum createDatum(final String code) throws FactoryException { try { return super.createDatum(code); } catch (FactoryException exception) { notifyFailure("createDatum", exception); try { return fallback.createDatum(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Creates a cartesian coordinate system from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CartesianCS createCartesianCS(final String code) throws FactoryException { try { return super.createCartesianCS(code); } catch (FactoryException exception) { notifyFailure("createCartesianCS", exception); try { return fallback.createCartesianCS(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Creates a cylindrical coordinate system from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CylindricalCS createCylindricalCS(final String code) throws FactoryException { try { return super.createCylindricalCS(code); } catch (FactoryException exception) { notifyFailure("createCylindricalCS", exception); try { return fallback.createCylindricalCS(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Returns a {@linkplain CoordinateSystemAxis coordinate system axis} from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CoordinateSystemAxis createCoordinateSystemAxis(final String code) throws FactoryException { try { return super.createCoordinateSystemAxis(code); } catch (FactoryException exception) { notifyFailure("createCoordinateSystemAxis", exception); try { return fallback.createCoordinateSystemAxis(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Creates a 3D coordinate reference system from a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CompoundCRS createCompoundCRS(final String code) throws FactoryException { try { return super.createCompoundCRS(code); } catch (FactoryException exception) { notifyFailure("createCompoundCRS", exception); try { return fallback.createCompoundCRS(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Creates an operation from a single operation code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CoordinateOperation createCoordinateOperation(final String code) throws FactoryException { try { return super.createCoordinateOperation(code); } catch (FactoryException exception) { notifyFailure("createCoordinateOperation", exception); try { return fallback.createCoordinateOperation(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }
/** * Returns an arbitrary {@linkplain CoordinateReferenceSystem coordinate reference system} from * a code. * * @throws FactoryException if the object creation failed for all factories. */ @Override public CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws FactoryException { try { return super.createCoordinateReferenceSystem(code); } catch (FactoryException exception) { notifyFailure("createCoordinateReferenceSystem", exception); try { return fallback.createCoordinateReferenceSystem(code); } catch (NoSuchAuthorityCodeException ignore) { throw exception; } } }