in src/com/amazon/ion/impl/lite/IonSystemLite.java [324:440]
private IonValueLite load_value_helper(IonReader reader, boolean isTopLevel)
{
boolean symbol_is_present = false;
IonType t = reader.getType();
if (t == null) {
return null;
}
IonValueLite v;
if (reader.isNullValue()) {
v = newNull(t);
}
else {
switch (t) {
case BOOL:
v = newBool(reader.booleanValue());
break;
case INT:
// TODO amzn/ion-java/issues/9 Inefficient since we can't determine the size
// of the integer in order to avoid making BigIntegers.
v = newInt(reader.bigIntegerValue());
break;
case FLOAT:
v = newFloat(reader.doubleValue());
break;
case DECIMAL:
v = newDecimal(reader.decimalValue());
break;
case TIMESTAMP:
v = newTimestamp(reader.timestampValue());
break;
case SYMBOL:
v = newSymbol(reader.symbolValue());
symbol_is_present = true;
break;
case STRING:
v = newString(reader.stringValue());
break;
case CLOB:
v = newClob(reader.newBytes());
break;
case BLOB:
v = newBlob(reader.newBytes());
break;
case LIST:
v = newEmptyList();
break;
case SEXP:
v = newEmptySexp();
break;
case STRUCT:
v = newEmptyStruct();
break;
default: throw new IonException("unexpected type encountered reading value: "+t.toString());
}
}
// Forget any incoming SIDs on field names.
if (!isTopLevel && reader.isInStruct()) {
SymbolToken token = reader.getFieldNameSymbol();
String text = token.getText();
if (text != null && token.getSid() != UNKNOWN_SYMBOL_ID)
{
token = newSymbolToken(text, UNKNOWN_SYMBOL_ID);
}
v.setFieldNameSymbol(token);
symbol_is_present = true;
}
// Forget any incoming SIDs on annotations.
// This is a fresh array so we can modify it:
SymbolToken[] annotations = reader.getTypeAnnotationSymbols();
if (annotations.length != 0)
{
for (int i = 0; i < annotations.length; i++)
{
SymbolToken token = annotations[i];
String text = token.getText();
if (text != null && token.getSid() != UNKNOWN_SYMBOL_ID )
{
annotations[i] = newSymbolToken(text, UNKNOWN_SYMBOL_ID);
}
}
v.setTypeAnnotationSymbols(annotations);
symbol_is_present = true;
}
if (!reader.isNullValue()) {
switch (t) {
case BOOL:
case INT:
case FLOAT:
case DECIMAL:
case TIMESTAMP:
case SYMBOL:
case STRING:
case CLOB:
case BLOB:
break;
case LIST:
case SEXP:
case STRUCT:
// we have to load the children after we grabbed the
// fieldname and annotations off of the parent container
if (load_children((IonContainerLite)v, reader)) {
symbol_is_present = true;
}
break;
default:
throw new IonException("unexpected type encountered reading value: "+t.toString());
}
}
if (symbol_is_present) {
v._isSymbolPresent(true);
}
return v;
}