@Test public void shouldTestTypedValueRetrivalForDate() throws Exception { Element test = new Element("test", "me"); Object res = DataHelper.getTypedValue(PropertyType.DATE.name(), "20121221122121"); Assert.assertNotNull(res); Assert.assertTrue(res instanceof Date); res = DataHelper.getTypedValue(PropertyType.DATE.name(), "1338474281528"); Assert.assertNotNull(res); Assert.assertTrue(res instanceof Date); res = DataHelper.getTypedValue(PropertyType.DATE.name(), "blah"); Assert.assertNotNull(res); Assert.assertTrue(res instanceof String); }
public static Object getTypedValue( String t, String value ) { if ( value == null ) { return ""; } PropertyType type = PropertyType.valueOf( t ); Object result = null; switch ( type ) { case STRING: result = value; break; case BOOL: result = getBooleanValue( value ); break; case INTEGER: result = getIntegerValue( value ); break; case FLOAT: result = getDoubleValue( value ); break; case DATE: result = getDateValue( value ); break; case ARRAY: break; } return (result == null) ? value : result; }
DataHelper { public static Object getTypedValue( String t, String value ) { if ( value == null ) { return ""; } PropertyType type = PropertyType.valueOf( t ); Object result = null; switch ( type ) { case STRING: result = value; break; case BOOL: result = getBooleanValue( value ); break; case INTEGER: result = getIntegerValue( value ); break; case FLOAT: result = getDoubleValue( value ); break; case DATE: result = getDateValue( value ); break; case ARRAY: break; } return (result == null) ? value : result; } }
DataHelper { public static Object getTypedValue( String t, String value ) { if ( value == null ) { return ""; } PropertyType type = PropertyType.valueOf( t ); Object result = null; switch ( type ) { case STRING: result = value; break; case BOOL: result = getBooleanValue( value ); break; case INTEGER: result = getIntegerValue( value ); break; case FLOAT: result = getDoubleValue( value ); break; case DATE: result = getDateValue( value ); break; case ARRAY: break; } return (result == null) ? value : result; } private  DataHelper(); }
DataHelper { public static Object getTypedValue( String t, String value ) { if ( value == null ) { return ""; } PropertyType type = PropertyType.valueOf( t ); Object result = null; switch ( type ) { case STRING: result = value; break; case BOOL: result = getBooleanValue( value ); break; case INTEGER: result = getIntegerValue( value ); break; case FLOAT: result = getDoubleValue( value ); break; case DATE: result = getDateValue( value ); break; case ARRAY: break; } return (result == null) ? value : result; } private  DataHelper(); static void init(); static String getPropertyType( String key ); static String removeTrailingZero( final String str ); static void mergeMetadataRecord( Element e, MetadataRecord mr ); static Object getTypedValue( String t, String value ); }
DataHelper { public static Object getTypedValue( String t, String value ) { if ( value == null ) { return ""; } PropertyType type = PropertyType.valueOf( t ); Object result = null; switch ( type ) { case STRING: result = value; break; case BOOL: result = getBooleanValue( value ); break; case INTEGER: result = getIntegerValue( value ); break; case FLOAT: result = getDoubleValue( value ); break; case DATE: result = getDateValue( value ); break; case ARRAY: break; } return (result == null) ? value : result; } private  DataHelper(); static void init(); static String getPropertyType( String key ); static String removeTrailingZero( final String str ); static void mergeMetadataRecord( Element e, MetadataRecord mr ); static Object getTypedValue( String t, String value );  }