|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.beanutils.ConvertUtils
public class ConvertUtils
Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class.
For more details, see ConvertUtilsBean
which provides the
implementations for these methods.
ConvertUtilsBean
Constructor Summary | |
---|---|
ConvertUtils()
|
Method Summary | |
---|---|
static String |
convert(Object value)
Convert the specified value into a String. |
static Object |
convert(Object value,
Class targetType)
Convert the value to an object of the specified class (if possible). |
static Object |
convert(String[] values,
Class clazz)
Convert an array of specified values to an array of objects of the specified class (if possible). |
static Object |
convert(String value,
Class clazz)
Convert the specified value to an object of the specified class (if possible). |
static void |
deregister()
Remove all registered Converter s, and re-establish the
standard Converters. |
static void |
deregister(Class clazz)
Remove any registered Converter for the specified destination
Class . |
static boolean |
getDefaultBoolean()
Deprecated. Register replacement converters for Boolean.TYPE and Boolean.class instead |
static byte |
getDefaultByte()
Deprecated. Register replacement converters for Byte.TYPE and Byte.class instead |
static char |
getDefaultCharacter()
Deprecated. Register replacement converters for Character.TYPE and Character.class instead |
static double |
getDefaultDouble()
Deprecated. Register replacement converters for Double.TYPE and Double.class instead |
static float |
getDefaultFloat()
Deprecated. Register replacement converters for Float.TYPE and Float.class instead |
static int |
getDefaultInteger()
Deprecated. Register replacement converters for Integer.TYPE and Integer.class instead |
static long |
getDefaultLong()
Deprecated. Register replacement converters for Long.TYPE and Long.class instead |
static short |
getDefaultShort()
Deprecated. Register replacement converters for Short.TYPE and Short.class instead |
static Converter |
lookup(Class clazz)
Look up and return any registered Converter for the specified
destination class; if there is no registered Converter, return
null . |
static Converter |
lookup(Class sourceType,
Class targetType)
Look up and return any registered Converter for the specified
source and destination class; if there is no registered Converter,
return null . |
static void |
register(Converter converter,
Class clazz)
Register a custom Converter for the specified destination
Class , replacing any previously registered Converter. |
static void |
setDefaultBoolean(boolean newDefaultBoolean)
Deprecated. Register replacement converters for Boolean.TYPE and Boolean.class instead |
static void |
setDefaultByte(byte newDefaultByte)
Deprecated. Register replacement converters for Byte.TYPE and Byte.class instead |
static void |
setDefaultCharacter(char newDefaultCharacter)
Deprecated. Register replacement converters for Character.TYPE and Character.class instead |
static void |
setDefaultDouble(double newDefaultDouble)
Deprecated. Register replacement converters for Double.TYPE and Double.class instead |
static void |
setDefaultFloat(float newDefaultFloat)
Deprecated. Register replacement converters for Float.TYPE and Float.class instead |
static void |
setDefaultInteger(int newDefaultInteger)
Deprecated. Register replacement converters for Integer.TYPE and Integer.class instead |
static void |
setDefaultLong(long newDefaultLong)
Deprecated. Register replacement converters for Long.TYPE and Long.class instead |
static void |
setDefaultShort(short newDefaultShort)
Deprecated. Register replacement converters for Short.TYPE and Short.class instead |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConvertUtils()
Method Detail |
---|
public static boolean getDefaultBoolean()
public static void setDefaultBoolean(boolean newDefaultBoolean)
newDefaultBoolean
- The default Boolean valuepublic static byte getDefaultByte()
public static void setDefaultByte(byte newDefaultByte)
newDefaultByte
- The default Byte valuepublic static char getDefaultCharacter()
public static void setDefaultCharacter(char newDefaultCharacter)
newDefaultCharacter
- The default Character valuepublic static double getDefaultDouble()
public static void setDefaultDouble(double newDefaultDouble)
newDefaultDouble
- The default Double valuepublic static float getDefaultFloat()
public static void setDefaultFloat(float newDefaultFloat)
newDefaultFloat
- The default Float valuepublic static int getDefaultInteger()
public static void setDefaultInteger(int newDefaultInteger)
newDefaultInteger
- The default Integer valuepublic static long getDefaultLong()
public static void setDefaultLong(long newDefaultLong)
newDefaultLong
- The default Long valuepublic static short getDefaultShort()
public static void setDefaultShort(short newDefaultShort)
newDefaultShort
- The default Short valuepublic static String convert(Object value)
Convert the specified value into a String.
For more details see ConvertUtilsBean
.
value
- Value to be converted (may be null)
ConvertUtilsBean.convert(Object)
public static Object convert(String value, Class clazz)
Convert the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value.
For more details see ConvertUtilsBean
.
value
- Value to be converted (may be null)clazz
- Java class to be converted to
ConvertUtilsBean.convert(String, Class)
public static Object convert(String[] values, Class clazz)
Convert an array of specified values to an array of objects of the specified class (if possible).
For more details see ConvertUtilsBean
.
values
- Array of values to be convertedclazz
- Java array or element class to be converted to
ConvertUtilsBean.convert(String[], Class)
public static Object convert(Object value, Class targetType)
Convert the value to an object of the specified class (if possible).
value
- Value to be converted (may be null)targetType
- Class of the value to be converted to
ConversionException
- if thrown by an underlying Converterpublic static void deregister()
Remove all registered Converter
s, and re-establish the
standard Converters.
For more details see ConvertUtilsBean
.
ConvertUtilsBean.deregister()
public static void deregister(Class clazz)
Remove any registered Converter
for the specified destination
Class
.
For more details see ConvertUtilsBean
.
clazz
- Class for which to remove a registered ConverterConvertUtilsBean.deregister(Class)
public static Converter lookup(Class clazz)
Look up and return any registered Converter
for the specified
destination class; if there is no registered Converter, return
null
.
For more details see ConvertUtilsBean
.
clazz
- Class for which to return a registered Converter
Converter
or null
if not foundConvertUtilsBean.lookup(Class)
public static Converter lookup(Class sourceType, Class targetType)
Converter
for the specified
source and destination class; if there is no registered Converter,
return null
.
sourceType
- Class of the value being convertedtargetType
- Class of the value to be converted to
Converter
or null
if not foundpublic static void register(Converter converter, Class clazz)
Register a custom Converter
for the specified destination
Class
, replacing any previously registered Converter.
For more details see ConvertUtilsBean
.
converter
- Converter to be registeredclazz
- Destination class for conversions performed by this
ConverterConvertUtilsBean.register(Converter, Class)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |