if ( value == null ) {
valueType = ValueType.NULL_TYPE;
}
if ( valueType == ValueType.NULL_TYPE ) {
field = new ObjectFieldImpl( null );
} else if ( valueType == ValueType.PCHAR_TYPE ) {
if( value instanceof String && ((String)value).length() == 1 ) {
field = new LongFieldImpl( ((String) value).charAt(0) );
} else {
field = new LongFieldImpl( ((Character) value).charValue() );
}
} else if ( valueType == ValueType.PBYTE_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Byte.parseByte( (String) value) );
} else {
field = new LongFieldImpl( ((Number) value).byteValue() );
}
} else if ( valueType == ValueType.PSHORT_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Short.parseShort( (String) value) );
} else {
field = new LongFieldImpl( ((Number) value).shortValue() );
}
} else if ( valueType == ValueType.PINTEGER_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Integer.parseInt( stripNumericType( (String) value ) ) );
} else {
field = new LongFieldImpl( ((Number) value).intValue() );
}
} else if ( valueType == ValueType.PLONG_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Long.parseLong( stripNumericType( (String) value ) ) );
} else {
field = new LongFieldImpl( ((Number) value).longValue() );
}
} else if ( valueType == ValueType.PFLOAT_TYPE ) {
if( value instanceof String ) {
field = new DoubleFieldImpl( Float.parseFloat( stripNumericType( (String) value ) ) );
} else {
field = new DoubleFieldImpl( ((Number) value).floatValue() );
}
} else if ( valueType == ValueType.PDOUBLE_TYPE ) {
if( value instanceof String ) {
field = new DoubleFieldImpl( Double.parseDouble( stripNumericType( (String) value ) ) );
} else {
field = new DoubleFieldImpl( ((Number) value).doubleValue() );
}
} else if ( valueType == ValueType.PBOOLEAN_TYPE ) {
if( value instanceof String ) {
field = new BooleanFieldImpl( Boolean.valueOf( (String) value).booleanValue() );
} else {
field = new BooleanFieldImpl( ((Boolean) value).booleanValue() );
}
} else if ( valueType == ValueType.CHAR_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BYTE_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.SHORT_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.INTEGER_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.LONG_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.FLOAT_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.DOUBLE_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BOOLEAN_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.STRING_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.DATE_TYPE ) {
//MN: I think its fine like this, seems to work !
if( value instanceof String ) {
Date date = DateUtils.parseDate( (String) value );
field = new ObjectFieldImpl( date );
} else {
field = new ObjectFieldImpl( value );
}
} else if ( valueType == ValueType.ARRAY_TYPE ) {
//MN: I think its fine like this.
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.OBJECT_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BIG_DECIMAL_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BIG_INTEGER_TYPE ) {
field = new ObjectFieldImpl( value );
}
return field;
}