Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.jasperreports.engine.util
Class JRProperties

    java.lang.Object
      net.sf.jasperreports.engine.util.JRProperties

    public final class JRProperties

extends java.lang.Object

Class that provides static methods for loading, getting and setting properties.

The following actions are performed:

- The default (hardcoded) properties are set.
- If the system property "net.sf.jasperreports.properties" has been set then the specified proprties file is loaded.
- Otherwise "jasperreports.properties" is loaded if found in the classpath.
- For backward compatibility, system properties like "jasper.reports.compile.xml.validation" are checked and their values are used. This way of specifying properties is deprecated.

Version:
  $Id: JRProperties.java 3974 2010-09-22 15:37:17Z teodord $
Author:
  Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
`static class` | `JRProperties.PropertySuffix` Class used by `getProperties(String)`.

Field Summary
`static java.lang.String` | `COMPILER_CLASS` Deprecated. Replaced by `JRCompiler.COMPILER_PREFIX`.
`static java.lang.String` | `COMPILER_CLASSPATH` The classpath used by the report compiler.
`static java.lang.String` | `COMPILER_KEEP_JAVA_FILE` Whether to keep the java file generated when the report is compiled.
`static java.lang.String` | `COMPILER_TEMP_DIR` The temporary directory used by the report compiler.
`static java.lang.String` | `COMPILER_XML_VALIDATION` Whether to validate the xml report when compiling.
`protected static java.lang.String` | `DEFAULT_PROPERTIES_FILE` The default properties file.
`static java.lang.String` | `EXPORT_XML_VALIDATION` Validation flag used by the XML exporter.
`static java.lang.String` | `PDF_FONT_DIRS_PREFIX` Prefix of properties that specify font directories for the PDF exporter.
`static java.lang.String` | `PDF_FONT_FILES_PREFIX` Prefix of properties that specify font files for the PDF exporter.
`static java.lang.String` | `PDF_FORCE_LINEBREAK_POLICY` Deprecated. Replaced by `JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY`.
`static java.lang.String` | `PROPERTIES_FILE` The name of the system property that specifies the properties file name.
`static java.lang.String` | `PROPERTY_PREFIX` The prefix used by all properties.
`protected static java.util.Properties` | `props`
`static java.lang.String` | `QUERY_EXECUTER_FACTORY_PREFIX` Deprecated. Replaced by `net.sf.jasperreports.engine.query`.
`protected static java.util.Properties` | `savedProps`
`static java.lang.String` | `SUBREPORT_RUNNER_FACTORY` Deprecated. Replaced by `JRSubreportRunnerFactory.SUBREPORT_RUNNER_FACTORY`.

