org.geotoolkit.referencing.factory.epsg
Class AnsiDialectEpsgFactory

Object
  extended by Factory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by DirectAuthorityFactory
                  extended by DirectEpsgFactory
                      extended by AnsiDialectEpsgFactory
All Implemented Interfaces:
AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Factory

@ThreadSafe
public class AnsiDialectEpsgFactory
extends DirectEpsgFactory

An EPSG factory for the database generated by ANSI-compatible SQL scripts. This class overrides adaptSQL(String) in order to translate SQL statements from MS-Access dialect to ANSI dialect. By default, the translated SQL statements use the table and field names in the Data Description Language (DDL) scripts provided by EPSG to create the schema for the database. Subclasses can changes this default behavior by modifying the toANSI content in their constructor.

Since:
2.0
Version:
3.05
Author:
Rueben Schulz (UBC), Martin Desruisseaux (IRD), Didier Richard (IGN), John Grange
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
protected  Map<String,String> toANSI
          Maps the MS-Access names to ANSI names.
 
Fields inherited from class DirectEpsgFactory
connection
 
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
AnsiDialectEpsgFactory(Hints userHints, Connection connection)
          Creates a factory using the given connection.
 
Method Summary
protected  String adaptSQL(String statement)
          Modifies the given SQL string to be suitable for non MS-Access databases.
protected  void setSchema(String schema, boolean removePrefix)
          Sets the schema where to search for the tables, and optionally removes the "epsg_" prefix.
protected  void useOriginalTableNames()
          Replaces the table names by the ones originally used in the MS-Access database.
 
Methods inherited from class DirectEpsgFactory
createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createDatum, createEllipsoid, createExtent, createFromCoordinateReferenceSystemCodes, createObject, createOperationMethod, createParameterDescriptor, createPrimeMeridian, createUnit, dispose, finalize, getAuthority, getAuthorityCodes, getBackingStoreDescription, getDescriptionText, getIdentifiedObjectFinder, getImplementationHints, isPrimaryKey
 
Methods inherited from class AbstractAuthorityFactory
createCartesianCS, createCompoundCRS, createCylindricalCS, createDerivedCRS, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createPolarCS, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createVerticalCRS, createVerticalCS, createVerticalDatum, noSuchAuthorityCode, trimAuthority
 
Methods inherited from class ReferencingFactory
ensureNonNull, getVendor
 
Methods inherited from class Factory
availability, equals, hasCompatibleHints, hashCode, setOrdering, toString
 
Methods inherited from class Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface CRSAuthorityFactory
createCompoundCRS, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
 
Methods inherited from interface CSAuthorityFactory
createCartesianCS, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createVerticalCS
 
Methods inherited from interface DatumAuthorityFactory
createEngineeringDatum, createGeodeticDatum, createImageDatum, createTemporalDatum, createVerticalDatum
 
Methods inherited from interface Factory
getVendor
 

Field Detail

toANSI

protected final Map<String,String> toANSI
Maps the MS-Access names to ANSI names. Keys are MS-Access names including bracket. Values are ANSI names. Keys and values are case-sensitive. The default content of this map is:
MS-Access name ANSI name
[Alias]  epsg_alias
[Area]  epsg_area
[Coordinate Axis]  epsg_coordinateaxis
[Coordinate Axis Name]  epsg_coordinateaxisname
[Coordinate_Operation]  epsg_coordoperation
[Coordinate_Operation Method]  epsg_coordoperationmethod
[Coordinate_Operation Parameter]  epsg_coordoperationparam
[Coordinate_Operation Parameter Usage]  epsg_coordoperationparamusage
[Coordinate_Operation Parameter Value]  epsg_coordoperationparamvalue
[Coordinate_Operation Path]  epsg_coordoperationpath
[Coordinate Reference System]  epsg_coordinatereferencesystem
[Coordinate System]  epsg_coordinatesystem
[Datum]  epsg_datum
[Naming System]  epsg_namingsystem
[Ellipsoid]  epsg_ellipsoid
[Prime Meridian]  epsg_primemeridian
[Supersession]  epsg_supersession
[Unit of Measure]  epsg_unitofmeasure
[ORDER]  coord_axis_order
Subclasses can modify this map in their constructor in order to provide a different mapping.

Constructor Detail

AnsiDialectEpsgFactory

public AnsiDialectEpsgFactory(Hints userHints,
                              Connection connection)
Creates a factory using the given connection. The connection is closed when this factory is disposed.

Note: we recommend to avoid keeping the connection open for a long time. An easy way to get the connection created only when first needed and closed automatically after a short timeout is to instantiate this AnsiDialectEpsgFactory class only in a ThreadedAuthorityFactory. This approach also gives concurrency and caching services in bonus.

Parameters:
userHints - The underlying factories used for objects creation, or null for the default ones.
connection - The connection to the underlying EPSG database.
Method Detail

setSchema

protected void setSchema(String schema,
                         boolean removePrefix)
                  throws SQLException
Sets the schema where to search for the tables, and optionally removes the "epsg_" prefix. Those two operations (setting a schema and removing the prefix) are proposed together because the prefix is redundant with the schema.

This method inserts "schema." in front of every table names, where schema is the value provided in argument. The "epsg_" prefix is removed from the table names only if removePrefix is true.

This method can be invoked at most once, at construction time only.

Parameters:
schema - The database schema in which the EPSG tables are stored.
removePrefix - true if the "epsg_" prefix should be removed from the table names.
Throws:
SQLException - If the schema can not be set.
Since:
3.05

useOriginalTableNames

protected void useOriginalTableNames()
                              throws SQLException
Replaces the table names by the ones originally used in the MS-Access database. The new names are quoted in order to allow the usage of space and mixed-case characters. For example this method replaces the epsg_coordinatereferencesystem table name by "Coordinate Reference System" (including the quotes).

If a schema has been previously set by a call to setSchema, it will be preserved. It is better to set the schema (if desired) before to invoke this method.

This method can be invoked at most once, at construction time only.

Throws:
SQLException - If the name of the tables to query can not be changed.
Since:
3.05

adaptSQL

protected String adaptSQL(String statement)
Modifies the given SQL string to be suitable for non MS-Access databases. This replaces table and field names in the SQL with the new names in the SQL DDL scripts provided with EPSG database.

Overrides:
adaptSQL in class DirectEpsgFactory
Parameters:
statement - The statement in MS-Access syntax.
Returns:
The SQL statement in ANSI syntax.


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