Class DefaultTypeConverter
java.lang.Object
org.apache.struts2.conversion.impl.DefaultTypeConverter
- All Implemented Interfaces:
- TypeConverter
- Direct Known Subclasses:
- ArrayConverter,- CollectionConverter,- DateConverter,- NumberConverter,- StringConverter,- StrutsTypeConverter,- UploadedFileConverter,- XWorkBasicConverter,- XWorkConverter
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 SummaryFieldsFields inherited from interface org.apache.struts2.conversion.TypeConverterNO_CONVERSION_POSSIBLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic BigDecimalbigDecValue(Object value) Evaluates the given object as a BigDecimal.static BigIntegerbigIntValue(Object value) Evaluates the given object as a BigInteger.static booleanbooleanValue(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.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.convertValue(Map<String, Object> context, Object target, Member member, String propertyName, Object value, Class toType) Converts the given value to a given type.static doubledoubleValue(Object value) Evaluates the given object as a double-precision floating-point number.Enum<?>protected LocalegetTypeConverter(Map<String, Object> context) static longEvaluates the given object as a long integer.voidsetContainer(Container container) static StringstringValue(Object value) Evaluates the given object as a String.static StringstringValue(Object value, boolean trim) Evaluates the given object as a String and trims it if the trim flag is true.
- 
Field Details- 
MILLISECOND_FORMAT- See Also:
 
 
- 
- 
Constructor Details- 
DefaultTypeConverterpublic DefaultTypeConverter()
 
- 
- 
Method Details- 
setContainer
- 
convertValue
- 
convertValuepublic Object convertValue(Map<String, Object> context, Object target, Member member, String propertyName, Object value, Class toType) Description copied from interface:TypeConverterConverts 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:
- convertValuein 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
- 
convertValueReturns 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.
 
- 
booleanValueEvaluates 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
- 
longValueEvaluates 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
 
- 
doubleValueEvaluates 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
 
- 
bigIntValueEvaluates the given object as a BigInteger.- Parameters:
- value- an object to interpret as a BigInteger
- Returns:
- the BigInteger value implied by the given object
 
- 
bigDecValueEvaluates the given object as a BigDecimal.- Parameters:
- value- an object to interpret as a BigDecimal
- Returns:
- the BigDecimal value implied by the given object
 
- 
stringValueEvaluates the given object as a String and trims it if the trim flag is true.- Parameters:
- value- an object to interpret as a String
- trim- trims the result if true
- Returns:
- the String value implied by the given object as returned by the toString() method, or "null" if the object is null.
 
- 
stringValueEvaluates 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
 
-