org.geotoolkit.referencing.factory.wkt
Class PropertyAuthorityFactory

Object
  extended by Factory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by DirectAuthorityFactory
                  extended by WKTParsingAuthorityFactory
                      extended by PropertyAuthorityFactory
All Implemented Interfaces:
AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, Factory
Direct Known Subclasses:
PropertyEpsgFactory

@ThreadSafe
public class PropertyAuthorityFactory
extends WKTParsingAuthorityFactory
implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory

A CRS Authority Factory that manages object creation using a set of static strings from a property file. This gives some of the benificts of using the EPSG database in a portable property file (which must be provided by the users), or add new authorities. See PropertyEpsgFactory for a subclass specialized for the EPSG authority.

This factory doesn't cache any result. Any call to a createFoo method will trig a new WKT parsing. For adding caching service, this factory needs to be wrapped in CachingAuthorityFactory. The AuthorityFactoryProvider convenience class can be used for that purpose.

Since:
3.10 (derived from 2.1)
Version:
3.10
Author:
Jody Garnett (Refractions), Rueben Schulz (UBC), Martin Desruisseaux (IRD, Geomatys)
Module:
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 DirectAuthorityFactory
factories
 
Fields inherited from class AbstractAuthorityFactory
nameFactory
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class Factory
EMPTY_HINTS, hints
 
Constructor Summary
protected PropertyAuthorityFactory(Hints userHints, Citation... authorities)
          Creates an initially empty factory.
  PropertyAuthorityFactory(Hints userHints, Collection<URL> definitionFiles, Citation... authorities)
          Creates a factory for the specified authorities using the definitions declared in the given property files.
  PropertyAuthorityFactory(Hints userHints, Hints.FileKey directoryKey, Class<?> resourceLoader, String filename, Citation... authorities)
          Creates a factory using the definitions found in properties files loaded from a directory and resources.
  PropertyAuthorityFactory(Hints userHints, URL definitionFile, Citation... authorities)
          Creates a factory for the specified authorities using the definitions declared in the given property file.
 
Method Summary
protected  void dispose(boolean shutdown)
          Disposes the resources used by this factory.
protected  void load(Collection<URL> definitionFiles)
          Loads the WKT strings from the given property files.
 
Methods inherited from class WKTParsingAuthorityFactory
availability, createCoordinateReferenceSystem, createObject, getAuthority, getAuthorityCodes, getDescriptionText, getIdentifiedObjectFinder, trimAuthority
 
Methods inherited from class DirectAuthorityFactory
getImplementationHints
 
Methods inherited from class AbstractAuthorityFactory
createCartesianCS, createCompoundCRS, createCoordinateOperation, 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, getBackingStoreDescription, noSuchAuthorityCode
 
Methods inherited from class ReferencingFactory
ensureNonNull, getVendor
 
Methods inherited from class Factory
equals, hasCompatibleHints, hashCode, setOrdering, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
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 AuthorityFactory
createObject, getAuthority, getAuthorityCodes, getDescriptionText
 
Methods inherited from interface Factory
getVendor
 

Constructor Detail

PropertyAuthorityFactory

public PropertyAuthorityFactory(Hints userHints,
                                URL definitionFile,
                                Citation... authorities)
                         throws IOException
Creates a factory for the specified authorities using the definitions declared in the given property file. There is usually only one authority, but more can be given when the objects to create should have more than one identifier, each with the same code but different namespace. See WKTParsingAuthorityFactory for more details.

Parameters:
userHints - An optional set of hints, or null for the default ones.
definitionFile - URL to the definition file. This is typically a value returned by Class.getResource(String).
authorities - The organizations or parties responsible for definition and maintenance of the database.
Throws:
IOException - If the definitions can't be read.
Since:
3.00

PropertyAuthorityFactory

public PropertyAuthorityFactory(Hints userHints,
                                Collection<URL> definitionFiles,
                                Citation... authorities)
                         throws IOException
Creates a factory for the specified authorities using the definitions declared in the given property files. There is usually only one file, but more are allowed. If there is more than one file, their content will be merged. If the same key appears in more than one file, the first occurrence is used. This is consistent with the usual rule saying that the first item in a class-path has precedence.

Parameters:
userHints - An optional set of hints, or null for the default ones.
definitionFiles - URL to the definition file(s). This is typically built from the values returned by ClassLoader.getResources(String).
authorities - The organizations or parties responsible for definition and maintenance of the database.
Throws:
IOException - If the definitions can't be read.
Since:
3.00

PropertyAuthorityFactory

public PropertyAuthorityFactory(Hints userHints,
                                Hints.FileKey directoryKey,
                                Class<?> resourceLoader,
                                String filename,
                                Citation... authorities)
                         throws IOException
Creates a factory using the definitions found in properties files loaded from a directory and resources. The directory and the resources are both optional - one or both of them can be omitted if the corresponding argument (directoryKey or resourceLoader) is null. If they are non-null, then they are used as below:
  1. The file directory is specified as a hint stored under the directoryKey. That key is usually Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, but other keys are allowed. If a value exists for that key and a file having the given filename exists in that directory, then it is loaded.

  2. The resource directory (which may be a directory in a JAR file) is specified as a class given by the resourceLoader argument. The resources are found in the same way than Class.getResource(String) - with filename as the string argument - except that more than one URLs will be obtained if possible.

If definitions are found for the same keys in both cases, then the definitions found in step 1 have precedence over the definitios found in case 2.

Parameters:
userHints - An optional set of hints, or null for the default ones.
directoryKey - The key under which a directory may be stored in the hints map, or null if none. If non-null, this value is typically Hints.CRS_AUTHORITY_EXTRA_DIRECTORY.
resourceLoader - The class to use for loading resources, or null if none. If non-null, the class package determine the directory (potentially in a JAR file) where to look for the resources, in the way documented at Class.getResource(String).
filename - The name of the file to look in the directory if directoryKey is non-null, or the name of the resources to load if resourceLoader is non-null.
authorities - The organizations or parties responsible for definition and maintenance of the database.
Throws:
IOException - If the definitions can't be read.
Since:
3.00

PropertyAuthorityFactory

protected PropertyAuthorityFactory(Hints userHints,
                                   Citation... authorities)
Creates an initially empty factory. This constructors is reserved for subclasses constructors only. Subclasses must invoke load(Collection) in their constructor in order to populate the factory before it is used.

Parameters:
userHints - An optional set of hints, or null for the default ones.
authorities - The organizations or parties responsible for definition and maintenance of the database.
Since:
3.00
Method Detail

load

protected void load(Collection<URL> definitionFiles)
             throws IOException
Loads the WKT strings from the given property files. This method should be invoked from constructors only. Changes after construction are not allowed.

Parameters:
definitionFiles - URL to the definition file(s). This is typically built from the values returned by ClassLoader.getResources(String).
Throws:
IOException - If the definition files can't be read.
Since:
3.00

dispose

protected void dispose(boolean shutdown)
Disposes the resources used by this factory.

Overrides:
dispose in class WKTParsingAuthorityFactory
Parameters:
shutdown - false for normal disposal, or true if this method is invoked during the process of a JVM shutdown.


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.