use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class _Private_IonWriterBase method pop_passed_symbol_table.
public final SymbolTable pop_passed_symbol_table() {
if (_symbol_table_top <= 0) {
return null;
}
_symbol_table_top--;
SymbolTable symbols = _symbol_table_stack[_symbol_table_top];
_symbol_table_stack[_symbol_table_top] = null;
return symbols;
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class _Private_IonWriterFactory method makeSystemWriter.
/**
* @param container must not be null.
*/
public static IonWriter makeSystemWriter(IonContainer container) {
IonSystem sys = container.getSystem();
IonCatalog cat = sys.getCatalog();
SymbolTable defaultSystemSymtab = sys.getSystemSymbolTable();
IonWriter writer = new IonWriterSystemTree(defaultSystemSymtab, cat, container, null);
return writer;
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class _Private_IonWriterFactory method makeWriter.
/**
* @param container must not be null.
*/
public static IonWriter makeWriter(IonCatalog catalog, IonContainer container) {
IonSystem sys = container.getSystem();
SymbolTable defaultSystemSymtab = sys.getSystemSymbolTable();
// TODO the SUPPRESS here is a nasty discontinuity with other places
// that create this kind of reader. It prevents the Lite DG system
// iterator from returning two IVMs at the start of the data.
// The Span tests detect that problem.
IonWriterSystemTree system_writer = new IonWriterSystemTree(defaultSystemSymtab, catalog, container, InitialIvmHandling.SUPPRESS);
return new IonWriterUser(catalog, sys, system_writer);
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class IonSymbolLite method getSymbolId.
private int getSymbolId(SymbolTableProvider symbolTableProvider) throws NullValueException {
validateThisNotNull();
if (_sid != UNKNOWN_SYMBOL_ID || isReadOnly()) {
return _sid;
}
SymbolTable symtab = symbolTableProvider != null ? symbolTableProvider.getSymbolTable() : getSymbolTable();
if (symtab == null) {
symtab = getSystem().getSystemSymbolTable();
}
assert (symtab != null);
String name = _get_value();
// TODO [amzn/ion-java/issues/27] - needs consistent handling, when to retain SID's vs ignore (here memoizing SID on read)
if (!symtab.isLocalTable()) {
setSID(symtab.findSymbol(name));
if (_sid > 0 || isReadOnly()) {
return _sid;
}
}
SymbolToken tok = symtab.find(name);
if (tok != null) {
setSID(tok.getSid());
// Use the interned instance of the text
_set_value(tok.getText());
}
return _sid;
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class _Private_Utils method localSymtabExtends.
/**
* Determines, for two local symbol tables, whether the passed-in {@code superset} symtab is an extension
* of {@code subset}. This works independent of implementation details--particularly in cases
* where {@link LocalSymbolTable#symtabExtends(SymbolTable)} cannot be used.
*
* @see #symtabExtends(SymbolTable, SymbolTable)
*/
private static boolean localSymtabExtends(SymbolTable superset, SymbolTable subset) {
if (subset.getMaxId() > superset.getMaxId()) {
// the subset has more symbols
return false;
}
// NB this API almost certainly requires cloning--symbol table's API doesn't give us a way to polymorphically
// get this without materializing an array
final SymbolTable[] supersetImports = superset.getImportedTables();
final SymbolTable[] subsetImports = subset.getImportedTables();
// TODO this is over-strict, but not as strict as LocalSymbolTable.symtabExtends()
if (supersetImports.length != subsetImports.length) {
return false;
}
// NB we cannot trust Arrays.equals--we don't know how an implementation will implement it...
for (int i = 0; i < supersetImports.length; i++) {
final SymbolTable supersetImport = supersetImports[i];
final SymbolTable subsetImport = subsetImports[i];
if (!supersetImport.getName().equals(subsetImport.getName()) || supersetImport.getVersion() != subsetImport.getVersion()) {
// bad match on import
return false;
}
}
// all the imports lined up, lets make sure the locals line up too
final Iterator<String> supersetIter = superset.iterateDeclaredSymbolNames();
final Iterator<String> subsetIter = subset.iterateDeclaredSymbolNames();
while (subsetIter.hasNext()) {
final String nextSubsetSymbol = subsetIter.next();
final String nextSupersetSymbol = supersetIter.next();
if (!nextSubsetSymbol.equals(nextSupersetSymbol)) {
// local symbol mismatch
return false;
}
}
// we made it this far--superset is really a superset of subset
return true;
}
Aggregations