use of com.amazon.ion.Decimal in project ion-java by amzn.
the class AbstractIonWriter method writeValueRecursive.
public final void writeValueRecursive(final IonReader reader) throws IOException {
final IonType type = reader.getType();
final SymbolToken fieldName = reader.getFieldNameSymbol();
if (fieldName != null && !isFieldNameSet() && isInStruct()) {
setFieldNameSymbol(fieldName);
}
final SymbolToken[] annotations = reader.getTypeAnnotationSymbols();
if (annotations.length > 0) {
setTypeAnnotationSymbols(annotations);
}
if (reader.isNullValue()) {
writeNull(type);
return;
}
switch(type) {
case BOOL:
final boolean booleanValue = reader.booleanValue();
writeBool(booleanValue);
break;
case INT:
switch(reader.getIntegerSize()) {
case INT:
final int intValue = reader.intValue();
writeInt(intValue);
break;
case LONG:
final long longValue = reader.longValue();
writeInt(longValue);
break;
case BIG_INTEGER:
final BigInteger bigIntegerValue = reader.bigIntegerValue();
writeInt(bigIntegerValue);
break;
default:
throw new IllegalStateException();
}
break;
case FLOAT:
final double doubleValue = reader.doubleValue();
writeFloat(doubleValue);
break;
case DECIMAL:
final Decimal decimalValue = reader.decimalValue();
writeDecimal(decimalValue);
break;
case TIMESTAMP:
final Timestamp timestampValue = reader.timestampValue();
writeTimestamp(timestampValue);
break;
case SYMBOL:
final SymbolToken symbolToken = reader.symbolValue();
writeSymbolToken(symbolToken);
break;
case STRING:
final String stringValue = reader.stringValue();
writeString(stringValue);
break;
case CLOB:
final byte[] clobValue = reader.newBytes();
writeClob(clobValue);
break;
case BLOB:
final byte[] blobValue = reader.newBytes();
writeBlob(blobValue);
break;
case LIST:
case SEXP:
case STRUCT:
reader.stepIn();
stepIn(type);
while (reader.next() != null) {
writeValue(reader);
}
stepOut();
reader.stepOut();
break;
default:
throw new IllegalStateException("Unexpected type: " + type);
}
}
Aggregations