org.apache.commons.beanutils
クラス ConvertUtils

java.lang.Object
  |
  +--org.apache.commons.beanutils.ConvertUtils

public class ConvertUtils
extends java.lang.Object

Utility methods for converting String values to objects of the specified class. If you specify a Java primitive type, or an array of a Java primitive type, as a destination type, a scalar or array of the coresponding Java wrapper class will be created instead. If you attempt to convert an Object or Object array of a non-String and non-primitive type, it will be converted to a scalar String or array of Strings, as appropriate.

バージョン:
$Revision: 1.3 $ $Date: 2001/09/15 05:06:26 $
作成者:
Craig R. McClanahan, Ralph Schaer, Chris Audley

フィールドの概要
private static java.lang.Boolean defaultBoolean
          The default value for Boolean conversions.
private static java.lang.Byte defaultByte
          The default value for Byte conversions.
private static java.lang.Character defaultCharacter
          The default value for Character conversions.
private static java.lang.Double defaultDouble
          The default value for Double conversions.
private static java.lang.Float defaultFloat
          The default value for Float conversions.
private static java.lang.Integer defaultInteger
          The default value for Integer conversions.
private static java.lang.Long defaultLong
          The default value for Long conversions.
private static java.lang.Short defaultShort
          The default value for Short conversions.
private static java.lang.Class stringClass
          The Class object for java.lang.String.
 
コンストラクタの概要
ConvertUtils()
           
 
メソッドの概要
static java.lang.String convert(java.lang.Object value)
          Convert the specified value into a String.
static java.lang.Object convert(java.lang.String[] values, java.lang.Class clazz)
          Convert an array of specified values to an array of objects of the specified class (if possible).
static java.lang.Object convert(java.lang.String value, java.lang.Class clazz)
          Convert the specified value to an object of the specified class (if possible).
private static java.lang.Boolean convertBoolean(java.lang.String value, java.lang.Boolean defaultValue)
          Convert a String value to a corresponding Boolean value.
private static java.lang.Byte convertByte(java.lang.String value, java.lang.Byte defaultValue)
          Convert a String value to a corresponding Byte value.
private static java.lang.Character convertCharacter(java.lang.String value, java.lang.Character defaultValue)
          Convert a String value to a corresponding Character value.
private static java.lang.Double convertDouble(java.lang.String value, java.lang.Double defaultValue)
          Convert a String value to a corresponding Double value.
private static java.lang.Float convertFloat(java.lang.String value, java.lang.Float defaultValue)
          Convert a String value to a corresponding Float value.
private static java.lang.Integer convertInteger(java.lang.String value, java.lang.Integer defaultValue)
          Convert a String value to a corresponding Integer value.
private static java.lang.Long convertLong(java.lang.String value, java.lang.Long defaultValue)
          Convert a String value to a corresponding Long value.
private static java.lang.Short convertShort(java.lang.String value, java.lang.Short defaultValue)
          Convert a String value to a corresponding Short value.
static boolean getDefaultBoolean()
           
static byte getDefaultByte()
           
static char getDefaultCharacter()
           
static double getDefaultDouble()
           
static float getDefaultFloat()
           
static int getDefaultInteger()
           
static long getDefaultLong()
           
static short getDefaultShort()
           
static void setDefaultBoolean(boolean newDefaultBoolean)
           
static void setDefaultByte(byte newDefaultByte)
           
static void setDefaultCharacter(char newDefaultCharacter)
           
static void setDefaultDouble(double newDefaultDouble)
           
static void setDefaultFloat(float newDefaultFloat)
           
static void setDefaultInteger(int newDefaultInteger)
           
static void setDefaultLong(long newDefaultLong)
           
static void setDefaultShort(short newDefaultShort)
           
 
クラス java.lang.Object から継承したメソッド
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

フィールドの詳細

defaultBoolean

private static java.lang.Boolean defaultBoolean
The default value for Boolean conversions.

defaultByte

private static java.lang.Byte defaultByte
The default value for Byte conversions.

defaultCharacter

private static java.lang.Character defaultCharacter
The default value for Character conversions.

defaultDouble

