org.geotoolkit.referencing.factory
Class FactoryDependencies

Object
  extended by FactoryDependencies

public class FactoryDependencies
extends Object

Build a tree of factory dependencies, usually for printing to the console. This is a convenience utility for inspecting the dependencies between Geotk referencing factories. For example the following code will prints the full set of factories used by the CRS.decode(String) method:

FactoryDependencies report = new FactoryDependencies(CRS.getAuthorityFactory(null));
report.setColorEnabled(true); // Use only if the output console is ANSI X3.64 compliant.
report.setAbridged(true);
report.print();
The output will looks like the tree below (actual output may vary depending the plugins available on the classpath). The "…⬏" suffix means that the factory has already been defined in a previous line and its dependencies are not repeated.
DefaultAuthorityFactory["All"]
└───AllAuthoritiesFactory["All"]
    ├───ThreadedEpsgFactory["EPSG"]
    │   └───AnsiDialectEpsgFactory["EPSG"]
    │       ├───ReferencingObjectFactory[objects]
    │       └───DatumAliases[objects]
    ├───AutoCRSFactory["AUTO2", "AUTO"]
    │   ├───ReferencingObjectFactory[objects] …⬏
    │   └───DatumAliases[objects] …⬏
    ├───WebCRSFactory["CRS", "OGC"]
    │   ├───ReferencingObjectFactory[objects] …⬏
    │   └───DatumAliases[objects] …⬏
    ├───URN_AuthorityFactory["urn:ogc:def", "urn:x-ogc:def"]
    │   └───AllAuthoritiesFactory["All"]
    │       ├───ThreadedEpsgFactory["EPSG"] …⬏
    │       ├───AutoCRSFactory["AUTO2"] …⬏
    │       └───WebCRSFactory["CRS"] …⬏
    └───HTTP_AuthorityFactory["http://www.opengis.net"]
        └───AllAuthoritiesFactory["All"] …⬏
For example if an "epsg.properties" file is provided on the classpath, then the above code snippet is useful for verifying that PropertyEpsgFactory appears as expected. It should be visible below ThreadedEpsgFactory in a fallback chain.

An other way to gather information about the factories available at runtime is to set the logging level of org.geotoolkit loggers to CONFIG or a finer level.

Since:
2.4
Version:
3.00
Author:
Martin Desruisseaux (IRD)
Module:
referencing/geotk-referencing (download)    View source code for this class

Constructor Summary
FactoryDependencies(Factory factory)
          Creates a new dependency tree for the specified factory.
 
Method Summary
 TreeNode asTree()
          Returns the dependencies as a tree.
 boolean isAbridged()
          Returns true if only the first node of duplicated factories will be reported.
 boolean isAttributeEnabled()
          Returns true if attributes are to be printed.
 boolean isColorEnabled()
          Returns true if syntax coloring is enabled.
 void print()
          Prints the dependencies as a tree to the standard output stream.
 void print(Appendable out)
          Prints the dependencies as a tree to the specified writer.
 void print(PrintWriter out)
          Prints the dependencies as a tree to the specified printer.
 void setAbridged(boolean abridged)
          Sets whetever the tree should be abridged.
 void setAttributeEnabled(boolean enabled)
          Enables or disables the addition of attributes after factory names.
 void setColorEnabled(boolean enabled)
          Enables or disables syntax coloring on ANSI X3.64 (aka ECMA-48 and ISO/IEC 6429) compatible terminal.
 String toString()
          Returns the string representation of the dependencies tree.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FactoryDependencies

public FactoryDependencies(Factory factory)
Creates a new dependency tree for the specified factory.

Parameters:
factory - The factory for which to build a dependency tree.
Method Detail

isColorEnabled

public boolean isColorEnabled()
Returns true if syntax coloring is enabled. Syntax coloring is disabled by default.

Returns:
true if syntax coloring is enabled.

setColorEnabled

public void setColorEnabled(boolean enabled)
Enables or disables syntax coloring on ANSI X3.64 (aka ECMA-48 and ISO/IEC 6429) compatible terminal. By default, syntax coloring is disabled.

Parameters:
enabled - true for enabling syntax coloring.

isAttributeEnabled

public boolean isAttributeEnabled()
Returns true if attributes are to be printed. By default, attributes are not printed.

Returns:
true if attributes will be printed.

setAttributeEnabled

public void setAttributeEnabled(boolean enabled)
Enables or disables the addition of attributes after factory names. Attributes are labels like "crs", "datum", etc. put between parenthesis. They give indications on the services implemented by the factory (e.g. CRSAuthorityFactory, DatumAuthorityFactory, etc.).

Parameters:
enabled - true for printing attributes.

isAbridged

public boolean isAbridged()
Returns true if only the first node of duplicated factories will be reported. The default value is false, which means that the full branch will be expanded on every occurrence of a factory in the dependency graph.

Returns:
true if only the first node of duplicated factories will be reported, except for the first occurrence.
Since:
3.00

setAbridged

public void setAbridged(boolean abridged)
Sets whetever the tree should be abridged. If true, only the first node of duplicated factories will be reported (except the first occurrence which is expanded like usual).

Parameters:
abridged - true for an abridged tree, or false for expanding every branches unconditionally.
Since:
3.00

print

public void print()
Prints the dependencies as a tree to the standard output stream.

Since:
3.00

print

public void print(PrintWriter out)
Prints the dependencies as a tree to the specified printer.

Parameters:
out - Where to print the dependencies tree.

print

public void print(Appendable out)
           throws IOException
Prints the dependencies as a tree to the specified writer.

Parameters:
out - Where to write the dependencies tree.
Throws:
IOException - if an error occurred while writing to the stream.

asTree

public TreeNode asTree()
Returns the dependencies as a tree.

Returns:
The dependencies as a tree.

toString

public String toString()
Returns the string representation of the dependencies tree.

Overrides:
toString in class Object
Since:
3.10


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