Method Summary
`static boolean` | `asBoolean(java.lang.String value)` Converts a `String` value into a `boolean`.
`static java.lang.Character` | `asCharacter(java.lang.String value)` Converts a `String` into a `Character` value.
`static float` | `asFloat(java.lang.String value)` Converts a `String` value into a `float`.
`static int` | `asInteger(java.lang.String value)` Converts a `String` value into a `int`.
`static long` | `asLong(java.lang.String value)` Converts a `String` value into a `long`.
`static void` | `backupProperties()` Saves a copy of the current properties.
`static java.util.List` | `getAllProperties(JRPropertiesHolder propertiesHolder, java.lang.String prefix)` Returns the list of all properties for a key prefix, including global properties.
`static java.util.List` | `getAllProperties(JRPropertiesMap propertiesMap, java.lang.String prefix)` Returns the list of all properties for a key prefix, including global properties.
`static boolean` | `getBooleanProperty(JRPropertiesHolder propertiesHolder, java.lang.String key, boolean defaultValue)` Returns the value of a property as a boolean, looking first in the supplied properties holder and then in the system properties.
`static boolean` | `getBooleanProperty(JRPropertiesMap propertiesMap, java.lang.String key, boolean defaultValue)` Returns the value of a property as a boolean, looking first in the supplied properties map and then in the system properties.
`static boolean` | `getBooleanProperty(java.lang.String key)` Returns a property as a boolean value.
`static java.lang.Character` | `getCharacterProperty(JRPropertiesMap propertiesMap, java.lang.String key)` Returns the value of a property as a `Character` value, looking first in the supplied properties holder and then in the system properties.
`static java.lang.Character` | `getCharacterProperty(java.lang.String key)` Returns a property as a `Character` value.
`protected static java.util.Properties` | `getDefaults()` Sets the default properties.
`static float` | `getFloatProperty(JRPropertiesHolder propertiesHolder, java.lang.String key, float defaultValue)` Returns the value of a property as a float, looking first in the supplied properties holder and then in the system properties.
`static float` | `getFloatProperty(JRPropertiesMap propertiesMap, java.lang.String key, float defaultValue)` Returns the value of a property as a float, looking first in the supplied properties map and then in the system properties.
`static float` | `getFloatProperty(java.lang.String key)` Returns a property as a float value.
`static float` | `getFloatProperty(java.lang.String key, float defaultValue)` Returns the value of a property as a float.
`static int` | `getIntegerProperty(JRPropertiesHolder propertiesHolder, java.lang.String key, int defaultValue)` Returns the value of a property as an integer, looking first in the supplied properties holder and then in the system properties.
`static int` | `getIntegerProperty(JRPropertiesMap propertiesMap, java.lang.String key, int defaultValue)` Returns the value of a property as an integer, looking first in the supplied properties map and then in the system properties.
`static int` | `getIntegerProperty(java.lang.String key)` Returns a property as an integer value.
`static int` | `getIntegerProperty(java.lang.String key, int defaultValue)` Returns the value of a property as an integer.
`static long` | `getLongProperty(JRPropertiesHolder propertiesHolder, java.lang.String key, int defaultValue)` Returns the value of a property as a long, looking first in the supplied properties holder and then in the system properties.
`static long` | `getLongProperty(JRPropertiesMap propertiesMap, java.lang.String key, int defaultValue)` Returns the value of a property as a long, looking first in the supplied properties map and then in the system properties.
`static long` | `getLongProperty(java.lang.String key)` Returns a property as a long value.
`protected static JRPropertiesMap` | `getOwnProperties(JRPropertiesHolder propertiesHolder)`
`static java.util.List` | `getProperties(JRPropertiesHolder propertiesHolder, java.lang.String prefix)` Returns the list of all properties for a key prefix.
`static java.util.List` | `getProperties(JRPropertiesMap propertiesMap, java.lang.String prefix)` Returns the list of all properties for a key prefix.
`static java.util.List` | `getProperties(java.lang.String prefix)` Returns the list of all properties for a key prefix.
`static java.lang.String` | `getProperty(JRPropertiesHolder propertiesHolder, java.lang.String key)` Returns the value of a property, looking first in the supplied properties holder and then in the system properties.
`static java.lang.String` | `getProperty(JRPropertiesMap propertiesMap, java.lang.String key)` Returns the value of a property, looking first in the supplied properties map and then in the system properties.
`static java.lang.String` | `getProperty(java.lang.String key)` Returns the value of the property.
`protected static java.lang.String` | `getSystemProperty(java.lang.String propertyName)`
`protected static void` | `initProperties()` Loads the properties.
`static java.util.Properties` | `loadProperties(java.lang.String name, java.util.Properties defaults)` Loads a properties file from the classpath.
`protected static void` | `loadSystemProperties()`
`protected static void` | `loadSystemProperty(java.lang.String sysKey, java.lang.String propKey)`
`static void` | `removePropertyValue(java.lang.String key)` Removes the value set for a property.
`static void` | `restoreProperties()` Restores previously saved properties.
`static void` | `setProperty(java.lang.String key, boolean value)` Sets the value of a property.
`static void` | `setProperty(java.lang.String key, java.lang.String value)` Sets the value of a property.
`protected static void` | `transfer(JRPropertiesMap source, JRPropertiesHolder destination, java.lang.String tranferPropertiesPrefix)`
`static void` | `transferProperties(JRPropertiesHolder source, JRPropertiesHolder destination, java.lang.String tranferPropertiesPrefix)` Copies properties from one object to another.
`static void` | `transferProperties(JRPropertiesMap source, JRPropertiesHolder destination, java.lang.String tranferPropertiesPrefix)` Copies properties from one object to another.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_PROPERTIES_FILE

    protected static final java.lang.String DEFAULT_PROPERTIES_FILE

  The default properties file.

  See Also:
    Constant Field Values

### PROPERTY_PREFIX

    public static final java.lang.String PROPERTY_PREFIX

  The prefix used by all properties.

  See Also:
    Constant Field Values

