org.jfree.report.util
Class ReportConfiguration

java.lang.Object
  extended byorg.jfree.report.util.ReportConfiguration
All Implemented Interfaces:
org.jfree.util.Configuration, java.io.Serializable
Direct Known Subclasses:
PropertyFileReportConfiguration, SystemPropertyConfiguration

public class ReportConfiguration
extends java.lang.Object
implements org.jfree.util.Configuration, java.io.Serializable

Global and local configurations for JFreeReport.

You can access the global configuration using this statement in your code:

ReportConfiguration config = ReportConfiguration.getGlobalConfig();

You can access the local configuration for a report using this:

ReportConfiguration local = myReport.getReportConfiguration();

You can also specify the local configuration for a report via the XML report template file.

todo document the initialization order ...

The report configuration can be modified using the configuration editor in the gui-config module.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String DISABLE_LOGGING
          The 'disable logging' property key.
static java.lang.String DISABLE_LOGGING_DEFAULT
          The default 'disable logging' property value.
static java.lang.String FONTRENDERER_ISBUGGY_FRC
          The G2 fontrenderer bug override configuration key.
static java.lang.String FONTRENDERER_ISBUGGY_FRC_DEFAULT
          The G2 fontrenderer bug override.
static java.lang.String FONTRENDERER_USEALIASING
          The text aliasing configuration key.
static java.lang.String FONTRENDERER_USEALIASING_DEFAULT
          The text aliasing configuration default value.
static java.lang.String LOGLEVEL
          The 'log level' property key.
static java.lang.String LOGLEVEL_DEFAULT
          The default 'log level' property value.
static java.lang.String LOGTARGET
          The 'log target' property key.
static java.lang.String LOGTARGET_DEFAULT
          The default 'log target' property value.
static java.lang.String NO_PRINTER_AVAILABLE
          The 'no-printer-available' property key.
static java.lang.String PRINT_OPERATION_COMMENT
          The property key, which defines whether to be verbose when generating the content.
static java.lang.String PRINT_OPERATION_COMMENT_DEFAULT
          The default 'print operation comment' property value.
static java.lang.String REPORT_RESOURCE_BUNDLE_KEY
          The default resourcebundle that should be used for ResourceFileFilter.
static java.lang.String STRICT_ERRORHANDLING
          The property key, which defines whether errors abort the report generation.
static java.lang.String STRICT_ERRORHANDLING_DEFAULT
          The default 'strict errorhandling' property value.
static java.lang.String WARN_INVALID_COLUMNS
          The 'warn on invalid columns' property key.
static java.lang.String WARN_INVALID_COLUMNS_DEFAULT
          The default 'warn on invalid columns' property value.
 
Constructor Summary
protected ReportConfiguration()
          Default constructor.
  ReportConfiguration(ReportConfiguration globalConfig)
          Creates a new report configuration.
 
Method Summary
 java.util.Iterator findPropertyKeys(java.lang.String prefix)
          Searches all property keys that start with a given prefix.
 java.util.Enumeration getConfigProperties()
          Returns all defined configuration properties for the report.
 java.lang.String getConfigProperty(java.lang.String key)
          Returns the configuration property with the specified key.
 java.lang.String getConfigProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the configuration property with the specified key (or the specified default value if there is no such property).
protected  java.util.Properties getConfiguration()
          Returns the collection of properties for the configuration.
static ReportConfiguration getGlobalConfig()
          Returns the global configuration for JFreeReport.
 java.lang.String getLogLevel()
          Returns the log level.
 java.lang.String getLogTarget()
          Returns the current log target.
protected  ReportConfiguration getParentConfig()
          Returns the parent configuration.
static java.lang.String getPlatformDefaultEncoding()
          Helper method to read the platform default encoding from the VM's system properties.
