org.geotools.referencing.factory
Class CachedCRSAuthorityDecorator

java.lang.Object
  extended by org.geotools.factory.AbstractFactory
      extended by org.geotools.referencing.factory.ReferencingFactory
          extended by org.geotools.referencing.factory.AbstractAuthorityFactory
              extended by org.geotools.referencing.factory.CachedCRSAuthorityDecorator
All Implemented Interfaces:
javax.imageio.spi.RegisterableService, BufferedFactory, Factory, org.opengis.referencing.AuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory

public final class CachedCRSAuthorityDecorator
extends AbstractAuthorityFactory
implements org.opengis.referencing.AuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory, BufferedFactory

An authority factory that caches all objects created by the delegate CRSAuthorityFactory.

The behaviour of the 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.

Since:
2.4
Version:
$Id: BufferedAuthorityDecorator.java 26038 2007-06-27 01:58:12Z jgarnett $
Author:
Jody Garnett

Field Summary
 
Fields inherited from class org.geotools.referencing.factory.ReferencingFactory
LOGGER
 
Fields inherited from class org.geotools.factory.AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
  CachedCRSAuthorityDecorator(org.opengis.referencing.crs.CRSAuthorityFactory factory)
          Constructs an instance wrapping the specified factory with a default cache.
protected CachedCRSAuthorityDecorator(org.opengis.referencing.crs.CRSAuthorityFactory factory, ObjectCache cache)
          Constructs an instance wrapping the specified factory.
 
Method Summary
protected static ObjectCache createCache(Hints hints)
          Utility method used to produce cache based on hint
 org.opengis.referencing.crs.CompoundCRS createCompoundCRS(java.lang.String code)
          Creates a 3D coordinate reference system from a code.
 org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(java.lang.String code)
          Returns an arbitrary coordinate reference system from a code.
 org.opengis.referencing.crs.DerivedCRS createDerivedCRS(java.lang.String code)
          Creates a derived coordinate reference system from a code.
 org.opengis.referencing.crs.EngineeringCRS createEngineeringCRS(java.lang.String code)
          Creates a engineering coordinate reference system from a code.
 org.opengis.referencing.crs.GeocentricCRS createGeocentricCRS(java.lang.String code)
          Returns a geocentric coordinate reference system from a code.
 org.opengis.referencing.crs.GeographicCRS createGeographicCRS(java.lang.String code)
          Returns a geographic coordinate reference system from a code.
 org.opengis.referencing.crs.ImageCRS createImageCRS(java.lang.String code)
          Creates a image coordinate reference system from a code.
 org.opengis.referencing.IdentifiedObject createObject(java.lang.String code)
          Returns an arbitrary object from a code.
 org.opengis.referencing.crs.ProjectedCRS createProjectedCRS(java.lang.String code)
          Returns a projected coordinate reference system from a code.
 org.opengis.referencing.crs.TemporalCRS createTemporalCRS(java.lang.String code)
          Creates a temporal coordinate reference system from a code.
 org.opengis.referencing.crs.VerticalCRS createVerticalCRS(java.lang.String code)
          Creates a vertical coordinate reference system from a code.
 void dispose()
          Releases resources immediately instead of waiting for the garbage collector.
 org.opengis.metadata.citation.Citation getAuthority()
          Returns the organization or party responsible for definition and maintenance of the database.
 java.util.Set getAuthorityCodes(java.lang.Class type)
           
 java.lang.String getBackingStoreDescription()
          Returns a description of the underlying backing store, or null if unknown.
 org.opengis.util.InternationalString getDescriptionText(java.lang.String code)
           
 IdentifiedObjectFinder getIdentifiedObjectFinder(java.lang.Class type)
          Returns a finder which can be used for looking up unidentified objects.
protected  java.lang.String toKey(java.lang.String code)
           
 
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
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
 
Methods inherited from class org.geotools.referencing.factory.ReferencingFactory
ensureNonNull, getVendor
 
Methods inherited from class org.geotools.factory.AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.referencing.Factory
getVendor
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 

Constructor Detail

CachedCRSAuthorityDecorator

public CachedCRSAuthorityDecorator(org.opengis.referencing.crs.CRSAuthorityFactory factory)
Constructs an instance wrapping the specified factory with a default cache.

The provided authority factory must implement DatumAuthorityFactory, CSAuthorityFactory, CRSAuthorityFactory and CoordinateOperationAuthorityFactory .

Parameters:
factory - The factory to cache. Can not be null.

CachedCRSAuthorityDecorator

protected CachedCRSAuthorityDecorator(org.opengis.referencing.crs.CRSAuthorityFactory factory,
                                      ObjectCache cache)
Constructs an instance wrapping the specified factory. The 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.

Parameters:
factory - The factory to cache. Can not be null.
maxStrongReferences - The maximum number of objects to keep by strong reference.
Method Detail

createCache

protected static ObjectCache createCache(Hints hints)
                                  throws FactoryRegistryException
Utility method used to produce cache based on hint

Throws:
FactoryRegistryException

toKey

protected java.lang.String toKey(java.lang.String code)

createObject

public org.opengis.referencing.IdentifiedObject createObject(java.lang.String code)
                                                      throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an arbitrary object from a code. The returned object will typically be an instance of 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.