### PROPERTIES_FILE

    public static final java.lang.String PROPERTIES_FILE

  The name of the system property that specifies the properties file name.

  See Also:
    Constant Field Values

### COMPILER_CLASS

    public static final java.lang.String COMPILER_CLASS

  Deprecated. Replaced by `JRCompiler.COMPILER_PREFIX`.
  The name of the class to be used for report compilation.

  No default value.

  See Also:
    Constant Field Values

### COMPILER_XML_VALIDATION

    public static final java.lang.String COMPILER_XML_VALIDATION

  Whether to validate the xml report when compiling.

  Defaults to `true`.

  See Also:
    Constant Field Values

### COMPILER_KEEP_JAVA_FILE

    public static final java.lang.String COMPILER_KEEP_JAVA_FILE

  Whether to keep the java file generated when the report is compiled.

  Defaults to `false`.

  See Also:
    Constant Field Values

### COMPILER_TEMP_DIR

    public static final java.lang.String COMPILER_TEMP_DIR

  The temporary directory used by the report compiler.

  Defaults to `System.getProperty("user.dir")`.

  See Also:
    Constant Field Values

### COMPILER_CLASSPATH

    public static final java.lang.String COMPILER_CLASSPATH

  The classpath used by the report compiler.

  Defaults to `System.getProperty("java.class.path")`.

  See Also:
    Constant Field Values

### EXPORT_XML_VALIDATION

    public static final java.lang.String EXPORT_XML_VALIDATION

  Validation flag used by the XML exporter.

  Defaults to `true`.

  See Also:
    Constant Field Values

### PDF_FONT_FILES_PREFIX

    public static final java.lang.String PDF_FONT_FILES_PREFIX

  Prefix of properties that specify font files for the PDF exporter.

  See Also:
    Constant Field Values

### PDF_FONT_DIRS_PREFIX

    public static final java.lang.String PDF_FONT_DIRS_PREFIX

  Prefix of properties that specify font directories for the PDF exporter.

  See Also:
    Constant Field Values

### QUERY_EXECUTER_FACTORY_PREFIX

    public static final java.lang.String QUERY_EXECUTER_FACTORY_PREFIX

  Deprecated. Replaced by `net.sf.jasperreports.engine.query`.
  See Also:
    Constant Field Values

### SUBREPORT_RUNNER_FACTORY

    public static final java.lang.String SUBREPORT_RUNNER_FACTORY

  Deprecated. Replaced by `JRSubreportRunnerFactory.SUBREPORT_RUNNER_FACTORY`.
  See Also:
    Constant Field Values

### PDF_FORCE_LINEBREAK_POLICY

    public static final java.lang.String PDF_FORCE_LINEBREAK_POLICY

  Deprecated. Replaced by `JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY`.
  See Also:
    Constant Field Values

### props

    protected static java.util.Properties props

### savedProps

    protected static java.util.Properties savedProps

Method Detail

### initProperties

    protected static void initProperties()

  Loads the properties.

### loadSystemProperties

    protected static void loadSystemProperties()

### getDefaults

    protected static java.util.Properties getDefaults()
                                               throws JRException

  Sets the default properties.

  Returns:
    the default properties
  Throws:
    `JRException`

### getSystemProperty

    protected static java.lang.String getSystemProperty(java.lang.String propertyName)

### loadSystemProperty

    protected static void loadSystemProperty(java.lang.String sysKey,
                                             java.lang.String propKey)

### loadProperties

    public static java.util.Properties loadProperties(java.lang.String name,
                                                      java.util.Properties defaults)
                                               throws JRException

  Loads a properties file from the classpath.

  Parameters:
    `name` - the resource name
    `defaults` - the default properties
  Returns:
    the loaded properties if the resource is found, `null` otherwise
  Throws:
    `JRException`

### getProperty

    public static java.lang.String getProperty(java.lang.String key)

  Returns the value of the property.

  Parameters:
    `key` - the key
  Returns:
    the property value

### getBooleanProperty

    public static boolean getBooleanProperty(java.lang.String key)

  Returns a property as a boolean value.

  Parameters:
    `key` - the key
  Returns:
    the property value as a boolean

### getIntegerProperty

    public static int getIntegerProperty(java.lang.String key)

  Returns a property as an integer value.

  Parameters:
    `key` - the key
  Returns:
    the property value as an integer