protected  void insertConfiguration(ReportConfiguration config)
          The new configuartion will be inserted into the list of report configuration, so that this configuration has the given report configuration instance as parent.
 boolean isDisableLogging()
          Returns true if logging is disabled, and false otherwise.
 boolean isFontRendererBuggy()
          Returns true, if the Graphics2D implementation is buggy and is not really able to place/calculate the fontsizes correctly.
 boolean isFontRendererUseAliasing()
          Returns true, if the Graphics2D should use aliasing to render text.
 boolean isLocallyDefined(java.lang.String key)
          Checks, whether the given key is localy defined in this instance or whether the key's value is inherited.
 boolean isPrintOperationComment()
          Returns true, if physical operation comments should be added to the physical page.
 boolean isStrictErrorHandling()
          Checks, whether a stricter error handling is applied to the report processing.
 boolean isWarnInvalidColumns()
          Returns true, if invalid columns in the dataRow are logged as warning.
 void setConfigProperty(java.lang.String key, java.lang.String value)
          Sets a configuration property.
 void setDisableLogging(boolean disableLogging)
          Sets the flag that disables logging.
 void setFontRendererBuggy(boolean buggy)
          set to true, if the Graphics2D implementation is buggy and is not really able to place/calculate the fontsizes correctly.
 void setFontRendererUseAliasing(boolean alias)
          set to true, if the Graphics2D should use aliasing to render text.
 void setLogLevel(java.lang.String level)
          Sets the log level, which is read from the global report configuration at the point that the classloader loads the Log class.
 void setLogTarget(java.lang.String logTarget)
          Sets the log target.
protected  void setParentConfig(ReportConfiguration config)
          Set the parent configuration.
 void setPrintOperationComment(boolean print)
          set to true, if physical operation comments should be added to the physical page.
 void setStrictErrorHandling(boolean strictErrorHandling)
          Defines, whether a stricter error handling is applied to the report processing.
 void setWarnInvalidColumns(boolean warnInvalidColumns)
          Set to true, if you want to get informed when invalid column-requests are made to the DataRow.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FONTRENDERER_USEALIASING

public static final java.lang.String FONTRENDERER_USEALIASING
The text aliasing configuration key.

See Also:
Constant Field Values

FONTRENDERER_USEALIASING_DEFAULT

public static final java.lang.String FONTRENDERER_USEALIASING_DEFAULT
The text aliasing configuration default value. Is "false".

See Also:
Constant Field Values

FONTRENDERER_ISBUGGY_FRC

public static final java.lang.String FONTRENDERER_ISBUGGY_FRC
The G2 fontrenderer bug override configuration key.

See Also:
Constant Field Values

FONTRENDERER_ISBUGGY_FRC_DEFAULT

public static final java.lang.String FONTRENDERER_ISBUGGY_FRC_DEFAULT
The G2 fontrenderer bug override. Is "false".

See Also:
Constant Field Values

PRINT_OPERATION_COMMENT

public static final java.lang.String PRINT_OPERATION_COMMENT
The property key, which defines whether to be verbose when generating the content.

See Also:
Constant Field Values

PRINT_OPERATION_COMMENT_DEFAULT

public static final java.lang.String PRINT_OPERATION_COMMENT_DEFAULT
The default 'print operation comment' property value.

See Also:
Constant Field Values

STRICT_ERRORHANDLING

public static final java.lang.String STRICT_ERRORHANDLING
The property key, which defines whether errors abort the report generation.

See Also:
Constant Field Values

STRICT_ERRORHANDLING_DEFAULT

public static final java.lang.String STRICT_ERRORHANDLING_DEFAULT
The default 'strict errorhandling' property value.

See Also:
Constant Field Values

WARN_INVALID_COLUMNS

public static final java.lang.String WARN_INVALID_COLUMNS
The 'warn on invalid columns' property key.

See Also:
Constant Field Values

WARN_INVALID_COLUMNS_DEFAULT

public static final java.lang.String WARN_INVALID_COLUMNS_DEFAULT
The default 'warn on invalid columns' property value.

See Also:
Constant Field Values

DISABLE_LOGGING

public static final java.lang.String DISABLE_LOGGING
The 'disable logging' property key.

See Also:
Constant Field Values

NO_PRINTER_AVAILABLE

public static final java.lang.String NO_PRINTER_AVAILABLE
The 'no-printer-available' property key.

See Also:
Constant Field Values

DISABLE_LOGGING_DEFAULT

public static final java.lang.String DISABLE_LOGGING_DEFAULT
The default 'disable logging' property value.