Specified by:
createObject in interface org.opengis.referencing.AuthorityFactory
Overrides:
createObject in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createCoordinateReferenceSystem(java.lang.String), AbstractAuthorityFactory.createDatum(java.lang.String), AbstractAuthorityFactory.createEllipsoid(java.lang.String), AbstractAuthorityFactory.createUnit(java.lang.String)

getAuthority

public org.opengis.metadata.citation.Citation getAuthority()
Description copied from class: AbstractAuthorityFactory
Returns the organization or party responsible for definition and maintenance of the database.

Specified by:
getAuthority in interface org.opengis.referencing.AuthorityFactory
Specified by:
getAuthority in class AbstractAuthorityFactory

getAuthorityCodes

public java.util.Set getAuthorityCodes(java.lang.Class type)
                                throws org.opengis.referencing.FactoryException
Specified by:
getAuthorityCodes in interface org.opengis.referencing.AuthorityFactory
Throws:
org.opengis.referencing.FactoryException

getDescriptionText

public org.opengis.util.InternationalString getDescriptionText(java.lang.String code)
                                                        throws org.opengis.referencing.FactoryException
Specified by:
getDescriptionText in interface org.opengis.referencing.AuthorityFactory
Throws:
org.opengis.referencing.FactoryException

createCompoundCRS

public org.opengis.referencing.crs.CompoundCRS createCompoundCRS(java.lang.String code)
                                                          throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a 3D coordinate reference system from a code.

Specified by:
createCompoundCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createCompoundCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.

createCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(java.lang.String code)
                                                                                      throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an arbitrary coordinate reference system from a code. If the coordinate reference system type is know at compile time, it is recommended to invoke the most precise method instead of this one (for example  createGeographicCRS(code)  instead of  createCoordinateReferenceSystem(code)  if the caller know he is asking for a geographic coordinate reference system).

Specified by:
createCoordinateReferenceSystem in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createCoordinateReferenceSystem in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
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)

createDerivedCRS

public org.opengis.referencing.crs.DerivedCRS createDerivedCRS(java.lang.String code)
                                                        throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a derived coordinate reference system from a code.

Specified by:
createDerivedCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createDerivedCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.

createEngineeringCRS

public org.opengis.referencing.crs.EngineeringCRS createEngineeringCRS(java.lang.String code)
                                                                throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a engineering coordinate reference system from a code.

Specified by:
createEngineeringCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createEngineeringCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.

createGeocentricCRS

public org.opengis.referencing.crs.GeocentricCRS createGeocentricCRS(java.lang.String code)
                                                              throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a geocentric coordinate reference system from a code.

Specified by:
createGeocentricCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createGeocentricCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createGeographicCRS

public org.opengis.referencing.crs.GeographicCRS createGeographicCRS(java.lang.String code)
                                                              throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a geographic coordinate reference system from a code.

Specified by:
createGeographicCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createGeographicCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createImageCRS

public org.opengis.referencing.crs.ImageCRS createImageCRS(java.lang.String code)
                                                    throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a image coordinate reference system from a code.

Specified by:
createImageCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createImageCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.

createProjectedCRS

public org.opengis.referencing.crs.ProjectedCRS createProjectedCRS(java.lang.String code)
                                                            throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a projected coordinate reference system from a code.

Specified by:
createProjectedCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createProjectedCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createTemporalCRS

public org.opengis.referencing.crs.TemporalCRS createTemporalCRS(java.lang.String code)
                                                          throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a temporal coordinate reference system from a code.

Specified by:
createTemporalCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createTemporalCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createTemporalDatum(java.lang.String)

createVerticalCRS

public org.opengis.referencing.crs.VerticalCRS createVerticalCRS(java.lang.String code)
                                                          throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a vertical coordinate reference system from a code.

Specified by:
createVerticalCRS in interface org.opengis.referencing.crs.CRSAuthorityFactory
Overrides:
createVerticalCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
org.opengis.referencing.FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createVerticalDatum(java.lang.String)

dispose

public void dispose()
             throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Releases resources immediately instead of waiting for the garbage collector. Once a factory has been disposed, further create(...) invocations may throw a FactoryException. Disposing a previously-disposed factory, however, has no effect.

Overrides:
dispose in class AbstractAuthorityFactory
Throws:
org.opengis.referencing.FactoryException - if an error occured while disposing the factory.

getBackingStoreDescription

public java.lang.String getBackingStoreDescription()
                                            throws org.opengis.referencing.FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a description of the underlying backing store, or null if unknown. This is for example the database software used for storing the data. The default implementation returns always null.

Overrides:
getBackingStoreDescription in class AbstractAuthorityFactory
Returns:
The description of the underlying backing store, or null.
Throws:
org.opengis.referencing.FactoryException - if a failure occurs while fetching the engine description.

getIdentifiedObjectFinder

public IdentifiedObjectFinder getIdentifiedObjectFinder(java.lang.Class type)
                                                 throws org.opengis.referencing.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 class AbstractAuthorityFactory
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:
org.opengis.referencing.FactoryException - if the finder can not be created.
Since:
2.4


Copyright © 1996-2010 Geotools. All Rights Reserved.