de.vc.jfo.env

## Class JFOConfig

- java.lang.Object
- - de.vc.jfo.env.JFOConfig

-     public class JFOConfig
      extends java.lang.Object

  Configuration for JFO. It contains global setting for these components:
  - Logging
  - License
  - Available XSL-FO renderers
  - RTF to XSL-FO transformation
  - Font mapping
  - Image transcoders
  The configuration is a singleton (only one instance at class loader level), `JFOConfig.instance()` returns the singleton. If the `instance()` methode is called the first time, the configuration is loaded from an XML file (jfo-config.xml). The XML file is loaded automatically if it's placed in a directory or a JAR of the classpath. One may also set a location (URL or file-path) of the configuration file using system property `de.vc.JFOConfigURL`. Also one can load the configuration manually by calling static method `JFOConfig.loadFrom(URL url)`.
  See Also:
    `instance()`, `loadFrom(java.net.URL)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `LOGGER_NAME`
    `static int` | `MEMORY_SPEED_RATIO_BALANCED` Memory-Speed ratio where speed and memory usage are balanced.
    `static int` | `MEMORY_SPEED_RATIO_MEMORY` Memory-Speed ration for saving memory.
    `static int` | `MEMORY_SPEED_RATIO_SPEED` Memory-Speed ratio for full speed.
    `static java.lang.String` | `SYSTEM_PROPERTY_URL` System property key that points to JFO's configuration file.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addImageTranscoder(ImageTranscoder transcoder)` Adds an image transcoder.
    `de.vc.config.Configuration` | `buildConfiguration()` Builds an Avalon-Configuration object from this configuration.
    `boolean` | `checkUrlDataScheme()` Checks whether the url data scheme is supported by JRE.
    `java.io.File` | `getConfigDirectory()` Returns the directory of jfo-config.xml if possible.
    `FontMapper` | `getDefaultFontMapper()` Gets the default font mapper from the list of font-mappers.
    `RendererFactory` | `getDefaultRendererFactory()` Returns the default factory for creating renderers.
    `FontMapper` | `getFontMapperByID(java.lang.String mapperID)` Gets a font-mapper by it's ID.
    `FontMapper` | `getFontMapperFor(RTF2FOCompatibilityMode cm)`
    `FontMapper` | `getFontMapperFor(java.lang.String cm, boolean bestMatching)`
    `ImageTranscoder` | `getImageTranscoderForFile(java.lang.String imageFile)` Gets an image transcoder for a given image if there is any transcoder that is able to convert the image.
    `java.net.URL` | `getLicenseKeyFile()` Gets the URL of the license key.
    `org.apache.commons.logging.Log` | `getLogger()`
    `org.apache.commons.logging.Log` | `getLoggerForComponent(java.lang.Class<?> componentClazz)`
    `org.apache.commons.logging.Log` | `getLoggerForComponent(java.lang.String componentName)`
    `java.lang.String` | `getLoggerPriority()`
    `int` | `getMemorySpeedRation()` Gets the memory-speed ratio.
    `RTF2FOConfig` | `getRTF2FOConfig()` Gets the default configuration that is used for RTF import.
    `Templates` | `getTemplates()` Gets the templates of JFO.
    `java.net.URL` | `getUrl()` Gets the URL of this configuration if it was loaded.
    `java.lang.String` | `getXmlEncoding()`
    `ImageTranscoder` | `imageTranscoder(ImageMetaData id)` Gets an image transcoder for a given image format.
    `static JFOConfig` | `instance()` Default instance of configuration.
    `boolean` | `isFormatXMLOutput()` Returns true if any XML output (e.g. if a document is written) is formatted.
    `FontMapper[]` | `listFontMappers()`
    `java.util.List<ImageTranscoder>` | `listImageTranscoders()` Returns an unmodifieable list of all registered image transcoders.
    `static boolean` | `loadFrom(java.net.URL url)` Loads the configuration from a stream.
    `void` | `registerFontMapper(FontMapper fm)` Registers a new font-mapper.
    `boolean` | `removeImageTranscoder(ImageTranscoder transcoder)` Removes an image transcode.
    `void` | `saveTo(java.io.File file)` Stores this configuration as XML into an file.
    `void` | `setDefaultFontMapper(FontMapper fontMapper)` Sets the default font mapper.
    `void` | `setFontMapper(FontMapper fm)` Removes all registered font-mappers and sets the give font-mapper as default mapper.
    `void` | `setFormatXMLOutput(boolean format)` Sets whether JFO shall format XML output.
    `void` | `setLicenseKeyFile(java.net.URL licenseKeyFile)` Sets the license key file.
    `void` | `setLogger(org.apache.commons.logging.Log logger)` Sets the Logger used by JFO.
    `void` | `setLoggerPriority(java.lang.String loggerPriority)` Sets a new log priority, but only if SimpleLog of JCL is used.
    `void` | `setMemorySpeedRation(int ratio)` Sets the memory-speed ratio.
    `void` | `setXmlEncoding(java.lang.String xmlEncoding)`
    `void` | `unregisterAllFontMappers()`
    `void` | `unregisterFontMapper(FontMapper fm)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOGGER_NAME

          public static final java.lang.String LOGGER_NAME

      See Also:
        Constant Field Values

    - #### MEMORY_SPEED_RATIO_BALANCED

          public static final int MEMORY_SPEED_RATIO_BALANCED

      Memory-Speed ratio where speed and memory usage are balanced.
      See Also:
        Constant Field Values

    - #### MEMORY_SPEED_RATIO_MEMORY

          public static final int MEMORY_SPEED_RATIO_MEMORY

      Memory-Speed ration for saving memory. It's about 20% slower that MEMORY_SPEED_RATIO_SPEED but saves more than 20% memory, for documents with very large tables up to 70%.
      See Also:
        Constant Field Values

    - #### MEMORY_SPEED_RATIO_SPEED

          public static final int MEMORY_SPEED_RATIO_SPEED

      Memory-Speed ratio for full speed. Use this ratio speeds up JFO but needs also more memory.
      See Also:
        Constant Field Values

    - #### SYSTEM_PROPERTY_URL

          public static final java.lang.String SYSTEM_PROPERTY_URL

      System property key that points to JFO's configuration file. Value is `de.vc.JFOConfigURL`.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### addImageTranscoder

          public void addImageTranscoder(ImageTranscoder transcoder)

      Adds an image transcoder.
      Parameters:
        `transcoder` - ImageTranscoder.

    - #### buildConfiguration

          public de.vc.config.Configuration buildConfiguration()

      Builds an Avalon-Configuration object from this configuration.
      Returns:
        Avalon Configuration.

    - #### checkUrlDataScheme

          public boolean checkUrlDataScheme()

      Checks whether the url data scheme is supported by JRE. If JRE cannot handle URLs with data protocol then JFO installs factory `de.vc.net.ExtendableURLStreamHandlerFactory` at `java.net.URL`
      Returns:
        `true` if data scheme is supported or was successfully installed.
      See Also:
        `URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)`

    - #### imageTranscoder

          public ImageTranscoder imageTranscoder(ImageMetaData id)

      Gets an image transcoder for a given image format.
      Parameters:
        `id` - Meta data of picture
      Returns:
        Image transcoder or null.

    - #### instance

          public static JFOConfig instance()

      Default instance of configuration.
      Returns:
        Configuration.

    - #### listFontMappers

          public FontMapper[] listFontMappers()

    - #### listImageTranscoders

          public java.util.List<ImageTranscoder> listImageTranscoders()

      Returns an unmodifieable list of all registered image transcoders.
      Returns:
        List of `de.vc.jfo.tools.ImageTranscode`.

    - #### loadFrom

          public static boolean loadFrom(java.net.URL url)

      Loads the configuration from a stream.
      Parameters:
        `url` - URL of configuration.
      Returns:
        `true` if configuration was successfully loaded.

    - #### registerFontMapper

          public void registerFontMapper(FontMapper fm)

      Registers a new font-mapper. If the mapper has an ID and there is already another mapper with the same ID in the list, the existing mapping is replaced by the given mapper.
      Parameters:
        `fm` - Font mapper.

    - #### removeImageTranscoder

          public boolean removeImageTranscoder(ImageTranscoder transcoder)

      Removes an image transcode.
      Parameters:
        `transcoder` - ImageTranscoder.
      Returns:
        `true` if `transcoder` was registered.

    - #### saveTo

          public void saveTo(java.io.File file)
                      throws java.lang.Exception

      Stores this configuration as XML into an file.
      Parameters:
        `file` - File.
      Throws:
        `java.lang.Exception`

    - #### unregisterAllFontMappers

          public void unregisterAllFontMappers()

    - #### unregisterFontMapper

          public void unregisterFontMapper(FontMapper fm)

    - #### getConfigDirectory

          public java.io.File getConfigDirectory()

      Returns the directory of jfo-config.xml if possible.
      Returns:
        File Directory or null if unknown.

    - #### getDefaultFontMapper

          public FontMapper getDefaultFontMapper()

      Gets the default font mapper from the list of font-mappers. A default font mapper is not dedicated for a certain renderer, which means it has no "for-renderer" property. If you register two default font mappers, the first with an ID and the other not, the font mapper without an ID wins. If there are two or more global renderers without an ID, the first registered wins.
      If no global font mapper was registered before, a new empty font mapper is created.
      Returns:
        Global font mapper (never null).
      See Also:
        `getFontMapperFor(RTF2FOCompatibilityMode)`, `listFontMappers()`

    - #### getDefaultRendererFactory

          public RendererFactory getDefaultRendererFactory()

      Returns the default factory for creating renderers. Configured renderes are registered at this factory.
      Returns:
        RendererFactory

    - #### getFontMapperByID

          public FontMapper getFontMapperByID(java.lang.String mapperID)

      Gets a font-mapper by it's ID.
      Parameters:
        `mapperID` - ID of Mapper (attribute id in node font-mapping).
      Returns:
        FontMapper or null.

    - #### getFontMapperFor

          public FontMapper getFontMapperFor(RTF2FOCompatibilityMode cm)

    - #### getFontMapperFor

          public FontMapper getFontMapperFor(java.lang.String cm,
                                    boolean bestMatching)

    - #### getImageTranscoderForFile

          public ImageTranscoder getImageTranscoderForFile(java.lang.String imageFile)

      Gets an image transcoder for a given image if there is any transcoder that is able to convert the image.
      Parameters:
        `imageFile` - Image file.
      Returns:
        Image transcoder or null.

    - #### getLicenseKeyFile

          public java.net.URL getLicenseKeyFile()

      Gets the URL of the license key.
      Returns:
        License key file.

    - #### getLogger

          public org.apache.commons.logging.Log getLogger()

    - #### getLoggerForComponent

          public org.apache.commons.logging.Log getLoggerForComponent(java.lang.Class<?> componentClazz)

    - #### getLoggerForComponent

          public org.apache.commons.logging.Log getLoggerForComponent(java.lang.String componentName)

    - #### getLoggerPriority

          public java.lang.String getLoggerPriority()

    - #### getMemorySpeedRation

          public int getMemorySpeedRation()

      Gets the memory-speed ratio.
      Returns:
        Memory speed ratio.

    - #### getRTF2FOConfig

          public RTF2FOConfig getRTF2FOConfig()

      Gets the default configuration that is used for RTF import.
      Returns:
        Configuration for RTF import.

    - #### getTemplates

          public Templates getTemplates()

      Gets the templates of JFO.
      Returns:
        Templates.

    - #### getUrl

          public java.net.URL getUrl()

      Gets the URL of this configuration if it was loaded. This URL is also available as system property `de.vc.JFOConfigURL`.
      Returns:
        URL of configuration.

    - #### getXmlEncoding

          public java.lang.String getXmlEncoding()

    - #### isFormatXMLOutput

          public boolean isFormatXMLOutput()

      Returns true if any XML output (e.g. if a document is written) is formatted.
      Returns:
        true if XML output is formatted.

    - #### setDefaultFontMapper

          public void setDefaultFontMapper(FontMapper fontMapper)

      Sets the default font mapper.
      Parameters:
        `fontMapper` - Default font mapper.
      See Also:
        `registerFontMapper(FontMapper)`, `unregisterFontMapper(FontMapper)`

    - #### setFontMapper

          public void setFontMapper(FontMapper fm)

      Removes all registered font-mappers and sets the give font-mapper as default mapper.
      Parameters:
        `fm` -

    - #### setFormatXMLOutput

          public void setFormatXMLOutput(boolean format)

      Sets whether JFO shall format XML output. We recommend to enable formatting only if you want a human want to read the XML document. Disabled formatting improves performance and decreases file size.
      Parameters:
        `format` - true to enable formatting.

    - #### setLicenseKeyFile

          public void setLicenseKeyFile(java.net.URL licenseKeyFile)

      Sets the license key file. If you have no license key file you can order it @ www.vision-cloud.de or send a mail to info@vision-cloud.de
      If no license key is set JFO looks in root of classpath for it.
      Parameters:
        `licenseKeyFile` - License key file.

    - #### setLogger

          public void setLogger(org.apache.commons.logging.Log logger)

      Sets the Logger used by JFO.
      Parameters:
        `logger` - Logger.

    - #### setLoggerPriority

          public void setLoggerPriority(java.lang.String loggerPriority)

      Sets a new log priority, but only if SimpleLog of JCL is used. Since JFO uses the LogFactor of JCL (Apaches Jakarta Commons Logging), a concrete Logging implementation (JDK 1.4 Logging, Log4J...) is chosen automatically. Depending on the concrete used log framework, you have to specificy logging levels manually. The root logger name of JFO is `de.vc.jfo`. Example for JDK 1.4:
      `java.util.logging.Logger.getLogger("de.vc.jfo").setLevel(Level.WARNING);`
      Parameters:
        `loggerPriority` - String

    - #### setMemorySpeedRation

          public void setMemorySpeedRation(int ratio)

      Sets the memory-speed ratio. Possible values are
      - `MEMORY_SPEED_RATIO_SPEED` Fast API and RTF conversion, needs more memory
      - `MEMORY_SPEED_RATIO_MEMORY` API needs less memory, but is a slower
      - `MEMORY_SPEED_RATIO_BALANCED` Compromise between speed and memory usage
      Parameters:
        `ratio` - New ratio.

    - #### setXmlEncoding

          public void setXmlEncoding(java.lang.String xmlEncoding)

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.