|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFactoryFinder
ReferencingFactoryFinder
public final class ReferencingFactoryFinder
Defines static methods used to access the application's default factory implementation.
To declare a factory implementation, a services subdirectory is placed within the
META-INF
directory that is present in every JAR file. This directory
contains a file for each factory interface that has one or more implementation classes
present in the JAR file. For example, if the JAR file contained a class named
com.mycompany.DatumFactoryImpl
which implements the DatumFactory
interface, the JAR file would contain a file named:
META-INF/services/org.opengis.referencing.datum.DatumFactory
containing the line:
com.mycompany.DatumFactoryImpl
If the factory classes implements RegisterableService
, it will
be notified upon registration and deregistration. Note that the factory classes should be
lightweight and quick to load. Implementations of these interfaces should avoid complex
dependencies on other classes and on native code. The usual pattern for more complex services
is to register a lightweight proxy for the heavyweight service.
This class is thread-safe. However, calls to any setAuthorityOrdering(java.lang.String, java.lang.String)
or
setVendorOrdering(java.lang.String, java.lang.String)
methods have a system-wide effect. If two threads or two
applications need a different ordering, they shall manage their own instance of
FactoryRegistry
. This FactoryFinder
class is simply a convenience
wrapper around a FactoryRegistry
instance.
modules/library/referencing (gt-referencing.jar)
Field Summary |
---|
Fields inherited from class FactoryFinder |
---|
EMPTY_HINTS |
Method Summary | |
---|---|
static void |
addAuthorityFactory(AuthorityFactory authority)
Programmatic management of authority factories. |
static Set<String> |
getAuthorityNames()
Returns the names of all currently registered authorities. |
static Set<CoordinateOperationAuthorityFactory> |
getCoordinateOperationAuthorityFactories(Hints hints)
Returns a set of all available implementations for the CoordinateOperationAuthorityFactory interface. |
static CoordinateOperationAuthorityFactory |
getCoordinateOperationAuthorityFactory(String authority,
Hints hints)
Returns the first implementation of CoordinateOperationAuthorityFactory matching
the specified hints. |
static Set<CoordinateOperationFactory> |
getCoordinateOperationFactories(Hints hints)
Returns a set of all available implementations for the CoordinateOperationFactory interface. |
static CoordinateOperationFactory |
getCoordinateOperationFactory(Hints hints)
Returns the first implementation of CoordinateOperationFactory matching the specified
hints. |
static Set<CRSAuthorityFactory> |
getCRSAuthorityFactories(Hints hints)
Returns a set of all available implementations for the CRSAuthorityFactory interface. |
static CRSAuthorityFactory |
getCRSAuthorityFactory(String authority,
Hints hints)
Returns the first implementation of CRSAuthorityFactory matching the specified
hints. |
static Set<CRSFactory> |
getCRSFactories(Hints hints)
Returns a set of all available implementations for the CRSFactory interface. |
static CRSFactory |
getCRSFactory(Hints hints)
Returns the first implementation of CRSFactory matching the specified hints. |
static Set<CSAuthorityFactory> |
getCSAuthorityFactories(Hints hints)
Returns a set of all available implementations for the CSAuthorityFactory interface. |
static CSAuthorityFactory |
getCSAuthorityFactory(String authority,
Hints hints)
Returns the first implementation of CSAuthorityFactory matching the specified
hints. |
static Set<CSFactory> |
getCSFactories(Hints hints)
Returns a set of all available implementations for the CSFactory interface. |
static CSFactory |
getCSFactory(Hints hints)
Returns the first implementation of CSFactory matching the specified hints. |
static Set<DatumAuthorityFactory> |
getDatumAuthorityFactories(Hints hints)
Returns a set of all available implementations for the DatumAuthorityFactory
interface. |
static DatumAuthorityFactory |
getDatumAuthorityFactory(String authority,
Hints hints)
Returns the first implementation of DatumAuthorityFactory matching the specified
hints. |
static Set<DatumFactory> |
getDatumFactories(Hints hints)
Returns a set of all available implementations for the DatumFactory interface. |
static DatumFactory |
getDatumFactory(Hints hints)
Returns the first implementation of DatumFactory matching the specified hints. |
static Set<MathTransformFactory> |
getMathTransformFactories(Hints hints)
Returns a set of all available implementations for the MathTransformFactory interface. |
static MathTransformFactory |
getMathTransformFactory(Hints hints)
Returns the first implementation of MathTransformFactory matching the specified
hints. |
static boolean |
isRegistered(Factory factory)
Returns true if the specified factory is registered. |
static void |
listProviders(Writer out,
Locale locale)
List all available factory implementations in a tabular format. |
static void |
main(String[] args)
Dump to the standard output stream a list of available factory implementations. |
static void |
removeAuthorityFactory(AuthorityFactory authority)
Programmatic management of authority factories. |
static void |
scanForPlugins()
Scans for factory plug-ins on the application class path. |
static boolean |
setAuthorityOrdering(String authority1,
String authority2)
Sets a pairwise ordering between two authorities. |
static boolean |
setVendorOrdering(String vendor1,
String vendor2)
Sets a pairwise ordering between two vendors. |
static boolean |
unsetAuthorityOrdering(String authority1,
String authority2)
Unsets a pairwise ordering between two authorities. |
static boolean |
unsetVendorOrdering(String vendor1,
String vendor2)
Unsets a pairwise ordering between two vendors. |
Methods inherited from class FactoryFinder |
---|
mergeSystemHints |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Set<String> getAuthorityNames()
public static DatumFactory getDatumFactory(Hints hints) throws FactoryRegistryException
DatumFactory
matching the specified hints.
If no implementation matches, a new one is created if possible or an exception is thrown
otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
DatumFactory
interface.public static Set<DatumFactory> getDatumFactories(Hints hints)
DatumFactory
interface.
hints
- An optional map of hints, or null
if none.
public static CSFactory getCSFactory(Hints hints) throws FactoryRegistryException
CSFactory
matching the specified hints.
If no implementation matches, a new one is created if possible or an exception is thrown
otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CSFactory
interface.public static Set<CSFactory> getCSFactories(Hints hints)
CSFactory
interface.
hints
- An optional map of hints, or null
if none.
public static CRSFactory getCRSFactory(Hints hints) throws FactoryRegistryException
CRSFactory
matching the specified hints.
If no implementation matches, a new one is created if possible or an exception is thrown
otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CRSFactory
interface.public static Set<CRSFactory> getCRSFactories(Hints hints)
CRSFactory
interface.
hints
- An optional map of hints, or null
if none.
public static CoordinateOperationFactory getCoordinateOperationFactory(Hints hints) throws FactoryRegistryException
CoordinateOperationFactory
matching the specified
hints. If no implementation matches, a new one is created if possible or an exception is
thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
Hints that may be understood includes
MATH_TRANSFORM_FACTORY
,
DATUM_SHIFT_METHOD
,
LENIENT_DATUM_SHIFT
and
VERSION
.
hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CoordinateOperationFactory
interface.public static Set<CoordinateOperationFactory> getCoordinateOperationFactories(Hints hints)
CoordinateOperationFactory
interface.
hints
- An optional map of hints, or null
if none.
public static DatumAuthorityFactory getDatumAuthorityFactory(String authority, Hints hints) throws FactoryRegistryException
DatumAuthorityFactory
matching the specified
hints. If no implementation matches, a new one is created if possible or an exception is
thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
authority
- The desired authority (e.g. "EPSG").hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
DatumAuthorityFactory
interface.public static Set<DatumAuthorityFactory> getDatumAuthorityFactories(Hints hints)
DatumAuthorityFactory
interface.
hints
- An optional map of hints, or null
if none.
public static CSAuthorityFactory getCSAuthorityFactory(String authority, Hints hints) throws FactoryRegistryException
CSAuthorityFactory
matching the specified
hints. If no implementation matches, a new one is created if possible or an exception is
thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
Hints that may be understood includes
FORCE_LONGITUDE_FIRST_AXIS_ORDER
,
FORCE_STANDARD_AXIS_UNITS
and
FORCE_STANDARD_AXIS_DIRECTIONS
and
VERSION
.
authority
- The desired authority (e.g. "EPSG").hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CSAuthorityFactory
interface.public static Set<CSAuthorityFactory> getCSAuthorityFactories(Hints hints)
CSAuthorityFactory
interface.
hints
- An optional map of hints, or null
if none.
public static CRSAuthorityFactory getCRSAuthorityFactory(String authority, Hints hints) throws FactoryRegistryException
CRSAuthorityFactory
matching the specified
hints. If no implementation matches, a new one is created if possible or an exception is
thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
Hints that may be understood includes
FORCE_LONGITUDE_FIRST_AXIS_ORDER
,
FORCE_STANDARD_AXIS_UNITS
,
FORCE_STANDARD_AXIS_DIRECTIONS
and
VERSION
.
TIP: The EPSG official factory and the EPSG extensions (additional CRS provided by
ESRI and others) are two distinct factories. Call to getCRSAuthorityFactory("EPSG",
null)
returns only one of those, usually the official EPSG factory. If the union of those
two factories is wanted, then a chain of fallbacks is wanted. Consider using something like:
FallbackAuthorityFactory.create(CRSAuthorityFactory.class,
getCRSAuthorityFactories(hints));
authority
- The desired authority (e.g. "EPSG").hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CRSAuthorityFactory
interface.public static Set<CRSAuthorityFactory> getCRSAuthorityFactories(Hints hints)
CRSAuthorityFactory
interface.
This set can be used to list the available codes known to all authorities.
In the event that the same code is understood by more then one authority
you will need to assume both are close enough, or make use of this set directly
rather than use the CRS.decode(java.lang.String)
convenience method.
hints
- An optional map of hints, or null
if none.
public static CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory(String authority, Hints hints) throws FactoryRegistryException
CoordinateOperationAuthorityFactory
matching
the specified hints. If no implementation matches, a new one is created if possible or an
exception is thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
authority
- The desired authority (e.g. "EPSG").hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
CoordinateOperationAuthorityFactory
interface.public static Set<CoordinateOperationAuthorityFactory> getCoordinateOperationAuthorityFactories(Hints hints)
CoordinateOperationAuthorityFactory
interface.
hints
- An optional map of hints, or null
if none.
public static MathTransformFactory getMathTransformFactory(Hints hints) throws FactoryRegistryException
MathTransformFactory
matching the specified
hints. If no implementation matches, a new one is created if possible or an exception is
thrown otherwise. If more than one implementation is registered and an
ordering is set, then the preferred
implementation is returned. Otherwise an arbitrary one is selected.
hints
- An optional map of hints, or null
if none.
FactoryRegistryException
- if no implementation was found or can be created for the
MathTransformFactory
interface.public static Set<MathTransformFactory> getMathTransformFactories(Hints hints)
MathTransformFactory
interface.
hints
- An optional map of hints, or null
if none.
public static boolean setVendorOrdering(String vendor1, String vendor2)
false
is returned.
The example below said that an ESRI implementation (if available) is preferred over the Geotools one:
FactoryFinder.setVendorOrdering("ESRI", "Geotools");
vendor1
- The preferred vendor.vendor2
- The vendor to which vendor1
is preferred.
true
if the ordering was set for at least one category.public static boolean unsetVendorOrdering(String vendor1, String vendor2)
false
is returned.
vendor1
- The preferred vendor.vendor2
- The vendor to which vendor1
is preferred.
true
if the ordering was unset for at least one category.public static boolean setAuthorityOrdering(String authority1, String authority2)
false
is returned.
The example below said that EPSG authority factories are preferred over ESRI ones:
FactoryFinder.setAuthorityOrdering("EPSG", "ESRI");
authority1
- The preferred authority.authority2
- The authority to which authority1
is preferred.
true
if the ordering was set for at least one category.public static boolean unsetAuthorityOrdering(String authority1, String authority2)
false
is returned.
authority1
- The preferred authority.authority2
- The vendor to which authority1
is preferred.
true
if the ordering was unset for at least one category.public static void addAuthorityFactory(AuthorityFactory authority)
authority
- The authority factory to add.public static void removeAuthorityFactory(AuthorityFactory authority)
authority
- The authority factory to remove.public static boolean isRegistered(Factory factory)
true
if the specified factory is registered. A factory may have been
registered by scanForPlugins()
if it was declared in a META-INF/services
file, or it may have been added programmatically.
public static void scanForPlugins()
public static void listProviders(Writer out, Locale locale) throws IOException
out
- The output stream where to format the list.locale
- The locale for the list, or null
.
IOException
- if an error occurs while writting to out
.public static void main(String[] args)
java org.geotools.referencing.FactoryFinder <options>
where options are:
-encoding <code> |
Set the character encoding |
-locale <language> |
Set the language for the output (e.g. "fr" for French) |
Note for Windows users: If the output contains strange
symbols, try to supply an "-encoding
" argument. Example:
java org.geotools.referencing.FactoryFinder -encoding Cp850
The codepage number (850 in the previous example) can be obtained from the DOS
commande line using the "chcp
" command with no arguments.
args
- Command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |