|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.PropertyConverter
public final class PropertyConverter
A utility class to convert the configuration properties into any type.
Field Summary | |
---|---|
private static java.lang.Class[] |
CONSTR_ARGS
Constant for the argument classes of the Number constructor that takes a String. |
private static java.lang.String |
HEX_PREFIX
Constant for the prefix of hex numbers. |
private static int |
HEX_RADIX
Constant for the radix of hex numbers. |
private static java.lang.String |
INTERNET_ADDRESS_CLASSNAME
The fully qualified name of javax.mail.internet.InternetAddress |
private static float |
JAVA_VERSION_1_5
Constant for the Java version 1.5. |
(package private) static char |
LIST_ESC_CHAR
Constant for the list delimiter as char. |
(package private) static java.lang.String |
LIST_ESCAPE
Constant for the list delimiter escaping character as string. |
Constructor Summary | |
---|---|
private |
PropertyConverter()
Private constructor prevents instances from being created. |
Method Summary | |
---|---|
static java.lang.String |
escapeDelimiters(java.lang.String s,
char delimiter)
Escapes the delimiters that might be contained in the given string. |
static java.lang.Object |
interpolate(java.lang.Object value,
AbstractConfiguration config)
Performs interpolation of the specified value. |
(package private) static boolean |
isEnum(java.lang.Class cls)
Calls Class.isEnum() on Java 5, returns false on older JRE. |
static java.util.List |
split(java.lang.String s,
char delimiter)
Split a string on the specified delimiter. |
(package private) static java.lang.Object |
to(java.lang.Class cls,
java.lang.Object value,
java.lang.Object[] params)
Converts the specified value to the target class. |
static java.math.BigDecimal |
toBigDecimal(java.lang.Object value)
Convert the specified object into a BigDecimal. |
static java.math.BigInteger |
toBigInteger(java.lang.Object value)
Convert the specified object into a BigInteger. |
static java.lang.Boolean |
toBoolean(java.lang.Object value)
Convert the specified object into a Boolean. |
static java.lang.Byte |
toByte(java.lang.Object value)
Convert the specified object into a Byte. |
static java.util.Calendar |
toCalendar(java.lang.Object value,
java.lang.String format)
Convert the specified object into a Calendar. |
static java.awt.Color |
toColor(java.lang.Object value)
Convert the specified object into a Color. |
static java.util.Date |
toDate(java.lang.Object value,
java.lang.String format)
Convert the specified object into a Date. |
static java.lang.Double |
toDouble(java.lang.Object value)
Convert the specified object into a Double. |
(package private) static java.lang.Object |
toEnum(java.lang.Object value,
java.lang.Class cls)
Convert the specified value into a Java 5 enum. |
static java.lang.Float |
toFloat(java.lang.Object value)
Convert the specified object into a Float. |
(package private) static java.net.InetAddress |
toInetAddress(java.lang.Object value)
Convert the specified value into an internet address. |
static java.lang.Integer |
toInteger(java.lang.Object value)
Convert the specified object into an Integer. |
(package private) static java.lang.Object |
toInternetAddress(java.lang.Object value)
Convert the specified value into an email address. |
static java.util.Iterator |
toIterator(java.lang.Object value,
char delimiter)
Return an iterator over the simple values of a composite value. |
static java.util.Locale |
toLocale(java.lang.Object value)
Convert the specified object into a Locale. |
static java.lang.Long |
toLong(java.lang.Object value)
Convert the specified object into a Long. |
(package private) static java.lang.Number |
toNumber(java.lang.Object value,
java.lang.Class targetClass)
Tries to convert the specified object into a number object. |
static java.lang.Short |
toShort(java.lang.Object value)
Convert the specified object into a Short. |
static java.net.URL |
toURL(java.lang.Object value)
Convert the specified object into an URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final char LIST_ESC_CHAR
static final java.lang.String LIST_ESCAPE
private static final java.lang.String HEX_PREFIX
private static final int HEX_RADIX
private static final float JAVA_VERSION_1_5
private static final java.lang.Class[] CONSTR_ARGS
private static final java.lang.String INTERNET_ADDRESS_CLASSNAME
javax.mail.internet.InternetAddress
Constructor Detail |
---|
private PropertyConverter()
Method Detail |
---|
static java.lang.Object to(java.lang.Class cls, java.lang.Object value, java.lang.Object[] params) throws ConversionException
cls
- the target class of the converted valuevalue
- the value to convertparams
- optional parameters used for the conversion
ConversionException
- if the value is not compatible with the requested typepublic static java.lang.Boolean toBoolean(java.lang.Object value) throws ConversionException
org.apache.commons.lang.BooleanUtils
class from the
Commons Lang
project is used to perform this conversion. This class accepts some more
tokens for the boolean value of true, e.g. yes
and
on
. Please refer to the documentation of this class for more
details.
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a booleanpublic static java.lang.Byte toByte(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a bytepublic static java.lang.Short toShort(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a shortpublic static java.lang.Integer toInteger(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to an integerpublic static java.lang.Long toLong(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a Longpublic static java.lang.Float toFloat(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a Floatpublic static java.lang.Double toDouble(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a Doublepublic static java.math.BigInteger toBigInteger(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a BigIntegerpublic static java.math.BigDecimal toBigDecimal(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a BigDecimalstatic java.lang.Number toNumber(java.lang.Object value, java.lang.Class targetClass) throws ConversionException
value
- the value to be converted (must not be null)targetClass
- the target class of the conversion (must be derived
from java.lang.Number
)
ConversionException
- if the object cannot be convertedpublic static java.net.URL toURL(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to an URLpublic static java.util.Locale toLocale(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a Localepublic static java.util.List split(java.lang.String s, char delimiter)
s
- the string to splitdelimiter
- the delimiter
public static java.lang.String escapeDelimiters(java.lang.String s, char delimiter)
s
- the string with the valuedelimiter
- the list delimiter to use
public static java.awt.Color toColor(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a Colorstatic java.net.InetAddress toInetAddress(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to a InetAddressstatic java.lang.Object toInternetAddress(java.lang.Object value) throws ConversionException
value
- the value to convert
ConversionException
- thrown if the value cannot be converted to an email addressstatic boolean isEnum(java.lang.Class cls)
static java.lang.Object toEnum(java.lang.Object value, java.lang.Class cls) throws ConversionException
value
- the value to convertcls
- the type of the enumeration
ConversionException
- thrown if the value cannot be converted to an enumerationpublic static java.util.Date toDate(java.lang.Object value, java.lang.String format) throws ConversionException
value
- the value to convertformat
- the DateFormat pattern to parse String values
ConversionException
- thrown if the value cannot be converted to a Calendarpublic static java.util.Calendar toCalendar(java.lang.Object value, java.lang.String format) throws ConversionException
value
- the value to convertformat
- the DateFormat pattern to parse String values
ConversionException
- thrown if the value cannot be converted to a Calendarpublic static java.util.Iterator toIterator(java.lang.Object value, char delimiter)
value
- the value to "split"delimiter
- the delimiter for String values
public static java.lang.Object interpolate(java.lang.Object value, AbstractConfiguration config)
${...}
. If
this is the case, all occurrances will be substituted by their current
values.
value
- the value to be interpolatedconfig
- the current configuration object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |