List of usage examples for com.amazonaws.services.simpledb.util SimpleDBUtils decodeZeroPaddingLong
public static long decodeZeroPaddingLong(String value)
From source file:wwutil.jsoda.DataUtil.java
License:Mozilla Public License
/** Caller should handle custom valueType first before calling this. */ @SuppressWarnings("unchecked") static Object decodeAttrStrToValue(String attrStr, Class valueType) throws Exception { // Set null if input is null. if (attrStr == null) return null; if (valueType == String.class) return attrStr; // Return string type as it is. // non-String field having "" is treated as null. if (attrStr.equals("")) return null; if (valueType == Byte.class || valueType == byte.class) { return new Byte((byte) SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Short.class || valueType == short.class) { return new Short((short) SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Integer.class || valueType == int.class) { return new Integer(SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Long.class || valueType == long.class) { return new Long(SimpleDBUtils.decodeZeroPaddingLong(attrStr)); } else if (valueType == Float.class || valueType == float.class) { return new Float(SimpleDBUtils.decodeZeroPaddingFloat(attrStr)); } else if (valueType == Double.class || valueType == double.class) { return new Double(attrStr); } else if (valueType == Boolean.class || valueType == boolean.class) { return new Boolean(attrStr); } else if (valueType == Character.class || valueType == char.class) { return attrStr.charAt(0); } else if (valueType == Date.class) { return SimpleDBUtils.decodeDate(attrStr); } else if (valueType.isEnum()) { return Enum.valueOf(valueType, attrStr); }/*from w w w .j ava 2s. c o m*/ // de-JSONify the rest. return fromJson(attrStr, valueType); }