org.geotools.referencing.factory
Class ManyAuthoritiesFactory

Object
  extended by AbstractFactory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by AuthorityFactoryAdapter
                  extended by ManyAuthoritiesFactory
All Implemented Interfaces:
RegisterableService, Factory, OptionalFactory, AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
Direct Known Subclasses:
AllAuthoritiesFactory

public class ManyAuthoritiesFactory
extends AuthorityFactoryAdapter
implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory

An authority factory that delegates the object creation to an other factory determined from the authority name in the code. This factory requires that every codes given to a createFoo method are prefixed by the authority name, for example "EPSG:4326". This is different from using a factory from a known authority, in which case the authority part was optional (for example when using the EPSG authority factory, the "EPSG:" part in "EPSG:4326" is optional).

This class parses the authority name and delegates the work the corresponding factory. For example if any createFoo(...) method in this class is invoked with a code starting by "EPSG:", then this class delegates the object creation to one of the authority factories provided to the constructor.

This class is not registered in ReferencingFactoryFinder, because it is not a real authority factory. There is not a single authority name associated to this factory, but rather a set of names determined from all available authority factories.

Since:
2.4
Author:
Martin Desruisseaux (IRD)
Module:

Field Summary
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
ManyAuthoritiesFactory(Collection<? extends AuthorityFactory> factories)
          Creates a new factory using the specified set of user factories.
 
Method Summary
 IdentifiedObject createObject(String code)
          Returns an arbitrary object from a code.
 Citation getAuthority()
          Returns the organization or party responsible for definition and maintenance of the database.
 Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
          Returns the set of authority codes of the given type.
protected  AuthorityFactory getAuthorityFactory(String code)
          Returns a generic object authority factory for the specified "AUTHORITY:NUMBER" code.
 Set<String> getAuthorityNames()
          Returns the authority names of every factories given at construction time.
 String getBackingStoreDescription()
          Returns a description of the underlying backing store, or null if unknow.
protected  CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory(String code)
          Returns the operation authority factory for the specified "AUTHORITY:NUMBER" code.
protected  CRSAuthorityFactory getCRSAuthorityFactory(String code)
          Returns the CRS authority factory for the specified "AUTHORITY:NUMBER" code.
protected  CSAuthorityFactory getCSAuthorityFactory(String code)
          Returns the CS authority factory for the specified "AUTHORITY:NUMBER" code.
protected  DatumAuthorityFactory getDatumAuthorityFactory(String code)
          Returns the datum authority factory for the specified "AUTHORITY:NUMBER" code.
 InternationalString getDescriptionText(String code)
          Gets a description of the object corresponding to a code.
 IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
          Returns a finder which can be used for looking up unidentified objects.
protected  char getSeparator(String code)
          Returns the character separator for the specified code.
 Citation getVendor()
          Returns the vendor responsible for creating this factory implementation.
 
Methods inherited from class AuthorityFactoryAdapter
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, 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 CRSAuthorityFactory
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
 
Methods inherited from interface CSAuthorityFactory
createCartesianCS, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createUnit, createVerticalCS
 
Methods inherited from interface DatumAuthorityFactory
createDatum, createEllipsoid, createEngineeringDatum, createGeodeticDatum, createImageDatum, createPrimeMeridian, createTemporalDatum, createVerticalDatum
 
Methods inherited from interface CoordinateOperationAuthorityFactory
createCoordinateOperation, createFromCoordinateReferenceSystemCodes
 
Methods inherited from interface Factory
getImplementationHints
 

Constructor Detail

ManyAuthoritiesFactory

public ManyAuthoritiesFactory(Collection<? extends AuthorityFactory> factories)
Creates a new factory using the specified set of user factories. Any call to a createFoo(code) method will scan the supplied factories in their iteration order. The first factory implementing the appropriate interface and having the expected authority name will be used.

If the factories collection contains more than one factory for the same authority and interface, then all additional factories will be fallbacks, to be tried in iteration order only if the first acceptable factory failed to create the requested object.

Parameters:
factories - A set of user-specified factories to try before to delegate to GeometryFactoryFinder.
Method Detail

getSeparator

protected char getSeparator(String code)
Returns the character separator for the specified code. The default implementation returns the default name separator ':', except if the code looks like a URL (e.g. "http://www.opengis.net/"), in which case this method returns '/'.

