in c3r-sdk-core/src/main/java/com/amazonaws/c3r/data/CsvValueFactory.java [27:75]
public CsvValue createValueFromEncodedBytes(final byte[] bytes) {
final ClientDataType type = ValueConverter.clientDataTypeForEncodedValue(bytes);
switch (type) {
case BIGINT:
final Long bigint = ValueConverter.BigInt.decode(bytes);
final String bigintStr = (bigint == null) ? null : bigint.toString();
return new CsvValue(bigintStr);
case BOOLEAN:
final Boolean bool = ValueConverter.Boolean.decode(bytes);
final String boolStr = (bool == null) ? null :
bool ? "true" : "false";
return new CsvValue(boolStr);
case CHAR:
return new CsvValue(ValueConverter.Char.decode(bytes));
case DATE:
final Integer date = ValueConverter.Date.decode(bytes);
return new CsvValue(convertDateToString(date));
case DECIMAL:
final ClientValueWithMetadata.Decimal decimal = ValueConverter.Decimal.decode(bytes);
final String decimalStr = (decimal.getValue() == null) ? null : decimal.getValue().toPlainString();
return new CsvValue(decimalStr);
case DOUBLE:
final Double dbl = ValueConverter.Double.decode(bytes);
final String dblStr = (dbl == null) ? null : dbl.toString();
return new CsvValue(dblStr);
case FLOAT:
final Float flt = ValueConverter.Float.decode(bytes);
final String fltStr = (flt == null) ? null : flt.toString();
return new CsvValue(fltStr);
case INT:
final Integer integer = ValueConverter.Int.decode(bytes);
final String intStr = (integer == null) ? null : integer.toString();
return new CsvValue(intStr);
case SMALLINT:
final Short shrt = ValueConverter.SmallInt.decode(bytes);
final String shrtStr = (shrt == null) ? null : shrt.toString();
return new CsvValue(shrtStr);
case STRING:
return new CsvValue(ValueConverter.String.decode(bytes));
case TIMESTAMP:
final ClientValueWithMetadata.Timestamp timestamp = ValueConverter.Timestamp.decode(bytes);
return new CsvValue(convertTimestampToString(timestamp));
case VARCHAR:
final ClientValueWithMetadata.Varchar varchar = ValueConverter.Varchar.decode(bytes);
return new CsvValue(varchar.getValue());
default:
throw new C3rRuntimeException("Unable to decode bytes to a valid type.");
}
}