public final class CachedCRSAuthorityDecorator extends AbstractAuthorityFactory implements AuthorityFactory, CRSAuthorityFactory, BufferedFactory
createFoo(String)
methods first looks if a previously created object
exists for the given code. If such an object exists, it is returned directly. The testing of the
cache is synchronized and may block if the referencing object is under construction.
If the object is not yet created, the definition is delegated to the appropriate the AuthorityFactory authority factory and the result is cached for next time.
This object is responsible for owning a {{ReferencingObjectCache}}; there are several implementations to choose from on construction.
LOGGER
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
Modifier | Constructor and Description |
---|---|
|
CachedCRSAuthorityDecorator(CRSAuthorityFactory factory)
Constructs an instance wrapping the specified factory with a default cache.
|
protected |
CachedCRSAuthorityDecorator(CRSAuthorityFactory factory,
ObjectCache<Object,Object> cache)
Constructs an instance wrapping the specified factory.
|
Modifier and Type | Method and Description |
---|---|
protected static <K,V> ObjectCache<K,V> |
createCache(Hints hints)
Utility method used to produce cache based on hint
|
CompoundCRS |
createCompoundCRS(String code)
Creates a 3D coordinate reference system from a code.
|
CoordinateReferenceSystem |
createCoordinateReferenceSystem(String code)
Returns an arbitrary coordinate reference system from
a code.
|
DerivedCRS |
createDerivedCRS(String code)
Creates a derived coordinate reference system from a code.
|
EngineeringCRS |
createEngineeringCRS(String code)
Creates a engineering coordinate reference system from a code.
|
GeocentricCRS |
createGeocentricCRS(String code)
Returns a geocentric coordinate reference system 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.
|
IdentifiedObject |
createObject(String code)
Returns an arbitrary object from a code.
|
ProjectedCRS |
createProjectedCRS(String code)
Returns a projected coordinate reference system from a code.
|
TemporalCRS |
createTemporalCRS(String code)
Creates a temporal coordinate reference system from a code.
|
VerticalCRS |
createVerticalCRS(String code)
Creates a vertical coordinate reference system from a code.
|
void |
dispose()
Releases resources immediately instead of waiting for the garbage collector.
|
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.
|
String |
getBackingStoreDescription()
Returns a description of the underlying backing store, or
null if unknown. |
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 String |
toKey(String code) |
createCartesianCS, createCoordinateOperation, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createEllipsoid, createEllipsoidalCS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeodeticDatum, createImageDatum, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createSphericalCS, createTemporalDatum, createTimeCS, createUnit, createVerticalCS, createVerticalDatum, noSuchAuthorityCode, trimAuthority
ensureNonNull, getVendor
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
getImplementationHints
public CachedCRSAuthorityDecorator(CRSAuthorityFactory factory)
The provided authority factory must implement DatumAuthorityFactory
, CSAuthorityFactory
, CRSAuthorityFactory
and CoordinateOperationAuthorityFactory
.
factory
- The factory to cache. Can not be null
.protected CachedCRSAuthorityDecorator(CRSAuthorityFactory factory, ObjectCache<Object,Object> cache)
maxStrongReferences
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
SearchableAuthorityFactory
and CoordinateOperationAuthorityFactory
interfaces they
choose to implement.
factory
- The factory to cache. Can not be null
.cache
- The underlying cacheprotected static <K,V> ObjectCache<K,V> createCache(Hints hints) throws FactoryRegistryException
FactoryRegistryException
public IdentifiedObject createObject(String code) throws FactoryException
AbstractAuthorityFactory
Datum
, CoordinateSystem
, CoordinateReferenceSystem
or CoordinateOperation
. The default implementation always throw an exception. Subclasses should
override this method if they are capable to automatically detect the object type from its
code.createObject
in interface AuthorityFactory
createObject
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.AbstractAuthorityFactory.createCoordinateReferenceSystem(java.lang.String)
,
AbstractAuthorityFactory.createDatum(java.lang.String)
,
AbstractAuthorityFactory.createEllipsoid(java.lang.String)
,
AbstractAuthorityFactory.createUnit(java.lang.String)
public Citation getAuthority()
AbstractAuthorityFactory
getAuthority
in interface AuthorityFactory
getAuthority
in class AbstractAuthorityFactory
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) throws FactoryException
AuthorityFactory
type
argument specify the
base class. For example if this factory is an instance of CRSAuthorityFactory
, then:
CoordinateReferenceSystem.class
asks for all authority codes accepted by one of createGeographicCRS
, createProjectedCRS
,
createVerticalCRS
, createTemporalCRS
and their friends.
ProjectedCRS.class
asks only for authority codes accepted by createProjectedCRS
.
getAuthorityCodes
in interface AuthorityFactory
type
- The spatial reference objects type.FactoryException
- if access to the underlying database failed.public InternationalString getDescriptionText(String code) throws FactoryException
AuthorityFactory
getDescriptionText
in interface AuthorityFactory
code
- Value allocated by authority.null
if the object corresponding to the
specified code
has no description.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the query failed for some other reason.public CompoundCRS createCompoundCRS(String code) throws FactoryException
AbstractAuthorityFactory
createCompoundCRS
in interface CRSAuthorityFactory
createCompoundCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException
AbstractAuthorityFactory
createGeographicCRS(code)
instead of
createCoordinateReferenceSystem(code)
if the caller know he is
asking for a geographic coordinate reference system).createCoordinateReferenceSystem
in interface CRSAuthorityFactory
createCoordinateReferenceSystem
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.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)
public DerivedCRS createDerivedCRS(String code) throws FactoryException
AbstractAuthorityFactory
createDerivedCRS
in interface CRSAuthorityFactory
createDerivedCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.public EngineeringCRS createEngineeringCRS(String code) throws FactoryException
AbstractAuthorityFactory
createEngineeringCRS
in interface CRSAuthorityFactory
createEngineeringCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.public GeocentricCRS createGeocentricCRS(String code) throws FactoryException
AbstractAuthorityFactory
createGeocentricCRS
in interface CRSAuthorityFactory
createGeocentricCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
public GeographicCRS createGeographicCRS(String code) throws FactoryException
AbstractAuthorityFactory
createGeographicCRS
in interface CRSAuthorityFactory
createGeographicCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
public ImageCRS createImageCRS(String code) throws FactoryException
AbstractAuthorityFactory
createImageCRS
in interface CRSAuthorityFactory
createImageCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.public ProjectedCRS createProjectedCRS(String code) throws FactoryException
AbstractAuthorityFactory
createProjectedCRS
in interface CRSAuthorityFactory
createProjectedCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
public TemporalCRS createTemporalCRS(String code) throws FactoryException
AbstractAuthorityFactory
createTemporalCRS
in interface CRSAuthorityFactory
createTemporalCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.AbstractAuthorityFactory.createTemporalDatum(java.lang.String)
public VerticalCRS createVerticalCRS(String code) throws FactoryException
AbstractAuthorityFactory
createVerticalCRS
in interface CRSAuthorityFactory
createVerticalCRS
in class AbstractAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.AbstractAuthorityFactory.createVerticalDatum(java.lang.String)
public void dispose() throws FactoryException
AbstractAuthorityFactory
create(...)
invocations may throw a FactoryException
. Disposing a previously-disposed factory, however, has no effect.dispose
in class AbstractAuthorityFactory
FactoryException
- if an error occured while disposing the factory.public String getBackingStoreDescription() throws FactoryException
AbstractAuthorityFactory
null
if unknown. This is
for example the database software used for storing the data. The default implementation
returns always null
.getBackingStoreDescription
in class AbstractAuthorityFactory
null
.FactoryException
- if a failure occurs while fetching the engine description.public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) throws FactoryException
getIdentifiedObjectFinder
in class AbstractAuthorityFactory
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.FactoryException
- if the finder can not be created.Copyright © 1996–2021 Geotools. All rights reserved.