In the current implementation, "looks like a URL" means that the first non-aplhanumeric characters are "://". But this heuristic rule may change in future implementations.


getVendor

public Citation getVendor()
Returns the vendor responsible for creating this factory implementation. The default implementation returns Geotools.

Overrides:
getVendor in class AuthorityFactoryAdapter
Returns:
The vendor for this factory implementation.

getAuthority

public Citation getAuthority()
Returns the organization or party responsible for definition and maintenance of the database. The default implementation returns a citation with title "All".

Specified by:
getAuthority in interface AuthorityFactory
Overrides:
getAuthority in class AuthorityFactoryAdapter

getAuthorityNames

public Set<String> getAuthorityNames()
Returns the authority names of every factories given at construction time.


getBackingStoreDescription

public String getBackingStoreDescription()
                                  throws FactoryException
Returns a description of the underlying backing store, or null if unknow.

Overrides:
getBackingStoreDescription in class AuthorityFactoryAdapter
Returns:
The description of the underlying backing store, or null.
Throws:
FactoryException - if a failure occured while fetching the engine description.

getAuthorityFactory

protected AuthorityFactory getAuthorityFactory(String code)
                                        throws NoSuchAuthorityCodeException
Returns a generic object authority factory for the specified "AUTHORITY:NUMBER" code.

Overrides:
getAuthorityFactory in class AuthorityFactoryAdapter
Parameters:
code - The code to parse.
Returns:
The authority factory.
Throws:
NoSuchAuthorityCodeException - if no authority name has been found.

getDatumAuthorityFactory

protected DatumAuthorityFactory getDatumAuthorityFactory(String code)
                                                  throws NoSuchAuthorityCodeException
Returns the datum authority factory for the specified "AUTHORITY:NUMBER" code.

Overrides:
getDatumAuthorityFactory in class AuthorityFactoryAdapter
Parameters:
code - The code to parse.
Returns:
The authority factory.
Throws:
NoSuchAuthorityCodeException - if no authority name has been found.

getCSAuthorityFactory

protected CSAuthorityFactory getCSAuthorityFactory(String code)
                                            throws NoSuchAuthorityCodeException
Returns the CS authority factory for the specified "AUTHORITY:NUMBER" code.

Overrides:
getCSAuthorityFactory in class AuthorityFactoryAdapter
Parameters:
code - The code to parse.
Returns:
The authority factory.
Throws:
NoSuchAuthorityCodeException - if no authority name has been found.

getCRSAuthorityFactory

protected CRSAuthorityFactory getCRSAuthorityFactory(String code)
                                              throws NoSuchAuthorityCodeException
Returns the CRS authority factory for the specified "AUTHORITY:NUMBER" code.

Overrides:
getCRSAuthorityFactory in class AuthorityFactoryAdapter
Parameters:
code - The code to parse.
Returns:
The authority factory.
Throws:
NoSuchAuthorityCodeException - if no authority name has been found.

getCoordinateOperationAuthorityFactory

protected CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory(String code)
                                                                              throws NoSuchAuthorityCodeException
Returns the operation authority factory for the specified "AUTHORITY:NUMBER" code.

Overrides:
getCoordinateOperationAuthorityFactory in class AuthorityFactoryAdapter
Parameters:
code - The code to parse.
Returns:
The authority factory.
Throws:
NoSuchAuthorityCodeException - if no authority name has been found.

getAuthorityCodes

public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
                              throws FactoryException
Returns the set of authority codes of the given type.

Specified by:
getAuthorityCodes in interface AuthorityFactory
Overrides:
getAuthorityCodes in class AuthorityFactoryAdapter
Parameters:
type - The spatial reference objects type (may be IdentifiedObject.class).
Returns:
The set of authority codes for spatial reference objects of the given type. If this factory doesn't contains any object of the given type, then this method returns an empty set.
Throws:
FactoryException - if access to the underlying database failed.

getDescriptionText

public InternationalString getDescriptionText(String code)
                                       throws FactoryException
Gets a description of the object corresponding to a code.

Specified by:
getDescriptionText in interface AuthorityFactory
Overrides:
getDescriptionText in class AuthorityFactoryAdapter
Parameters:
code - Value allocated by authority.
Returns:
A description of the object, or null if the object corresponding to the specified code has no description.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the query failed for some other reason.

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)

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 underlying factories.

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.


Copyright © 1996-2009 Geotools. All Rights Reserved.