See Also:
Constant Field Values

LOGLEVEL

public static final java.lang.String LOGLEVEL
The 'log level' property key.

See Also:
Constant Field Values

LOGLEVEL_DEFAULT

public static final java.lang.String LOGLEVEL_DEFAULT
The default 'log level' property value.

See Also:
Constant Field Values

LOGTARGET

public static final java.lang.String LOGTARGET
The 'log target' property key.

See Also:
Constant Field Values

LOGTARGET_DEFAULT

public static final java.lang.String LOGTARGET_DEFAULT
The default 'log target' property value.


REPORT_RESOURCE_BUNDLE_KEY

public static final java.lang.String REPORT_RESOURCE_BUNDLE_KEY
The default resourcebundle that should be used for ResourceFileFilter. This property must be applied by the parser.

See Also:
Constant Field Values
Constructor Detail

ReportConfiguration

protected ReportConfiguration()
Default constructor.


ReportConfiguration

public ReportConfiguration(ReportConfiguration globalConfig)
Creates a new report configuration.

Parameters:
globalConfig - the global configuration.
Method Detail

getPlatformDefaultEncoding

public static java.lang.String getPlatformDefaultEncoding()
Helper method to read the platform default encoding from the VM's system properties.

Returns:
the contents of the system property "file.encoding".

getConfigProperty

public java.lang.String getConfigProperty(java.lang.String key)
Returns the configuration property with the specified key.

Specified by:
getConfigProperty in interface org.jfree.util.Configuration
Parameters:
key - the property key.
Returns:
the property value.

getConfigProperty

public java.lang.String getConfigProperty(java.lang.String key,
                                          java.lang.String defaultValue)
Returns the configuration property with the specified key (or the specified default value if there is no such property).

If the property is not defined in this configuration, the code will lookup the property in the parent configuration.

Specified by:
getConfigProperty in interface org.jfree.util.Configuration
Parameters:
key - the property key.
defaultValue - the default value.
Returns:
the property value.

setConfigProperty

public void setConfigProperty(java.lang.String key,
                              java.lang.String value)
Sets a configuration property.

Parameters:
key - the property key.
value - the property value.

getLogLevel

public java.lang.String getLogLevel()
Returns the log level.

Returns:
the log level.

setLogLevel

public void setLogLevel(java.lang.String level)
Sets the log level, which is read from the global report configuration at the point that the classloader loads the Log class.

Valid log levels are:

  • "Error" - error messages;
  • "Warn" - warning messages;
  • "Info" - information messages;
  • "Debug" - debug messages;
Notes:
  • the setting is not case sensitive.
  • changing the log level after the Log class has been loaded will have no effect.
  • to turn of logging altogether, use the setDisableLogging(boolean) method.

Parameters:
level - the new log level.

isDisableLogging

public boolean isDisableLogging()
Returns true if logging is disabled, and false otherwise.

Returns:
true, if logging is completly disabled, false otherwise.

setDisableLogging

public void setDisableLogging(boolean disableLogging)
Sets the flag that disables logging.

To switch off logging globally, you can use the following code:

ReportConfiguration.getGlobalConfig().setDisableLogging(true);

Parameters:
disableLogging - the flag.

getConfiguration

protected java.util.Properties getConfiguration()
Returns the collection of properties for the configuration.

Returns:
the properties.

getGlobalConfig

public static ReportConfiguration getGlobalConfig()
Returns the global configuration for JFreeReport.

In the current implementation, the configuration has no properties defined, but references a parent configuration that:

  • copies across all the System properties to use as report configuration properties (obviously the majority of them will not apply to reports);
  • itself references a parent configuration that reads its properties from a file jfreereport.properties.

Returns:
the global configuration.

insertConfiguration

protected void insertConfiguration(ReportConfiguration config)
The new configuartion will be inserted into the list of report configuration, so that this configuration has the given report configuration instance as parent.

Parameters:
config - the new report configuration.

setParentConfig

protected void setParentConfig(ReportConfiguration config)
Set the parent configuration. The parent configuration is queried, if the requested configuration values was not found in this report configuration.

Parameters:
config - the parent configuration.

getParentConfig

