org.geotools.referencing.factory
Class FallbackAuthorityFactory

Object
  extended by AbstractFactory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by AuthorityFactoryAdapter
                  extended by FallbackAuthorityFactory
All Implemented Interfaces:
RegisterableService, Factory, OptionalFactory, AuthorityFactory

public class FallbackAuthorityFactory
extends AuthorityFactoryAdapter

A factory which delegates all object creation to a primary factory, and fallback on an other one if the primary factory failed.

Since:
2.3
Author:
Martin Desruisseaux
Module:
modules/library/referencing (gt-referencing.jar)

Field Summary
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
protected FallbackAuthorityFactory(AuthorityFactory primary, AuthorityFactory fallback)
          Wraps a primary and a fallback authority factories.
 
Method Summary
static
<T extends AuthorityFactory>
T
create(Class<T> type, Collection<T> factories)
          Wraps the specified authority factories.
static AuthorityFactory create(Collection<? extends AuthorityFactory> factories)
          Wraps the specified authority factories.
 CartesianCS createCartesianCS(String code)
          Creates a cartesian coordinate system from a code.
 CompoundCRS createCompoundCRS(String code)
          Creates a 3D coordinate reference system from a code.
 CoordinateOperation createCoordinateOperation(String code)
          Creates an operation from a single operation code.
 CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
          Returns an arbitrary coordinate reference system from a code.
 CoordinateSystem createCoordinateSystem(String code)
          Returns an arbitrary coordinate system from a code.
 CoordinateSystemAxis createCoordinateSystemAxis(String code)
          Returns a coordinate system axis from a code.
 CylindricalCS createCylindricalCS(String code)
          Creates a cylindrical coordinate system from a code.
 Datum createDatum(String code)
          Returns an arbitrary datum from a code.
 DerivedCRS createDerivedCRS(String code)
          Creates a derived coordinate reference system from a code.
 Ellipsoid createEllipsoid(String code)
          Returns an ellipsoid from a code.
 EllipsoidalCS createEllipsoidalCS(String code)
          Creates an ellipsoidal coordinate system from a code.
 EngineeringCRS createEngineeringCRS(String code)
          Creates a engineering coordinate reference system from a code.
 EngineeringDatum createEngineeringDatum(String code)
          Creates a engineering datum from a code.
 Extent createExtent(String code)
          Returns a extent (usually an area of validity) from a code.
 Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS, String targetCRS)
          Creates an operation from coordinate reference system codes.
 GeocentricCRS createGeocentricCRS(String code)
          Returns a geocentric coordinate reference system from a code.
 GeodeticDatum createGeodeticDatum(String code)
          Returns a geodetic datum from a code.
 GeographicCRS createGeographicCRS(String code)
          Returns a geographic coordinate reference system from a code.
 ImageCRS createImageCRS(String code)
          Creates a image coordinate reference system from a code.
 ImageDatum createImageDatum(String code)
          Creates a image datum from a code.
 IdentifiedObject createObject(String code)
          Returns an arbitrary object from a code.
 OperationMethod createOperationMethod(String code)
          Creates an operation method from a code.
 ParameterDescriptor createParameterDescriptor(String code)
          Creates a parameter descriptor from a code.
 PolarCS createPolarCS(String code)
          Creates a polar coordinate system from a code.
 PrimeMeridian createPrimeMeridian(String code)
          Returns a prime meridian from a code.
 ProjectedCRS createProjectedCRS(String code)
          Returns a projected coordinate reference system from a code.
 SphericalCS createSphericalCS(String code)
          Creates a spherical coordinate system from a code.
 TemporalCRS createTemporalCRS(String code)
          Creates a temporal coordinate reference system from a code.
 TemporalDatum createTemporalDatum(String code)
          Creates a temporal datum from a code.
 TimeCS createTimeCS(String code)
          Creates a temporal coordinate system from a code.
 Unit<?> createUnit(String code)
          Returns an unit from a code.
 VerticalCRS createVerticalCRS(String code)
          Creates a vertical coordinate reference system from a code.
 VerticalCS createVerticalCS(String code)
          Creates a vertical coordinate system from a code.
 VerticalDatum createVerticalDatum(String code)
          Creates a vertical datum from a code.
 Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
          Returns the set of authority codes for the specified type.
 InternationalString getDescriptionText(String code)
          Returns a description for the object identified by the specified code.
 IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
          Returns a finder which can be used for looking up unidentified objects.
 