### getFloatProperty

    public static float getFloatProperty(java.lang.String key)

  Returns a property as a float value.

  Parameters:
    `key` - the key
  Returns:
    the property value as a float

### asBoolean

    public static boolean asBoolean(java.lang.String value)

  Converts a `String` value into a `boolean`.

  Parameters:
    `value` - the value
  Returns:
    the value as a `boolean`

### asInteger

    public static int asInteger(java.lang.String value)

  Converts a `String` value into a `int`.

  Parameters:
    `value` - the value
  Returns:
    the value as a `int`

### asFloat

    public static float asFloat(java.lang.String value)

  Converts a `String` value into a `float`.

  Parameters:
    `value` - the value
  Returns:
    the value as a `float`

### setProperty

    public static void setProperty(java.lang.String key,
                                   java.lang.String value)

  Sets the value of a property.

  Parameters:
    `key` - the key
    `value` - the value

### setProperty

    public static void setProperty(java.lang.String key,
                                   boolean value)

  Sets the value of a property.

  Parameters:
    `key` - the key
    `value` - the value

### removePropertyValue

    public static void removePropertyValue(java.lang.String key)

  Removes the value set for a property.

  This method removes values set in jasperreports.properties or via the `setProperty` method. Built-in default property values are not affected; if the property has a default value it will be used after calling this method for the property.

  Parameters:
    `key` - the property key

### backupProperties

    public static void backupProperties()

  Saves a copy of the current properties.

  See Also:
    `restoreProperties()`

### restoreProperties

    public static void restoreProperties()

  Restores previously saved properties.

  See Also:
    `backupProperties()`

### getProperties

    public static java.util.List getProperties(java.lang.String prefix)

  Returns the list of all properties for a key prefix.

  Parameters:
    `prefix` - the key prefix
  Returns:
    a list of `PropertySuffix` objects containing the suffix of the key and the value

### getProperties

    public static java.util.List getProperties(JRPropertiesHolder propertiesHolder,
                                               java.lang.String prefix)

  Returns the list of all properties for a key prefix. Only this holder's own properties are considered, and not global properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `prefix` - the key prefix
  Returns:
    a list of `PropertySuffix` objects containing the suffix of the key and the value
  See Also:
    `getAllProperties(JRPropertiesHolder, String)`

### getAllProperties

    public static java.util.List getAllProperties(JRPropertiesHolder propertiesHolder,
                                                  java.lang.String prefix)

  Returns the list of all properties for a key prefix, including global properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `prefix` - the key prefix
  Returns:
    a list of `PropertySuffix` objects containing the suffix of the key and the value
  See Also:
    `getProperties(JRPropertiesHolder, String)`

### getProperties

    public static java.util.List getProperties(JRPropertiesMap propertiesMap,
                                               java.lang.String prefix)

  Returns the list of all properties for a key prefix. Only properties from `propertiesMap` are considered, and not global properties.

  Parameters:
    `propertiesMap` - the properties map
    `prefix` - the key prefix
  Returns:
    a list of `PropertySuffix` objects containing the suffix of the key and the value
  See Also:
    `getAllProperties(JRPropertiesMap, String)`

### getAllProperties

    public static java.util.List getAllProperties(JRPropertiesMap propertiesMap,
                                                  java.lang.String prefix)

  Returns the list of all properties for a key prefix, including global properties.

  Parameters:
    `propertiesMap` - the properties map
    `prefix` - the key prefix
  Returns:
    a list of `PropertySuffix` objects containing the suffix of the key and the value
  See Also:
    `getProperties(JRPropertiesMap, String)`

### getProperty

    public static java.lang.String getProperty(JRPropertiesHolder propertiesHolder,
                                               java.lang.String key)

  Returns the value of a property, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `key` - the key
  Returns:
    the property value

### getProperty

    public static java.lang.String getProperty(JRPropertiesMap propertiesMap,
                                               java.lang.String key)

  Returns the value of a property, looking first in the supplied properties map and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
  Returns:
    the property value