protected ReportConfiguration getParentConfig()
Returns the parent configuration. The parent configuration is queried, if the requested configuration values was not found in this report configuration.

Returns:
the parent configuration.

getLogTarget

public java.lang.String getLogTarget()
Returns the current log target.

Returns:
the log target.

setLogTarget

public void setLogTarget(java.lang.String logTarget)
Sets the log target.

Parameters:
logTarget - the new log target.

isWarnInvalidColumns

public boolean isWarnInvalidColumns()
Returns true, if invalid columns in the dataRow are logged as warning.

Returns:
true, if invalid columns in the dataRow are logged as warning.

setWarnInvalidColumns

public void setWarnInvalidColumns(boolean warnInvalidColumns)
Set to true, if you want to get informed when invalid column-requests are made to the DataRow.

Parameters:
warnInvalidColumns - the warning flag

isPrintOperationComment

public boolean isPrintOperationComment()
Returns true, if physical operation comments should be added to the physical page. This is only usefull for debugging.

Returns:
true, if comments are enabled.

setPrintOperationComment

public void setPrintOperationComment(boolean print)
set to true, if physical operation comments should be added to the physical page. This is only usefull for debugging.

Parameters:
print - set to true, if comments should be enabled.

isFontRendererUseAliasing

public boolean isFontRendererUseAliasing()
Returns true, if the Graphics2D should use aliasing to render text. Defaults to false.

Returns:
true, if aliasing is enabled.

setFontRendererUseAliasing

public void setFontRendererUseAliasing(boolean alias)
set to true, if the Graphics2D should use aliasing to render text. Defaults to false.

Parameters:
alias - set to true, if the Graphics2D should use aliasing.

isFontRendererBuggy

public boolean isFontRendererBuggy()
Returns true, if the Graphics2D implementation is buggy and is not really able to place/calculate the fontsizes correctly. Defaults to false. (SunJDK on Windows is detected and corrected, Linux SunJDK 1.3 is buggy, but not detectable).

Returns:
true, if the Graphics2D implementation does not calculate the string positions correctly and an alternative implementation should be used.

setFontRendererBuggy

public void setFontRendererBuggy(boolean buggy)
set to true, if the Graphics2D implementation is buggy and is not really able to place/calculate the fontsizes correctly. Defaults to false. (SunJDK on Windows is detected and corrected, Linux SunJDK 1.3 is buggy, but not detectable).

Parameters:
buggy - set to true, if the Graphics2D implementation does not calculate the string positions correctly and an alternative implementation should be used.

getConfigProperties

public java.util.Enumeration getConfigProperties()
Returns all defined configuration properties for the report. The enumeration contains all keys of the changed properties, properties set from files or the system properties are not included.

Returns:
all defined configuration properties for the report.

isStrictErrorHandling

public boolean isStrictErrorHandling()
Checks, whether a stricter error handling is applied to the report processing. If set to true, then errors in the handling of report events will cause the report processing to fail. This is a safe-and-paranoid setting, life is simpler with this set to false. The property defaults to false, as this is the old behaviour.

A properly defined report should not throw exceptions, so it is safe to set this to true.

Returns:
true, if the strict handling is enabled, false otherwise.

setStrictErrorHandling

public void setStrictErrorHandling(boolean strictErrorHandling)
Defines, whether a stricter error handling is applied to the report processing. If set to true, then errors in the handling of report events will cause the report processing to fail. This is a safe-and-paranoid setting, life is simpler with this set to false. The property defaults to false, as this is the old behaviour.

A properly defined report should not throw exceptions, so it is safe to set this to true.

Parameters:
strictErrorHandling - if set to true, then errors in the event dispatching will cause the reporting to fail.

findPropertyKeys

public java.util.Iterator findPropertyKeys(java.lang.String prefix)
Searches all property keys that start with a given prefix.

Parameters:
prefix - the prefix that all selected property keys should share
Returns:
the properties as iterator.

isLocallyDefined

public boolean isLocallyDefined(java.lang.String key)
Checks, whether the given key is localy defined in this instance or whether the key's value is inherited.

Parameters:
key - the key that should be checked.
Returns:
true, if the key is defined locally, false otherwise.