Methods inherited from class AuthorityFactoryAdapter
getAuthority, getAuthorityFactory, getBackingStoreDescription, getCoordinateOperationAuthorityFactory, getCRSAuthorityFactory, getCSAuthorityFactory, getDatumAuthorityFactory, getVendor, isAvailable, toBackingFactoryCode
 
Methods inherited from class AbstractAuthorityFactory
dispose, noSuchAuthorityCode, trimAuthority
 
Methods inherited from class ReferencingFactory
ensureNonNull
 
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Factory
getImplementationHints
 

Constructor Detail

FallbackAuthorityFactory

protected FallbackAuthorityFactory(AuthorityFactory primary,
                                   AuthorityFactory fallback)
Wraps a primary and a fallback authority factories.

This constructor is protected because subclasses must declare which of the DatumAuthorityFactory, CSAuthorityFactory, CRSAuthorityFactory and CoordinateOperationAuthorityFactory interfaces they choose to implement.

Parameters:
primary - The primary factory.
fallback - The factory to use as a fallback if the primary factory failed.
See Also:
create(java.lang.Class, java.util.Collection)
Method Detail

create

public static <T extends AuthorityFactory> T create(Class<T> type,
                                                    Collection<T> factories)
                                         throws FactoryNotFoundException,
                                                ClassCastException
Wraps the specified authority factories. If the specified collection contains more than one element, then a chain of FallbackAuthorityFactory instances is created.

Type Parameters:
T - The interface to implement.
Parameters:
type - The interface to implement. Should be one of DatumAuthorityFactory, CSAuthorityFactory, CRSAuthorityFactory or CoordinateOperationAuthorityFactory.
factories - The factories to wrap, in iteration order.
Returns:
The given factories as a chain of fallback factories.
Throws:
FactoryNotFoundException - if the collection doesn't contains at least one element.
ClassCastException - if type is illegal.
FactoryNotFoundException

create

public static AuthorityFactory create(Collection<? extends AuthorityFactory> factories)
                               throws FactoryNotFoundException
Wraps the specified authority factories. If the specified collection contains more than one element, then a chain of FallbackAuthorityFactory instances is created. The type is inferred from the factories found in the collection.

Consider using create(type, factories) instead when the type is known at compile time.

Parameters:
factories - The factories to wrap, in iteration order.
Returns:
The given factories as a chain of fallback factories.
Throws:
FactoryNotFoundException - if the collection doesn't contains at least one element.
FactoryNotFoundException
Since:
2.4

getAuthorityCodes

public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
                              throws FactoryException
Returns the set of authority codes for the specified type. The default implementation returns the union of the authority codes from the primary and the fallback factories.

Specified by:
getAuthorityCodes in interface AuthorityFactory
Overrides:
getAuthorityCodes in class AuthorityFactoryAdapter
Throws:
FactoryException

getDescriptionText

public InternationalString getDescriptionText(String code)
                                       throws FactoryException
Returns a description for the object identified by the specified code.

Specified by:
getDescriptionText in interface AuthorityFactory
Overrides:
getDescriptionText in class AuthorityFactoryAdapter
Throws:
FactoryException

createObject

public IdentifiedObject createObject(String code)
                              throws FactoryException
Returns an arbitrary object from a code.

Specified by:
createObject in interface AuthorityFactory
Overrides:
createObject in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Throws:
FactoryException - if the object creation failed.
See Also:
AuthorityFactoryAdapter.createCoordinateReferenceSystem(java.lang.String), AuthorityFactoryAdapter.createDatum(java.lang.String), AuthorityFactoryAdapter.createEllipsoid(java.lang.String), AuthorityFactoryAdapter.createUnit(java.lang.String)

createDatum

public Datum createDatum(String code)
                  throws FactoryException
Returns an arbitrary datum from a code.