private static java.lang.Double defaultDouble
The default value for Double conversions.

defaultFloat

private static java.lang.Float defaultFloat
The default value for Float conversions.

defaultInteger

private static java.lang.Integer defaultInteger
The default value for Integer conversions.

defaultLong

private static java.lang.Long defaultLong
The default value for Long conversions.

defaultShort

private static java.lang.Short defaultShort
The default value for Short conversions.

stringClass

private static java.lang.Class stringClass
The Class object for java.lang.String.
コンストラクタの詳細

ConvertUtils

public ConvertUtils()
メソッドの詳細

getDefaultBoolean

public static boolean getDefaultBoolean()

setDefaultBoolean

public static void setDefaultBoolean(boolean newDefaultBoolean)

getDefaultByte

public static byte getDefaultByte()

setDefaultByte

public static void setDefaultByte(byte newDefaultByte)

getDefaultCharacter

public static char getDefaultCharacter()

setDefaultCharacter

public static void setDefaultCharacter(char newDefaultCharacter)

getDefaultDouble

public static double getDefaultDouble()

setDefaultDouble

public static void setDefaultDouble(double newDefaultDouble)

getDefaultFloat

public static float getDefaultFloat()

setDefaultFloat

public static void setDefaultFloat(float newDefaultFloat)

getDefaultInteger

public static int getDefaultInteger()

setDefaultInteger

public static void setDefaultInteger(int newDefaultInteger)

getDefaultLong

public static long getDefaultLong()

setDefaultLong

public static void setDefaultLong(long newDefaultLong)

getDefaultShort

public static short getDefaultShort()

setDefaultShort

public static void setDefaultShort(short newDefaultShort)

convert

public static java.lang.String convert(java.lang.Object value)
Convert the specified value into a String. If the specified value is an array, the first element (converted to a String) will be returned.
パラメータ:
value - Value to be converted (may be null)

convert

public static java.lang.Object convert(java.lang.String value,
                                       java.lang.Class clazz)
Convert the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value. If you specify type as the name of a Java primitive type, an instance of the corresponding wrapper class (initialized to the correct value) is returned instead.
パラメータ:
value - Value to be converted (may be null)
clazz - Java class to be converted to (must be java.lang.String or one of the primitive type wrappers)

convert

public static java.lang.Object convert(java.lang.String[] values,
                                       java.lang.Class clazz)
Convert an array of specified values to an array of objects of the specified class (if possible). If you specify type as one of the Java primitive types, an array of that type will be returned; otherwise an array of the requested type (must be String or a Java wrapper class for the primitive types) will be returned.
パラメータ:
value - Value to be converted (may be null)
clazz - Java array class to be converted to (must be String[], or an array of one of the Java primitive types)

convertBoolean

private static java.lang.Boolean convertBoolean(java.lang.String value,
                                                java.lang.Boolean defaultValue)
Convert a String value to a corresponding Boolean value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertByte

private static java.lang.Byte convertByte(java.lang.String value,
                                          java.lang.Byte defaultValue)
Convert a String value to a corresponding Byte value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertCharacter

private static java.lang.Character convertCharacter(java.lang.String value,
                                                    java.lang.Character defaultValue)
Convert a String value to a corresponding Character value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertDouble

private static java.lang.Double convertDouble(java.lang.String value,
                                              java.lang.Double defaultValue)
Convert a String value to a corresponding Double value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertFloat

private static java.lang.Float convertFloat(java.lang.String value,
                                            java.lang.Float defaultValue)
Convert a String value to a corresponding Float value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertInteger

private static java.lang.Integer convertInteger(java.lang.String value,
                                                java.lang.Integer defaultValue)
Convert a String value to a corresponding Integer value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertLong

private static java.lang.Long convertLong(java.lang.String value,
                                          java.lang.Long defaultValue)
Convert a String value to a corresponding Long value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error

convertShort

private static java.lang.Short convertShort(java.lang.String value,
                                            java.lang.Short defaultValue)
Convert a String value to a corresponding Short value.
パラメータ:
value - The string value to convert
defaultValue - Default value to return on a conversion error


Copyright (c) 2001 - Apache Software Foundation