Class BufferedAuthorityFactory
- All Implemented Interfaces:
AuthorityFactory
,Factory
,BufferedFactory
,Factory
,RegistrableFactory
- Direct Known Subclasses:
DeferredAuthorityFactory
createFoo(String)
methods first
looks if a previously created object exists for the given code. If such an object exists, it is returned. Otherwise,
the object creation is delegated to the authority factory specified at creation
time, and the result is cached in this buffered factory.
Objects are cached by strong references, up to the amount of objects specified at construction time. If a greater amount of objects are cached, the oldest ones will be retained through a weak reference instead of a strong one. This means that this buffered factory will continue to returns them as long as they are in use somewhere else in the Java virtual machine, but will be discarted (and recreated on the fly if needed) otherwise.
- Since:
- 2.1
- 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
ConstructorsModifierConstructorDescriptionprotected
Constructs an instance wrapping the specified factory with a default number of entries to keep by strong reference.protected
BufferedAuthorityFactory
(AbstractAuthorityFactory factory, int maxStrongReferences) Constructs an instance wrapping the specified factory. -
Method Summary
Modifier and TypeMethodDescriptioncreateCartesianCS
(String code) Returns a cartesian coordinate system from a code.createCompoundCRS
(String code) Returns a 3D coordinate reference system from a code.Returns an operation from a single operation code.Returns an arbitrary coordinate reference system from a code.createCoordinateSystem
(String code) Returns an arbitrary coordinate system from a code.Returns a coordinate system axis from a code.createCylindricalCS
(String code) Returns a cylindrical coordinate system from a code.createDatum
(String code) Returns an arbitrary datum from a code.createDerivedCRS
(String code) Returns a derived coordinate reference system from a code.createEllipsoid
(String code) Returns an ellipsoid from a code.createEllipsoidalCS
(String code) Returns an ellipsoidal coordinate system from a code.createEngineeringCRS
(String code) Returns an engineering coordinate reference system from a code.createEngineeringDatum
(String code) Returns an engineering datum from a code.createExtent
(String code) Returns an extent (usually an area of validity) from a code.createFromCoordinateReferenceSystemCodes
(String sourceCRS, String targetCRS) Returns an operation from coordinate reference system codes.createGeocentricCRS
(String code) Returns a geocentric coordinate reference system from a code.createGeodeticDatum
(String code) Returns a geodetic datum from a code.createGeographicCRS
(String code) Returns a geographic coordinate reference system from a code.createImageCRS
(String code) Returns an image coordinate reference system from a code.createImageDatum
(String code) Returns an image datum from a code.createObject
(String code) Returns an arbitrary object from a code.createOperationMethod
(String code) Returns an operation method from a code.Returns a parameter descriptor from a code.createPolarCS
(String code) Returns a polar coordinate system from a code.createPrimeMeridian
(String code) Returns a prime meridian from a code.createProjectedCRS
(String code) Returns a projected coordinate reference system from a code.createSphericalCS
(String code) Returns a spherical coordinate system from a code.createTemporalCRS
(String code) Returns a temporal coordinate reference system from a code.createTemporalDatum
(String code) Returns a temporal datum from a code.createTimeCS
(String code) Returns a temporal coordinate system from a code.Unit<?>
createUnit
(String code) Returns an unit from a code.createVerticalCRS
(String code) Returns a vertical coordinate reference system from a code.createVerticalCS
(String code) Returns a vertical coordinate system from a code.createVerticalDatum
(String code) Returns a vertical datum from a code.void
dispose()
Releases resources immediately instead of waiting for the garbage collector.Returns the organization or party responsible for definition and maintenance of the underlying database.getAuthorityCodes
(Class<? extends IdentifiedObject> type) Returns the set of authority codes of the given type.Returns a description of the underlying backing store, ornull
if unknow.getDescriptionText
(String code) Gets a description of the object corresponding to a code.getIdentifiedObjectFinder
(Class<? extends IdentifiedObject> type) Returns a finder which can be used for looking up unidentified objects.Returns the vendor responsible for creating the underlying factory implementation.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 Factory
getImplementationHints
-
Constructor Details
-
BufferedAuthorityFactory
Constructs an instance wrapping the specified factory with a default number of entries to keep by strong reference.This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory
,CSAuthorityFactory
,CRSAuthorityFactory
andCoordinateOperationAuthorityFactory
interfaces they choose to implement.- Parameters:
factory
- The factory to cache. Can not benull
.
-
BufferedAuthorityFactory
Constructs an instance wrapping the specified factory. ThemaxStrongReferences
argument specify the maximum number of objects to keep by strong reference. If a greater amount of objects are created, then the strong references for the oldest ones are replaced by weak references.This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory
,CSAuthorityFactory
,CRSAuthorityFactory
andCoordinateOperationAuthorityFactory
interfaces they choose to implement.- Parameters:
factory
- The factory to cache. Can not benull
.maxStrongReferences
- The maximum number of objects to keep by strong reference.
-
-
Method Details
-
getVendor
Returns the vendor responsible for creating the underlying factory implementation.- Specified by:
getVendor
in interfaceFactory
- Overrides:
getVendor
in classReferencingFactory
- Returns:
- The vendor for this factory implementation.
-
getAuthority
Returns the organization or party responsible for definition and maintenance of the underlying database.- Specified by:
getAuthority
in interfaceAuthorityFactory
- Specified by:
getAuthority
in classAbstractAuthorityFactory
- Returns:
- The organization reponsible for definition of the database.
-
getBackingStoreDescription
Returns a description of the underlying backing store, ornull
if unknow. This is for example the database software used for storing the data.- Overrides:
getBackingStoreDescription
in classAbstractAuthorityFactory
- Returns:
- The description of the underlying backing store, or
null
. - Throws:
FactoryException
- if a failure occured while fetching the engine description.
-
getAuthorityCodes
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) throws FactoryException Returns the set of authority codes of the given type. Thetype
argument specify the base class.- Specified by:
getAuthorityCodes
in interfaceAuthorityFactory
- Parameters:
type
- The spatial reference objects type.- 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 NoSuchAuthorityCodeException, FactoryException Gets a description of the object corresponding to a code.- Specified by:
getDescriptionText
in interfaceAuthorityFactory
- 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
Returns an arbitrary object from a code.- Specified by:
createObject
in interfaceAuthorityFactory
- Overrides:
createObject
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The object for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createDatum
Returns an arbitrary datum from a code.- Overrides:
createDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEngineeringDatum
Returns an engineering datum from a code.- Overrides:
createEngineeringDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createImageDatum
Returns an image datum from a code.- Overrides:
createImageDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createVerticalDatum
Returns a vertical datum from a code.- Overrides:
createVerticalDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createTemporalDatum
Returns a temporal datum from a code.- Overrides:
createTemporalDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createGeodeticDatum
Returns a geodetic datum from a code.- Overrides:
createGeodeticDatum
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEllipsoid
Returns an ellipsoid from a code.- Overrides:
createEllipsoid
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The ellipsoid for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createPrimeMeridian
Returns a prime meridian from a code.- Overrides:
createPrimeMeridian
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The prime meridian for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createExtent
Returns an extent (usually an area of validity) from a code.- Overrides:
createExtent
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The extent for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createCoordinateSystem
Returns an arbitrary coordinate system from a code.- Overrides:
createCoordinateSystem
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createCartesianCS
Returns a cartesian coordinate system from a code.- Overrides:
createCartesianCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createPolarCS
Returns a polar coordinate system from a code.- Overrides:
createPolarCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createCylindricalCS
Returns a cylindrical coordinate system from a code.- Overrides:
createCylindricalCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createSphericalCS
Returns a spherical coordinate system from a code.- Overrides:
createSphericalCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createEllipsoidalCS
Returns an ellipsoidal coordinate system from a code.- Overrides:
createEllipsoidalCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createVerticalCS
Returns a vertical coordinate system from a code.- Overrides:
createVerticalCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createTimeCS
Returns a temporal coordinate system from a code.- Overrides:
createTimeCS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createCoordinateSystemAxis
Returns a coordinate system axis from a code.- Overrides:
createCoordinateSystemAxis
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The axis for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createUnit
Returns an unit from a code.- Overrides:
createUnit
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The unit for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createCoordinateReferenceSystem
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException Returns an arbitrary coordinate reference system from a code.- Overrides:
createCoordinateReferenceSystem
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
AbstractAuthorityFactory.createGeographicCRS(java.lang.String)
AbstractAuthorityFactory.createProjectedCRS(java.lang.String)
AbstractAuthorityFactory.createVerticalCRS(java.lang.String)
AbstractAuthorityFactory.createTemporalCRS(java.lang.String)
AbstractAuthorityFactory.createCompoundCRS(java.lang.String)
-
createCompoundCRS
Returns a 3D coordinate reference system from a code.- Overrides:
createCompoundCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createDerivedCRS
Returns a derived coordinate reference system from a code.- Overrides:
createDerivedCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createEngineeringCRS
Returns an engineering coordinate reference system from a code.- Overrides:
createEngineeringCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createGeographicCRS
Returns a geographic coordinate reference system from a code.- Overrides:
createGeographicCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createGeocentricCRS
Returns a geocentric coordinate reference system from a code.- Overrides:
createGeocentricCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createImageCRS
Returns an image coordinate reference system from a code.- Overrides:
createImageCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.
-
createProjectedCRS
Returns a projected coordinate reference system from a code.- Overrides:
createProjectedCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createTemporalCRS
Returns a temporal coordinate reference system from a code.- Overrides:
createTemporalCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createVerticalCRS
Returns a vertical coordinate reference system from a code.- Overrides:
createVerticalCRS
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createParameterDescriptor
Returns a parameter descriptor from a code.- Overrides:
createParameterDescriptor
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- Since:
- 2.2
-
createOperationMethod
Returns an operation method from a code.- Overrides:
createOperationMethod
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The operation method for the given code.
- Throws:
FactoryException
- if the object creation failed.- Since:
- 2.2
-
createCoordinateOperation
Returns an operation from a single operation code.- Overrides:
createCoordinateOperation
in classAbstractAuthorityFactory
- Parameters:
code
- Value allocated by authority.- Returns:
- The operation for the given code.
- Throws:
FactoryException
- if the object creation failed.- Since:
- 2.2
-
createFromCoordinateReferenceSystemCodes
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS, String targetCRS) throws FactoryException Returns an operation from coordinate reference system codes.- Overrides:
createFromCoordinateReferenceSystemCodes
in classAbstractAuthorityFactory
- Parameters:
sourceCRS
- Coded value of source coordinate reference system.targetCRS
- Coded value of target coordinate reference system.- Returns:
- The operations from
sourceCRS
totargetCRS
. - Throws:
FactoryException
- if the object creation failed.- Since:
- 2.2
-
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 lookup to the underlying backing store and caches the result.- Overrides:
getIdentifiedObjectFinder
in classAbstractAuthorityFactory
- 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 finder can not be created.- Since:
- 2.4
-
dispose
Releases resources immediately instead of waiting for the garbage collector.- Overrides:
dispose
in classAbstractAuthorityFactory
- Throws:
FactoryException
- if an error occured while disposing the factory.
-