|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFactory
ReferencingFactory
AbstractAuthorityFactory
CachingAuthorityFactory
@Buffered @ThreadSafe @Decorator(value=AbstractAuthorityFactory.class) public class CachingAuthorityFactory
An authority factory that caches all objects created by an other factory. All
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 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 caching factory will continue to returns them as long as they are in use somewhere else in the Java virtual machine, but will be discarded (and recreated on the fly if needed) otherwise.
| referencing/geotk-referencing (download) | View source code for this class |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class Factory |
|---|
Factory.Availability, Factory.Organizer |
| Field Summary |
|---|
| Fields inherited from class AbstractAuthorityFactory |
|---|
nameFactory |
| Fields inherited from class ReferencingFactory |
|---|
LOGGER |
| Fields inherited from class Factory |
|---|
EMPTY_HINTS, hints |
| Constructor Summary | |
|---|---|
protected |
CachingAuthorityFactory(AbstractAuthorityFactory factory)
Constructs an instance wrapping the specified factory with a default number of entries to keep by strong reference. |
protected |
CachingAuthorityFactory(AbstractAuthorityFactory factory,
int maxStrongReferences)
Constructs an instance wrapping the specified factory. |
| Method Summary | |
|---|---|
ConformanceResult |
availability()
Returns whatever this factory is available. |
CartesianCS |
createCartesianCS(String code)
Returns a Cartesian coordinate system from a code. |
CompoundCRS |
createCompoundCRS(String code)
Returns a 3D coordinate reference system from a code. |
CoordinateOperation |
createCoordinateOperation(String code)
Returns 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)
Returns a cylindrical coordinate system from a code. |
Datum |
createDatum(String code)
Returns an arbitrary datum from a code. |
DerivedCRS |
createDerivedCRS(String code)
Returns a derived coordinate reference system from a code. |
Ellipsoid |
createEllipsoid(String code)
Returns an ellipsoid from a code. |
EllipsoidalCS |
createEllipsoidalCS(String code)
Returns an ellipsoidal coordinate system from a code. |
EngineeringCRS |
createEngineeringCRS(String code)
Returns an engineering coordinate reference system from a code. |
EngineeringDatum |
createEngineeringDatum(String code)
Returns an engineering datum from a code. |
Extent |
createExtent(String code)
Returns an extent (usually an area of validity) from a code. |
Set<CoordinateOperation> |
createFromCoordinateReferenceSystemCodes(String sourceCRS,
String targetCRS)
Returns 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)
Returns an image coordinate reference system from a code. |
ImageDatum |
createImageDatum(String code)
Returns an image datum from a code. |
IdentifiedObject |
createObject(String code)
Returns an arbitrary object from a code. |
OperationMethod |
createOperationMethod(String code)
Returns an operation method from a code. |
ParameterDescriptor<?> |
createParameterDescriptor(String code)
Returns a parameter descriptor from a code. |
PolarCS |
createPolarCS(String code)
Returns 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)
Returns a spherical coordinate system from a code. |
TemporalCRS |
createTemporalCRS(String code)
Returns a temporal coordinate reference system from a code. |
TemporalDatum |
createTemporalDatum(String code)
Returns a temporal datum from a code. |
TimeCS |
createTimeCS(String code)
Returns a temporal coordinate system from a code. |
Unit<?> |
createUnit(String code)
Returns an unit from a code. |
VerticalCRS |
createVerticalCRS(String code)
Returns a vertical coordinate reference system from a code. |
VerticalCS |
createVerticalCS(String code)
Returns a vertical coordinate system from a code. |
VerticalDatum |
createVerticalDatum(String code)
Returns a vertical datum from a code. |
protected void |
dispose(boolean shutdown)
Releases resources immediately instead of waiting for the garbage collector. |
Citation |
getAuthority()
Returns the organization or party responsible for definition and maintenance of the underlying 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. |
Citation |
getVendor()
Returns the vendor responsible for creating the underlying factory implementation. |
void |
printCacheContent(PrintWriter out)
Prints the cache content to the standard output stream. |
protected void |
setKeyCollisionAllowed(boolean allowed)
true if different values may be assigned to the same key. |
| Methods inherited from class AbstractAuthorityFactory |
|---|
noSuchAuthorityCode, trimAuthority |
| Methods inherited from class ReferencingFactory |
|---|
ensureNonNull |
| Methods inherited from class Factory |
|---|
equals, getImplementationHints, hasCompatibleHints, hashCode, setOrdering, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected CachingAuthorityFactory(AbstractAuthorityFactory factory)
This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory, CSAuthorityFactory, CRSAuthorityFactory
and CoordinateOperationAuthorityFactory interfaces they choose to implement.
factory - The factory to cache. Can not be null.
protected CachingAuthorityFactory(AbstractAuthorityFactory factory,
int maxStrongReferences)
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 eldest ones are replaced
by weak references.
This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory, CSAuthorityFactory, CRSAuthorityFactory
and CoordinateOperationAuthorityFactory interfaces they choose to implement.
factory - The factory to cache. Can not be null.maxStrongReferences - The maximum number of objects to keep by strong reference.| Method Detail |
|---|
public ConformanceResult availability()
ThreadedAuthorityFactory.createBackingStore() threw an exception.
availability in class Factorypublic Citation getVendor()
getVendor in interface FactorygetVendor in class ReferencingFactoryCitations.GEOTOOLKITpublic Citation getAuthority()
getAuthority in interface AuthorityFactorygetAuthority in class AbstractAuthorityFactory
public String getBackingStoreDescription()
throws FactoryException
null if unknown.
This is for example the database software used for storing the data.
getBackingStoreDescription in class AbstractAuthorityFactorynull.
FactoryException - if a failure occurred while fetching the engine description.
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
throws FactoryException
type
argument specifies the base class.
type - The spatial reference objects type.
FactoryException - if access to the underlying database failed.
public InternationalString getDescriptionText(String code)
throws NoSuchAuthorityCodeException,
FactoryException
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 IdentifiedObject createObject(String code)
throws FactoryException
createObject in interface AuthorityFactorycreateObject in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public Datum createDatum(String code)
throws FactoryException
createDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public EngineeringDatum createEngineeringDatum(String code)
throws FactoryException
createEngineeringDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public ImageDatum createImageDatum(String code)
throws FactoryException
createImageDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public VerticalDatum createVerticalDatum(String code)
throws FactoryException
createVerticalDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public TemporalDatum createTemporalDatum(String code)
throws FactoryException
createTemporalDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public GeodeticDatum createGeodeticDatum(String code)
throws FactoryException
createGeodeticDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public Ellipsoid createEllipsoid(String code)
throws FactoryException
createEllipsoid in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public PrimeMeridian createPrimeMeridian(String code)
throws FactoryException
createPrimeMeridian in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public Extent createExtent(String code)
throws FactoryException
createExtent in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CoordinateSystem createCoordinateSystem(String code)
throws FactoryException
createCoordinateSystem in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CartesianCS createCartesianCS(String code)
throws FactoryException
createCartesianCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public PolarCS createPolarCS(String code)
throws FactoryException
createPolarCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CylindricalCS createCylindricalCS(String code)
throws FactoryException
createCylindricalCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public SphericalCS createSphericalCS(String code)
throws FactoryException
createSphericalCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public EllipsoidalCS createEllipsoidalCS(String code)
throws FactoryException
createEllipsoidalCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public VerticalCS createVerticalCS(String code)
throws FactoryException
createVerticalCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public TimeCS createTimeCS(String code)
throws FactoryException
createTimeCS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CoordinateSystemAxis createCoordinateSystemAxis(String code)
throws FactoryException
createCoordinateSystemAxis in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public Unit<?> createUnit(String code)
throws FactoryException
createUnit in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
throws FactoryException
createCoordinateReferenceSystem in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CompoundCRS createCompoundCRS(String code)
throws FactoryException
createCompoundCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public DerivedCRS createDerivedCRS(String code)
throws FactoryException
createDerivedCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public EngineeringCRS createEngineeringCRS(String code)
throws FactoryException
createEngineeringCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public GeographicCRS createGeographicCRS(String code)
throws FactoryException
createGeographicCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public GeocentricCRS createGeocentricCRS(String code)
throws FactoryException
createGeocentricCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public ImageCRS createImageCRS(String code)
throws FactoryException
createImageCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public ProjectedCRS createProjectedCRS(String code)
throws FactoryException
createProjectedCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public TemporalCRS createTemporalCRS(String code)
throws FactoryException
createTemporalCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public VerticalCRS createVerticalCRS(String code)
throws FactoryException
createVerticalCRS in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public ParameterDescriptor<?> createParameterDescriptor(String code)
throws FactoryException
createParameterDescriptor in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public OperationMethod createOperationMethod(String code)
throws FactoryException
createOperationMethod in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public CoordinateOperation createCoordinateOperation(String code)
throws FactoryException
createCoordinateOperation in class AbstractAuthorityFactorycode - Value allocated by authority.
FactoryException - if the object creation failed.
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS,
String targetCRS)
throws FactoryException
createFromCoordinateReferenceSystemCodes in class AbstractAuthorityFactorysourceCRS - Coded value of source coordinate reference system.targetCRS - Coded value of target coordinate reference system.
sourceCRS to targetCRS.
FactoryException - if the object creation failed.
public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
throws FactoryException
getIdentifiedObjectFinder in class AbstractAuthorityFactorytype - 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 (for example the factories backed
by EPSG databases).
FactoryException - if the finder can not be created.@Debug public void printCacheContent(PrintWriter out)
out - The output printer, or null for the
standard output stream.protected void setKeyCollisionAllowed(boolean allowed)
true if different values may be assigned to the same key. This is usually
an error, so the default Cache behavior is to thrown an exception in such
case. However in some cases we may want to relax this check. For example the EPSG
database sometime assign the same key to different kind of objects.
This property can also be set in order to allow some recursivity. If during the creation of
an object, the program asks to this CachingAuthorityFactory for the same object
(using the same key), then the default CachingAuthorityFactory implementation will
consider this situation as a key collision unless this property has been set to true.
allowed - true if key collisions are allowed.Cache.setKeyCollisionAllowed(boolean)protected void dispose(boolean shutdown)
dispose in class AbstractAuthorityFactoryshutdown - false for normal disposal, or true if
this method is invoked during the process of a JVM shutdown.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||