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 |
EXCEPTION_MESSAGE_KEY_LOAD_PROPERTIES_FAILURE |
static String |
EXCEPTION_MESSAGE_KEY_LOAD_PROPERTIES_FILE_FAILURE |
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 double |
asDouble(String value)
Converts a
String value into a double . |
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)
Returns the value of a property as a Boolean, looking first in the supplied properties holder
and then in the system 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)
Returns the value of a property as a boolean, looking first in the supplied properties map
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.
|
boolean |
getBooleanProperty(String key,
boolean defaultValue)
Returns a property as a boolean value.
|
boolean |
getBooleanProperty(String key,
boolean defaultValue,
JRPropertiesHolder... propertiesHolders)
Returns the value of a property as a boolean, looking first in several properties holders
and then in the system properties.
|
Character |
getCharacterProperty(JRPropertiesHolder propertiesHolder,
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(JRPropertiesMap propertiesMap,
String key)
Returns the value of a property as a
Character value,
looking first in the supplied properties map
and then in the system properties. |
Character |
getCharacterProperty(String key)
Returns a property as a
Character value. |
Double |
getDoubleProperty(JRPropertiesHolder propertiesHolder,
String key)
Returns the value of a property as a Double, looking first in the supplied properties holder
and then in the system properties.
|
Float |
getFloatProperty(JRPropertiesHolder propertiesHolder,
String key)
Returns the value of a property as a Float, looking first in the supplied properties holder
and then in the system properties.
|
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.
|
float |
getFloatProperty(String key,
float defaultValue,
JRPropertiesHolder... propertiesHolders)
Returns the value of a property as a float, looking first in several properties holders
and then in the system properties.
|
static JRPropertiesUtil |
getInstance(JasperReportsContext jasperReportsContext) |
Integer |
getIntegerProperty(JRPropertiesHolder propertiesHolder,
String key)
Returns the value of a property as an Integer, looking first in the supplied properties holder
and then in the system properties.
|
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.
|
Integer |
getIntegerProperty(JRPropertiesMap propertiesMap,
String key)
Returns the value of a property as an Integer, looking first in the supplied properties map
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.
|
String |
getLocalizedProperty(String property,
Locale locale) |
long |
getLongProperty(JRPropertiesHolder propertiesHolder,
String key,
long 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,
long 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.
|
long |
getLongProperty(String key,
long defaultValue)
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(JRPropertiesHolder propertiesHolder,
String key,
String defaultValue)
Returns the value of a property, looking first in the supplied properties holder
and then in the system properties, using a default value if the property is not found.
|
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,
List<String> propertyNames) |
void |
transferProperties(JRPropertiesMap source,
JRPropertiesHolder destination,
String tranferPropertiesPrefix)
Copies properties from one object to another.
|
public static final String PROPERTY_PREFIX
public static final String EXCEPTION_MESSAGE_KEY_LOAD_PROPERTIES_FILE_FAILURE
public static final String EXCEPTION_MESSAGE_KEY_LOAD_PROPERTIES_FAILURE
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 boolean getBooleanProperty(String key, boolean defaultValue)
key
- the keydefaultValue
- the default valuepublic 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 static double asDouble(String value)
String
value into a double
.value
- the valuedouble
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(JRPropertiesHolder propertiesHolder, String key, String defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the value to return if no property is foundpublic 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(String key, boolean defaultValue, JRPropertiesHolder... propertiesHolders)
key
- the keydefaultValue
- the default value used if the property is not foundpropertiesHolders
- the properties holderspublic boolean getBooleanProperty(JRPropertiesMap propertiesMap, String key, boolean defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic Boolean getBooleanProperty(JRPropertiesMap propertiesMap, String key)
propertiesMap
- the properties mapkey
- the keypublic Boolean getBooleanProperty(JRPropertiesHolder propertiesHolder, String key)
propertiesHolder
- the properties holderkey
- the keypublic Integer getIntegerProperty(JRPropertiesMap propertiesMap, String key)
propertiesMap
- the properties mapkey
- the keypublic Integer getIntegerProperty(JRPropertiesHolder propertiesHolder, String key)
propertiesHolder
- the properties holderkey
- the keypublic 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)
propertiesHolder
- the properties holderkey
- the keypublic 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(String key, float defaultValue, JRPropertiesHolder... propertiesHolders)
key
- the keydefaultValue
- the default value used if the property is not foundpropertiesHolders
- the properties holderspublic 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(String key, long defaultValue)
key
- the keydefaultValue
- the default valuepublic long getLongProperty(JRPropertiesMap propertiesMap, String key, long defaultValue)
propertiesMap
- the properties mapkey
- the keydefaultValue
- the default value used if the property is not foundpublic long getLongProperty(JRPropertiesHolder propertiesHolder, String key, long defaultValue)
propertiesHolder
- the properties holderkey
- the keydefaultValue
- the default value used if the property is not foundpublic Double getDoubleProperty(JRPropertiesHolder propertiesHolder, String key)
propertiesHolder
- the properties holderkey
- the keyprotected 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)
public void transferProperties(JRPropertiesMap source, JRPropertiesHolder destination, List<String> propertyNames)
protected void transfer(JRPropertiesMap source, JRPropertiesHolder destination, String tranferPropertiesPrefix)
public Character getCharacterProperty(String key)
Character
value.key
- the keyCharacter
asCharacter(String)
public Character getCharacterProperty(JRPropertiesHolder propertiesHolder, String key)
Character
value,
looking first in the supplied properties holder and then in the
system properties.propertiesHolder
- the properties holderkey
- the keyCharacter
public Character getCharacterProperty(JRPropertiesMap propertiesMap, String key)
Character
value,
looking first in the supplied properties map
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 © 2023 Cloud Software Group, Inc.. All rights reserved.