### getBooleanProperty

    public static boolean getBooleanProperty(JRPropertiesHolder propertiesHolder,
                                             java.lang.String key,
                                             boolean defaultValue)

  Returns the value of a property as a boolean, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getBooleanProperty

    public static boolean getBooleanProperty(JRPropertiesMap propertiesMap,
                                             java.lang.String key,
                                             boolean defaultValue)

  Returns the value of a property as a boolean, looking first in the supplied properties map and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getIntegerProperty

    public static int getIntegerProperty(JRPropertiesHolder propertiesHolder,
                                         java.lang.String key,
                                         int defaultValue)

  Returns the value of a property as an integer, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getIntegerProperty

    public static int getIntegerProperty(JRPropertiesMap propertiesMap,
                                         java.lang.String key,
                                         int defaultValue)

  Returns the value of a property as an integer, looking first in the supplied properties map and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getIntegerProperty

    public static int getIntegerProperty(java.lang.String key,
                                         int defaultValue)

  Returns the value of a property as an integer.

  Parameters:
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getFloatProperty

    public static float getFloatProperty(JRPropertiesHolder propertiesHolder,
                                         java.lang.String key,
                                         float defaultValue)

  Returns the value of a property as a float, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getFloatProperty

    public static float getFloatProperty(JRPropertiesMap propertiesMap,
                                         java.lang.String key,
                                         float defaultValue)

  Returns the value of a property as a float, looking first in the supplied properties map and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getFloatProperty

    public static float getFloatProperty(java.lang.String key,
                                         float defaultValue)

  Returns the value of a property as a float.

  Parameters:
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### asLong

    public static long asLong(java.lang.String value)

  Converts a `String` value into a `long`.

  Parameters:
    `value` - the value
  Returns:
    the value as a `long`

### getLongProperty

    public static long getLongProperty(java.lang.String key)

  Returns a property as a long value.

  Parameters:
    `key` - the key
  Returns:
    the property value as a long

### getLongProperty

    public static long getLongProperty(JRPropertiesMap propertiesMap,
                                       java.lang.String key,
                                       int defaultValue)

  Returns the value of a property as a long, looking first in the supplied properties map and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getLongProperty

    public static long getLongProperty(JRPropertiesHolder propertiesHolder,
                                       java.lang.String key,
                                       int defaultValue)

  Returns the value of a property as a long, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesHolder` - the properties holder
    `key` - the key
    `defaultValue` - the default value used if the property is not found
  Returns:
    the property value

### getOwnProperties

    protected static JRPropertiesMap getOwnProperties(JRPropertiesHolder propertiesHolder)

### transferProperties

    public static void transferProperties(JRPropertiesHolder source,
                                          JRPropertiesHolder destination,
                                          java.lang.String tranferPropertiesPrefix)

  Copies properties from one object to another.

  The properties to be copied are determined by one or more JasperReports properties having a specified prefix. The values of these properties are interpreted as prefixes of properties to copy.

  Parameters:
    `source` - the source properties holder
    `destination` - the destination properties holder
    `tranferPropertiesPrefix` - the prefix of the JasperReports properties that specify the object properties to copy

### transferProperties

    public static void transferProperties(JRPropertiesMap source,
                                          JRPropertiesHolder destination,
                                          java.lang.String tranferPropertiesPrefix)

  Copies properties from one object to another.

  Parameters:
    `source` - the source properties
    `destination` - the destination properties holder
    `tranferPropertiesPrefix` - the prefix of the JasperReports properties that specify the object properties to copy
  See Also:
    `transferProperties(JRPropertiesHolder, JRPropertiesHolder, String)`

### transfer

    protected static void transfer(JRPropertiesMap source,
                                   JRPropertiesHolder destination,
                                   java.lang.String tranferPropertiesPrefix)

### getCharacterProperty

    public static java.lang.Character getCharacterProperty(java.lang.String key)

  Returns a property as a `Character` value.

  Parameters:
    `key` - the key
  Returns:
    the property value as a `Character`
  See Also:
    `asCharacter(String)`

### getCharacterProperty

    public static java.lang.Character getCharacterProperty(JRPropertiesMap propertiesMap,
                                                           java.lang.String key)

  Returns the value of a property as a `Character` value, looking first in the supplied properties holder and then in the system properties.

  Parameters:
    `propertiesMap` - the properties map
    `key` - the key
  Returns:
    the property value as a `Character`

### asCharacter

    public static java.lang.Character asCharacter(java.lang.String value)

  Converts a `String` into a `Character` value.

  If the `String` value is null or the empty string, `null` is returned. Otherwise, the method returns the first character in the string.

  Parameters:
    `value` - the `String` value
  Returns:
    the value converted to `Character`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com