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:
  EnumTypeConverter, XWorkBasicConverter, XWorkConverter

    public class DefaultTypeConverter

extends java.lang.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

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

Constructor Summary
`DefaultTypeConverter()`

Method Summary
`static java.math.BigDecimal` | `bigDecValue(java.lang.Object value)` Evaluates the given object as a BigDecimal.
`static java.math.BigInteger` | `bigIntValue(java.lang.Object value)` Evaluates the given object as a BigInteger.
`static boolean` | `booleanValue(java.lang.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.
`java.lang.Object` | `convertValue(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object value, java.lang.Class toType)`
`java.lang.Object` | `convertValue(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object target, java.lang.reflect.Member member, java.lang.String propertyName, java.lang.Object value, java.lang.Class toType)` Converts the given value to a given type.
`java.lang.Object` | `convertValue(java.lang.Object value, java.lang.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(java.lang.Object value)` Evaluates the given object as a double-precision floating-point number.
`java.lang.Enum<?>` | `enumValue(java.lang.Class toClass, java.lang.Object o)`
`TypeConverter` | `getTypeConverter(java.util.Map<java.lang.String,java.lang.Object> context)`
`static long` | `longValue(java.lang.Object value)` Evaluates the given object as a long integer.
`static java.lang.String` | `stringValue(java.lang.Object value)` Evaluates the given object as a String.
`static java.lang.String` | `stringValue(java.lang.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`

Constructor Detail

### DefaultTypeConverter

    public DefaultTypeConverter()

Method Detail

### convertValue

    public java.lang.Object convertValue(java.util.Map<java.lang.String,java.lang.Object> context,
                                         java.lang.Object value,
                                         java.lang.Class toType)

### convertValue

    public java.lang.Object convertValue(java.util.Map<java.lang.String,java.lang.Object> context,
                                         java.lang.Object target,
                                         java.lang.reflect.Member member,
                                         java.lang.String propertyName,
                                         java.lang.Object value,
                                         java.lang.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(java.util.Map<java.lang.String,java.lang.Object> context)

### convertValue

    public java.lang.Object convertValue(java.lang.Object value,
                                         java.lang.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(java.lang.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 java.lang.Enum<?> enumValue(java.lang.Class toClass,
                                       java.lang.Object o)

### longValue

    public static long longValue(java.lang.Object value)
                          throws java.lang.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:
    `java.lang.NumberFormatException` - if the given object can't be understood as a long integer

### doubleValue

    public static double doubleValue(java.lang.Object value)
                              throws java.lang.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:
    `java.lang.NumberFormatException` - if the given object can't be understood as a double

### bigIntValue

    public static java.math.BigInteger bigIntValue(java.lang.Object value)
                                            throws java.lang.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:
    `java.lang.NumberFormatException` - if the given object can't be understood as a BigInteger

### bigDecValue

    public static java.math.BigDecimal bigDecValue(java.lang.Object value)
                                            throws java.lang.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:
    `java.lang.NumberFormatException` - if the given object can't be understood as a BigDecimal

### stringValue

    public static java.lang.String stringValue(java.lang.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 java.lang.String stringValue(java.lang.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.

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-2011 Apache Software Foundation. All Rights Reserved.