Overrides:
createDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createGeodeticDatum(java.lang.String), AuthorityFactoryAdapter.createVerticalDatum(java.lang.String), AuthorityFactoryAdapter.createTemporalDatum(java.lang.String)

createEngineeringDatum

public EngineeringDatum createEngineeringDatum(String code)
                                        throws FactoryException
Creates a engineering datum from a code.

Overrides:
createEngineeringDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createEngineeringCRS(java.lang.String)

createImageDatum

public ImageDatum createImageDatum(String code)
                            throws FactoryException
Creates a image datum from a code.

Overrides:
createImageDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createImageCRS(java.lang.String)

createVerticalDatum

public VerticalDatum createVerticalDatum(String code)
                                  throws FactoryException
Creates a vertical datum from a code.

Overrides:
createVerticalDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createVerticalCRS(java.lang.String)

createTemporalDatum

public TemporalDatum createTemporalDatum(String code)
                                  throws FactoryException
Creates a temporal datum from a code.

Overrides:
createTemporalDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createTemporalCRS(java.lang.String)

createGeodeticDatum

public GeodeticDatum createGeodeticDatum(String code)
                                  throws FactoryException
Returns a geodetic datum from a code.

Overrides:
createGeodeticDatum in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createEllipsoid(java.lang.String), AuthorityFactoryAdapter.createPrimeMeridian(java.lang.String), AuthorityFactoryAdapter.createGeographicCRS(java.lang.String), AuthorityFactoryAdapter.createProjectedCRS(java.lang.String)

createEllipsoid

public Ellipsoid createEllipsoid(String code)
                          throws FactoryException
Returns an ellipsoid from a code.

Overrides:
createEllipsoid in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The ellipsoid for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createGeodeticDatum(java.lang.String)

createPrimeMeridian

public PrimeMeridian createPrimeMeridian(String code)
                                  throws FactoryException
Returns a prime meridian from a code.

Overrides:
createPrimeMeridian in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The prime meridian for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createGeodeticDatum(java.lang.String)

createExtent

public Extent createExtent(String code)
                    throws FactoryException
Returns a extent (usually an area of validity) from a code.

Overrides:
createExtent in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The extent for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCoordinateSystem

public CoordinateSystem createCoordinateSystem(String code)
                                        throws FactoryException
Returns an arbitrary coordinate system from a code.

Overrides:
createCoordinateSystem in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCartesianCS

public CartesianCS createCartesianCS(String code)
                              throws FactoryException
Creates a cartesian coordinate system from a code.

Overrides:
createCartesianCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createPolarCS

public PolarCS createPolarCS(String code)
                      throws FactoryException
Creates a polar coordinate system from a code.

Overrides:
createPolarCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCylindricalCS

public CylindricalCS createCylindricalCS(String code)
                                  throws FactoryException
Creates a cylindrical coordinate system from a code.

Overrides:
createCylindricalCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createSphericalCS

public SphericalCS createSphericalCS(String code)
                              throws FactoryException
Creates a spherical coordinate system from a code.

Overrides:
createSphericalCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createEllipsoidalCS

public EllipsoidalCS createEllipsoidalCS(String code)
                                  throws FactoryException
Creates an ellipsoidal coordinate system from a code.

Overrides:
createEllipsoidalCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createVerticalCS

public VerticalCS createVerticalCS(String code)
                            throws FactoryException
Creates a vertical coordinate system from a code.

Overrides:
createVerticalCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createTimeCS

public TimeCS createTimeCS(String code)
                    throws FactoryException
Creates a temporal coordinate system from a code.

Overrides:
createTimeCS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCoordinateSystemAxis

public CoordinateSystemAxis createCoordinateSystemAxis(String code)
                                                throws FactoryException
Returns a coordinate system axis from a code.

Overrides:
createCoordinateSystemAxis in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The axis for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createUnit

public Unit<?> createUnit(String code)
                   throws FactoryException
Returns an unit from a code.

Overrides:
createUnit in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The unit for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCoordinateReferenceSystem

public CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
                                                          throws FactoryException
Returns an arbitrary coordinate reference system from a code.

