use of com.amazon.ion.ValueFactory in project ion-java by amzn.
the class SymbolTableStructCache method addSymbol.
/**
* Adds a new symbol table with the given symbol ID to the IonStruct's 'symbols' list.
* @param symbolName can be null when there's a gap in the local symbols list.
* @param sid the symbol ID to assign to the new symbol.
*/
void addSymbol(String symbolName, int sid) {
assert sid >= firstLocalSid;
ValueFactory sys = image.getSystem();
IonValue syms = image.get(SYMBOLS);
// the symbols field if necessary.
while (syms != null && syms.getType() != IonType.LIST) {
image.remove(syms);
syms = image.get(SYMBOLS);
}
if (syms == null) {
syms = sys.newEmptyList();
image.put(SYMBOLS, syms);
}
int thisOffset = sid - firstLocalSid;
IonValue name = sys.newString(symbolName);
((IonList) syms).add(thisOffset, name);
}
Aggregations