Class ManyAuthoritiesFactory
- Object
-
- AbstractFactory
-
- ReferencingFactory
-
- AbstractAuthorityFactory
-
- AuthorityFactoryAdapter
-
- ManyAuthoritiesFactory
-
- All Implemented Interfaces:
AuthorityFactory
,CRSAuthorityFactory
,CSAuthorityFactory
,DatumAuthorityFactory
,Factory
,CoordinateOperationAuthorityFactory
,Factory
,OptionalFactory
,RegistrableFactory
- 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 acreateFoo
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)
-
-
Field Summary
-
Fields inherited from class ReferencingFactory
LOGGER
-
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
-
Constructor Summary
Constructors Constructor Description ManyAuthoritiesFactory(Collection<? extends AuthorityFactory> factories)
Creates a new factory using the specified set of user factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, ornull
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.protected void
notifySuccess(String method, String code, CRSAuthorityFactory factory, CoordinateReferenceSystem crs)
Log a message when a CRS is found.-
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, dispose, isAvailable, toBackingFactoryCode
-
Methods inherited from class AbstractAuthorityFactory
noSuchAuthorityCode, trimAuthority
-
Methods inherited from class ReferencingFactory
ensureNonNull
-
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
-
Methods inherited from interface CoordinateOperationAuthorityFactory
createCoordinateOperation, createFromCoordinateReferenceSystemCodes
-
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 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 acreateFoo(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
-
-
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.- Specified by:
getVendor
in interfaceFactory
- Overrides:
getVendor
in classAuthorityFactoryAdapter
- 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 interfaceAuthorityFactory
- Overrides:
getAuthority
in classAuthorityFactoryAdapter
- Returns:
- The organization reponsible for definition of the database.
-
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, ornull
if unknow.- Overrides:
getBackingStoreDescription
in classAuthorityFactoryAdapter
- Returns:
- The description of the underlying backing store, or
null
. - Throws:
FactoryException
- if a failure occured while fetching the engine description.
-
notifySuccess
protected void notifySuccess(String method, String code, CRSAuthorityFactory factory, CoordinateReferenceSystem crs)
Description copied from class:AuthorityFactoryAdapter
Log a message when a CRS is found. Child objects that doesn't create their own CRS-objects should not report.- Overrides:
notifySuccess
in classAuthorityFactoryAdapter
-
getAuthorityFactory
protected AuthorityFactory getAuthorityFactory(String code) throws NoSuchAuthorityCodeException
Returns a generic object authority factory for the specified"AUTHORITY:NUMBER"
code.- Overrides:
getAuthorityFactory
in classAuthorityFactoryAdapter
- 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 classAuthorityFactoryAdapter
- 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 classAuthorityFactoryAdapter
- 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 classAuthorityFactoryAdapter
- 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 classAuthorityFactoryAdapter
- 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 interfaceAuthorityFactory
- Overrides:
getAuthorityCodes
in classAuthorityFactoryAdapter
- Parameters:
type
- The spatial reference objects type (may beIdentifiedObject.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 {@linkplain java.util.Collections.emptySet() 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 interfaceAuthorityFactory
- Overrides:
getDescriptionText
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- A description of the object, or
null
if the object corresponding to the specifiedcode
has no description. - Throws:
NoSuchAuthorityCodeException
- if the specifiedcode
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 interfaceAuthorityFactory
- Overrides:
createObject
in classAuthorityFactoryAdapter
- Parameters:
code
- Value allocated by authority.- Returns:
- The object for the given code.
- 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 classAuthorityFactoryAdapter
- Parameters:
type
- The type of objects to look for. Should be a GeoAPI interface likeGeographicCRS.class
, but this method accepts also implementation class. If the type is unknown, useIdentifiedObject.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.
-
-