public final class JRPropertiesUtil extends Object
The following actions are performed:
Modifier and Type | Class and Description |
---|---|
static class |
JRPropertiesUtil.PropertySuffix
Class used by
getProperties(String) . |
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_PREFIX
The prefix used by all properties.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
asBoolean(String value)
Converts a
String value into a boolean . |
static boolean |
asBoolean(String value,
boolean defaultValue) |
static Character |
asCharacter(String value)
Converts a
String into a Character value. |
static float |
asFloat(String value)
Converts a
String value into a float . |
static int |
asInteger(String value)
Converts a
String value into a int . |
static long |
asLong(String value)
Converts a
String value into a long . |
List<JRPropertiesUtil.PropertySuffix> |
getAllProperties(JRPropertiesHolder propertiesHolder,
String prefix)
Returns the list of all properties for a key prefix, including global
properties.
|
List<JRPropertiesUtil.PropertySuffix> |
getAllProperties(JRPropertiesMap propertiesMap,
String prefix)
Returns the list of all properties for a key prefix, including global
properties.
|
boolean |
getBooleanProperty(JRPropertiesHolder propertiesHolder,
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.
|
boolean |
getBooleanProperty(JRPropertiesMap propertiesMap,
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.
|
boolean |
getBooleanProperty(String key)
Returns a property as a boolean value.
|
Character |
getCharacterProperty(JRPropertiesMap propertiesMap,
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. |
Character |
getCharacterProperty(String key)
Returns a property as a
Character value. |
float |
getFloatProperty(JRPropertiesHolder propertiesHolder,
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.
|
float |
getFloatProperty(JRPropertiesMap propertiesMap,
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.
|
float |
getFloatProperty(String key)
Returns a property as a float value.
|
float |
getFloatProperty(String key,
float defaultValue)
Returns the value of a property as a float.
|
static JRPropertiesUtil |
getInstance(JasperReportsContext jasperReportsContext) |
int |
getIntegerProperty(JRPropertiesHolder propertiesHolder,
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.
|
int |
getIntegerProperty(JRPropertiesMap propertiesMap,
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.
|
int |
getIntegerProperty(String key)
Returns a property as an integer value.
|
int |
getIntegerProperty(String key,
int defaultValue)
Returns the value of a property as an integer.
|
long |
getLongProperty(JRPropertiesHolder propertiesHolder,
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.
|
long |
getLongProperty(JRPropertiesMap propertiesMap,
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.
|
long |
getLongProperty(String key)
Returns a property as a long value.
|
protected static JRPropertiesMap |
getOwnProperties(JRPropertiesHolder propertiesHolder) |
static String |
getOwnProperty(JRPropertiesHolder propertiesHolder,
String key) |
static List<JRPropertiesUtil.PropertySuffix> |
getProperties(JRPropertiesHolder propertiesHolder,
String prefix)
Returns the list of all properties for a key prefix.
|
static List<JRPropertiesUtil.PropertySuffix> |
getProperties(JRPropertiesMap propertiesMap,
String prefix)
Returns the list of all properties for a key prefix.
|
List<JRPropertiesUtil.PropertySuffix> |
getProperties(String prefix)
Returns the list of all properties for a key prefix.
|
String |
getProperty(JRPropertiesHolder propertiesHolder,
String key)
Returns the value of a property, looking first in the supplied properties holder
and then in the system properties.
|
String |
getProperty(JRPropertiesMap propertiesMap,
String key)
Returns the value of a property, looking first in the supplied properties map
and then in the system properties.
|
String |
getProperty(String key)
Returns the value of the property.
|
String |
getProperty(String key,
JRPropertiesHolder... propertiesHolders)
Returns the value of a property, looking for it in several properties holders
and then in the system properties.
|
static Properties |
loadProperties(String name,
Properties defaults)
Loads a properties file from the classpath.
|
void |
removeProperty(String key) |
void |
setProperty(String key,
String value) |
protected void |
transfer(JRPropertiesMap source,
JRPropertiesHolder destination,
String tranferPropertiesPrefix) |
void |
transferProperties(JRPropertiesHolder source,
JRPropertiesHolder destination,
String tranferPropertiesPrefix)
Copies properties from one object to another.
|
void |
transferProperties(JRPropertiesMap source,
JRPropertiesHolder destination,
String tranferPropertiesPrefix)
Copies properties from one object to another.
|
public static final String PROPERTY_PREFIX
public static JRPropertiesUtil getInstance(JasperReportsContext jasperReportsContext)
public static Properties loadProperties(String name, Properties defaults) throws JRException
name
- the resource namedefaults
- the default propertiesnull
otherwiseJRException
public String getProperty(String key)
key
- the keypublic void removeProperty(String key)
public boolean getBooleanProperty(String key)
key
- the keypublic int getIntegerProperty(String key)
key
- the keypublic float getFloatProperty(String key)
key
- the keypublic static boolean asBoolean(String value)
String
value into a boolean
.value
- the valueboolean
public static boolean asBoolean(String value, boolean defaultValue)
public static int asInteger(String value)
String
value into a int
.value
- the valueint
public static float asFloat(String value)
String
value into a float
.value
- the valuefloat
public List<JRPropertiesUtil.PropertySuffix> getProperties(String prefix)
prefix
- the key prefixPropertySuffix
objects containing the suffix of the key and the valuepublic static List<JRPropertiesUtil.PropertySuffix> getProperties(JRPropertiesHolder propertiesHolder, String prefix)
propertiesHolder
- the properties holderprefix
- the key prefixPropertySuffix
objects containing the suffix of the key and the valuegetAllProperties(JRPropertiesHolder, String)
public List<JRPropertiesUtil.PropertySuffix> getAllProperties(JRPropertiesHolder propertiesHolder, String prefix)
propertiesHolder
- the properties holderprefix
- the key prefixPropertySuffix
objects containing the suffix of the key and the valuegetProperties(JRPropertiesHolder, String)
public static List<JRPropertiesUtil.PropertySuffix> getProperties(JRPropertiesMap propertiesMap, String prefix)
propertiesMap
are considered, and
not global properties.propertiesMap
- the properties mapprefix
- the key prefixPropertySuffix
objects containing the suffix of the key and the valuegetAllProperties(JRPropertiesMap, String)
public List<JRPropertiesUtil.PropertySuffix> getAllProperties(JRPropertiesMap propertiesMap, String prefix)
propertiesMap
- the properties mapprefix
- the key prefixPropertySuffix
objects containing the suffix of the key and the valuegetProperties(JRPropertiesMap, String)
public String getProperty(JRPropertiesHolder propertiesHolder, String key)
propertiesHolder
- the properties holderkey
- the keypublic String getProperty(String key, JRPropertiesHolder... propertiesHolders)
key
- the keypropertiesHolders
- the properties holderspublic String getProperty(JRPropertiesMap propertiesMap, String key)
propertiesMap
- the properties mapkey
- the keypublic boolean getBooleanProperty(JRPropertiesHolder propertiesHolder, String key, boolean defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the default value used if the property is not foundpublic boolean getBooleanProperty(JRPropertiesMap propertiesMap, String key, boolean defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic int getIntegerProperty(JRPropertiesHolder propertiesHolder, String key, int defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the default value used if the property is not foundpublic int getIntegerProperty(JRPropertiesMap propertiesMap, String key, int defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic int getIntegerProperty(String key, int defaultValue)
key
- the keydefaultValue
- the default value used if the property is not foundpublic float getFloatProperty(JRPropertiesHolder propertiesHolder, String key, float defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the default value used if the property is not foundpublic float getFloatProperty(JRPropertiesMap propertiesMap, String key, float defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic float getFloatProperty(String key, float defaultValue)
key
- the keydefaultValue
- the default value used if the property is not foundpublic static long asLong(String value)
String
value into a long
.value
- the valuelong
public long getLongProperty(String key)
key
- the keypublic long getLongProperty(JRPropertiesMap propertiesMap, String key, int defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic long getLongProperty(JRPropertiesHolder propertiesHolder, String key, int defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the default value used if the property is not foundprotected static JRPropertiesMap getOwnProperties(JRPropertiesHolder propertiesHolder)
public void transferProperties(JRPropertiesHolder source, JRPropertiesHolder destination, String tranferPropertiesPrefix)
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.
source
- the source properties holderdestination
- the destination properties holdertranferPropertiesPrefix
- the prefix of the JasperReports properties
that specify the object properties to copypublic void transferProperties(JRPropertiesMap source, JRPropertiesHolder destination, String tranferPropertiesPrefix)
source
- the source propertiesdestination
- the destination properties holdertranferPropertiesPrefix
- the prefix of the JasperReports properties
that specify the object properties to copytransferProperties(JRPropertiesHolder, JRPropertiesHolder, String)
protected void transfer(JRPropertiesMap source, JRPropertiesHolder destination, String tranferPropertiesPrefix)
public Character getCharacterProperty(String key)
Character
value.key
- the keyCharacter
asCharacter(String)
public Character getCharacterProperty(JRPropertiesMap propertiesMap, String key)
Character
value,
looking first in the supplied properties holder and then in the
system properties.propertiesMap
- the properties mapkey
- the keyCharacter
public static Character asCharacter(String value)
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.
value
- the String
valueCharacter
public static String getOwnProperty(JRPropertiesHolder propertiesHolder, String key)
Copyright © 2013. All Rights Reserved.