Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.conversion.impl
Class DefaultTypeConverter

    java.lang.Object
      com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter

All Implemented Interfaces:
  TypeConverter

Direct Known Subclasses:
  ArrayConverter, CollectionConverter, DateConverter, EnumTypeConverter, NumberConverter, StringConverter, XWorkBasicConverter, XWorkConverter

    public abstract class DefaultTypeConverter

extends Object
implements TypeConverter

Default type conversion. Converts among numeric types and also strings. Contains the basic type mapping code from OGNL.

Author:
  Luke Blanshard (blanshlu@netscape.net), Drew Davidson (drew@ognl.org)

Field Summary
`protected static String` | `MILLISECOND_FORMAT`

Fields inherited from interface com.opensymphony.xwork2.conversion.TypeConverter
`NO_CONVERSION_POSSIBLE, TYPE_CONVERTER_CONTEXT_KEY`

Constructor Summary
`DefaultTypeConverter()`

Method Summary
`static BigDecimal` | `bigDecValue(Object value)` Evaluates the given object as a BigDecimal.
`static BigInteger` | `bigIntValue(Object value)` Evaluates the given object as a BigInteger.
`static boolean` | `booleanValue(Object value)` Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if it's a Number or a Character, returns true for non-zero objects; and otherwise returns true for non-null objects.
`Object` | `convertValue(Map<String,Object> context, Object value, Class toType)`
`Object` | `convertValue(Map<String,Object> context, Object target, Member member, String propertyName, Object value, Class toType)` Converts the given value to a given type.
`Object` | `convertValue(Object value, Class toType)` Returns the value converted numerically to the given class type This method also detects when arrays are being converted and converts the components of one array to the type of the other.
`static double` | `doubleValue(Object value)` Evaluates the given object as a double-precision floating-point number.
`Enum<?>` | `enumValue(Class toClass, Object o)`
`protected Locale` | `getLocale(Map<String,Object> context)`
`TypeConverter` | `getTypeConverter(Map<String,Object> context)`
`static long` | `longValue(Object value)` Evaluates the given object as a long integer.
`void` | `setContainer(Container container)`
`static String` | `stringValue(Object value)` Evaluates the given object as a String.
`static String` | `stringValue(Object value, boolean trim)` Evaluates the given object as a String and trims it if the trim flag is true.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MILLISECOND_FORMAT

    protected static String MILLISECOND_FORMAT

Constructor Detail

### DefaultTypeConverter

    public DefaultTypeConverter()

Method Detail

### setContainer

    public void setContainer(Container container)

### convertValue

    public Object convertValue(Map<String,Object> context,
                               Object value,
                               Class toType)

### convertValue

    public Object convertValue(Map<String,Object> context,
                               Object target,
                               Member member,
                               String propertyName,
                               Object value,
                               Class toType)

  Description copied from interface: `TypeConverter`
  Converts the given value to a given type. The OGNL context, target, member and name of property being set are given. This method should be able to handle conversion in general without any context, target, member or property name specified.

  Specified by:
    `convertValue` in interface `TypeConverter`
  Parameters:
    `context` - context under which the conversion is being done
    `target` - target object in which the property is being set
    `member` - member (Constructor, Method or Field) being set
    `propertyName` - property name being set
    `value` - value to be converted
    `toType` - type to which value is converted
  Returns:
    Converted value of type toType or TypeConverter.NoConversionPossible to indicate that the conversion was not possible.

### getTypeConverter

    public TypeConverter getTypeConverter(Map<String,Object> context)

### convertValue

    public Object convertValue(Object value,
                               Class toType)

  Returns the value converted numerically to the given class type This method also detects when arrays are being converted and converts the components of one array to the type of the other.

  Parameters:
    `value` - an object to be converted to the given type
    `toType` - class type to be converted to
  Returns:
    converted value of the type given, or value if the value cannot be converted to the given type.

### booleanValue

    public static boolean booleanValue(Object value)

  Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if it's a Number or a Character, returns true for non-zero objects; and otherwise returns true for non-null objects.

  Parameters:
    `value` - an object to interpret as a boolean
  Returns:
    the boolean value implied by the given object

### enumValue

    public Enum<?> enumValue(Class toClass,
                             Object o)

### longValue

    public static long longValue(Object value)
                          throws NumberFormatException

  Evaluates the given object as a long integer.

  Parameters:
    `value` - an object to interpret as a long integer
  Returns:
    the long integer value implied by the given object
  Throws:
    `NumberFormatException` - if the given object can't be understood as a long integer

### doubleValue

    public static double doubleValue(Object value)
                              throws NumberFormatException

  Evaluates the given object as a double-precision floating-point number.

  Parameters:
    `value` - an object to interpret as a double
  Returns:
    the double value implied by the given object
  Throws:
    `NumberFormatException` - if the given object can't be understood as a double

### bigIntValue

    public static BigInteger bigIntValue(Object value)
                                  throws NumberFormatException

  Evaluates the given object as a BigInteger.

  Parameters:
    `value` - an object to interpret as a BigInteger
  Returns:
    the BigInteger value implied by the given object
  Throws:
    `NumberFormatException` - if the given object can't be understood as a BigInteger

### bigDecValue

    public static BigDecimal bigDecValue(Object value)
                                  throws NumberFormatException

  Evaluates the given object as a BigDecimal.

  Parameters:
    `value` - an object to interpret as a BigDecimal
  Returns:
    the BigDecimal value implied by the given object
  Throws:
    `NumberFormatException` - if the given object can't be understood as a BigDecimal

### stringValue

    public static String stringValue(Object value,
                                     boolean trim)

  Evaluates the given object as a String and trims it if the trim flag is true.

  Parameters:
    `value` - an object to interpret as a String
  Returns:
    the String value implied by the given object as returned by the toString() method, or "null" if the object is null.

### stringValue

    public static String stringValue(Object value)

  Evaluates the given object as a String.

  Parameters:
    `value` - an object to interpret as a String
  Returns:
    the String value implied by the given object as returned by the toString() method, or "null" if the object is null.

### getLocale

    protected Locale getLocale(Map<String,Object> context)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000–2018 Apache Software Foundation. All rights reserved.