Overrides:
createCoordinateReferenceSystem in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AuthorityFactoryAdapter.createGeographicCRS(java.lang.String), AuthorityFactoryAdapter.createProjectedCRS(java.lang.String), AuthorityFactoryAdapter.createVerticalCRS(java.lang.String), AuthorityFactoryAdapter.createTemporalCRS(java.lang.String), AuthorityFactoryAdapter.createCompoundCRS(java.lang.String)

createCompoundCRS

public CompoundCRS createCompoundCRS(String code)
                              throws FactoryException
Creates a 3D coordinate reference system from a code.

Overrides:
createCompoundCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createDerivedCRS

public DerivedCRS createDerivedCRS(String code)
                            throws FactoryException
Creates a derived coordinate reference system from a code.

Overrides:
createDerivedCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createEngineeringCRS

public EngineeringCRS createEngineeringCRS(String code)
                                    throws FactoryException
Creates a engineering coordinate reference system from a code.

Overrides:
createEngineeringCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createGeographicCRS

public GeographicCRS createGeographicCRS(String code)
                                  throws FactoryException
Returns a geographic coordinate reference system from a code.

Overrides:
createGeographicCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createGeocentricCRS

public GeocentricCRS createGeocentricCRS(String code)
                                  throws FactoryException
Returns a geocentric coordinate reference system from a code.

Overrides:
createGeocentricCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createImageCRS

public ImageCRS createImageCRS(String code)
                        throws FactoryException
Creates a image coordinate reference system from a code.

Overrides:
createImageCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createProjectedCRS

public ProjectedCRS createProjectedCRS(String code)
                                throws FactoryException
Returns a projected coordinate reference system from a code.

Overrides:
createProjectedCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createTemporalCRS

public TemporalCRS createTemporalCRS(String code)
                              throws FactoryException
Creates a temporal coordinate reference system from a code.

Overrides:
createTemporalCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AbstractAuthorityFactory.createTemporalDatum(java.lang.String)

createVerticalCRS

public VerticalCRS createVerticalCRS(String code)
                              throws FactoryException
Creates a vertical coordinate reference system from a code.

Overrides:
createVerticalCRS in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.
See Also:
AbstractAuthorityFactory.createVerticalDatum(java.lang.String)

createParameterDescriptor

public ParameterDescriptor createParameterDescriptor(String code)
                                              throws FactoryException
Creates a parameter descriptor from a code.

Overrides:
createParameterDescriptor in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createOperationMethod

public OperationMethod createOperationMethod(String code)
                                      throws FactoryException
Creates an operation method from a code.

Overrides:
createOperationMethod in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The operation method for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createCoordinateOperation

public CoordinateOperation createCoordinateOperation(String code)
                                              throws FactoryException
Creates an operation from a single operation code.

Overrides:
createCoordinateOperation in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
The operation for the given code.
Throws:
FactoryException - if the object creation failed for all factories.

createFromCoordinateReferenceSystemCodes

public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS,
                                                                         String targetCRS)
                                                                  throws FactoryException
Creates an operation from coordinate reference system codes.

Overrides:
createFromCoordinateReferenceSystemCodes in class AuthorityFactoryAdapter
Parameters:
sourceCRS - Coded value of source coordinate reference system.
targetCRS - Coded value of target coordinate reference system.
Returns:
The operations from sourceCRS to targetCRS.
Throws:
FactoryException - if the object creation failed for all factories.

getIdentifiedObjectFinder

public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
                                                 throws FactoryException
Returns a finder which can be used for looking up unidentified objects. The default implementation delegates the lookups to the primary factory, and fallback on the second one if the primary factory can't find a match.

Overrides:
getIdentifiedObjectFinder in class AuthorityFactoryAdapter
Parameters:
type - The type of objects to look for. Should be a GeoAPI interface like GeographicCRS.class, but this method accepts also implementation class. If the type is unknown, use IdentifiedObject.class. A more accurate type may help to speed up the search, since it reduces the amount of tables to scan in some implementations like the factories backed by EPSG database.
Returns:
A finder to use for looking up unidentified objects.
Throws:
FactoryException - if the object creation failed.
Since:
2.4


Copyright © 1996-2009 Geotools. All Rights Reserved.