Class AuthorityFactoryProxy<T>

java.lang.Object
org.apache.sis.referencing.factory.AuthorityFactoryProxy<T>
Direct Known Subclasses:
MultiAuthoritiesFactory.Deferred

abstract class AuthorityFactoryProxy<T> extends Object
Delegates object creations to one of the create methods in a backing AuthorityFactory. It is possible to use the generic AuthorityFactory.createObject(String) method instead of this class, but some factories are more efficient when we use the most specific create method. For example, when using a EPSGDataAccess, invoking GeodeticAuthorityFactory.createProjectedCRS(String) instead of AuthorityFactory.createObject(String) method reduce the amount of tables to be queried.

This class is useful when the same create method need to be invoked often, but is unknown at compile time. It may also be used as a workaround for authority factories that do not implement the createObject(String) method.

Example: the following code creates a proxy which will delegates its work to the createGeographicCRS method.
Since:
0.7
Version:
0.7
  • Field Details

  • Constructor Details

    • AuthorityFactoryProxy

      AuthorityFactoryProxy(Class<T> type, byte factoryType)
      Creates a new proxy for objects of the given type.
  • Method Details

    • toString

      public String toString()
      Returns a string representation for debugging purpose.
      Overrides:
      toString in class Object
    • datumFactory

      final org.opengis.referencing.datum.DatumAuthorityFactory datumFactory(org.opengis.referencing.AuthorityFactory factory) throws org.opengis.util.FactoryException
      Casts the given factory into a datum authority factory, or throws a FactoryException if the given factory is not of the expected type.
      Throws:
      org.opengis.util.FactoryException
    • csFactory

      final org.opengis.referencing.cs.CSAuthorityFactory csFactory(org.opengis.referencing.AuthorityFactory factory) throws org.opengis.util.FactoryException
      Casts the given factory into a CS authority factory, or throws a FactoryException if the given factory is not of the expected type.
      Throws:
      org.opengis.util.FactoryException
    • crsFactory

      final org.opengis.referencing.crs.CRSAuthorityFactory crsFactory(org.opengis.referencing.AuthorityFactory factory) throws org.opengis.util.FactoryException
      Casts the given factory into a CRS authority factory, or throws a FactoryException if the given factory is not of the expected type.
      Throws:
      org.opengis.util.FactoryException
    • opFactory

      final org.opengis.referencing.operation.CoordinateOperationAuthorityFactory opFactory(org.opengis.referencing.AuthorityFactory factory) throws org.opengis.util.FactoryException
      Casts the given factory into an operation authority factory, or throws a FactoryException if the given factory is not of the expected type.
      Throws:
      org.opengis.util.FactoryException
    • geodeticFactory

      final GeodeticAuthorityFactory geodeticFactory(org.opengis.referencing.AuthorityFactory factory) throws org.opengis.util.FactoryException
      Casts the given factory into a geodetic authority factory, or throws a FactoryException if the given factory is not of the expected type.
      Throws:
      org.opengis.util.FactoryException
    • factoryNotFound

      private static org.opengis.util.FactoryException factoryNotFound(Class<? extends org.opengis.referencing.AuthorityFactory> type)
      Returns the exception to be thrown when a factory is not found.
    • create

      T create(GeodeticAuthorityFactory factory, String code) throws org.opengis.util.FactoryException
      Creates the object for the given code.
      Parameters:
      factory - the factory to use for creating the object.
      code - the code for which to create an object.
      Returns:
      the object created from the given code.
      Throws:
      org.opengis.util.FactoryException - if an error occurred while creating the object.
    • createFromAPI

      abstract T createFromAPI(org.opengis.referencing.AuthorityFactory factory, String code) throws org.opengis.util.FactoryException
      Creates the object for the given code using only GeoAPI interfaces. This method is slightly less efficient than the above create(org.apache.sis.referencing.factory.GeodeticAuthorityFactory, java.lang.String) method.
      Parameters:
      factory - the factory to use for creating the object.
      code - the code for which to create an object.
      Returns:
      the object created from the given code.
      Throws:
      org.opengis.util.FactoryException - if an error occurred while creating the object.
    • getInstance

      static <T> AuthorityFactoryProxy<? super T> getInstance(Class<T> type) throws IllegalArgumentException
      Returns the instance for the given type. The type argument can be a GeoAPI interface or some implementation class like DefaultProjectedCRS. This method returns the most specific proxy for the given type.
      Parameters:
      type - the GeoAPI or implementation class.
      Returns:
      the most specific proxy for the given type.
      Throws:
      IllegalArgumentException - if the type does not implement a valid interface.
    • specialize

      AuthorityFactoryProxy<? extends T> specialize(String typeName)
      The proxy to use for a given type declared in a URN. For example in the "urn:ogc:def:crs:EPSG::4326" URN, the proxy to use is CRS.
      Parameters:
      typeName - the name of URN type.
      Returns:
      the proxy for the given type, or null if the given type is illegal.