use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class LocalSymbolTableTest method testInternUnknownText.
@Test
public void testInternUnknownText() {
SymbolTable st = makeLocalSymtab(system(), LOCAL_SYMBOLS_ABC, ST_FRED_V2, ST_GINGER_V1);
String D = "d";
checkUnknownSymbol(D, st);
SymbolToken tok = st.intern(D);
assertSame(D, tok.getText());
assertEquals(st.getImportedMaxId() + 4, tok.getSid());
// Force a new instance
tok = st.intern(new String(D));
assertSame(D, tok.getText());
assertEquals(st.getImportedMaxId() + 4, tok.getSid());
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class LocalSymbolTableTest method testCopyLST.
@Test
public void testCopyLST() {
SymbolTable orig = makeLocalSymtab(system(), LOCAL_SYMBOLS_ABC);
// method under test
SymbolTable copy = copyLocalSymbolTable(orig);
assertNotSame(orig, copy);
assertTrue(copy.isLocalTable());
int systemMaxId = orig.getSystemSymbolTable().getMaxId();
checkSymbol("a", systemMaxId + 1, copy.find("a"));
checkSymbol("b", systemMaxId + 2, copy.find("b"));
checkSymbol("c", systemMaxId + 3, copy.find("c"));
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class OptimizedBinaryWriterSymbolTableTest method testOptimizedWriteValueSupersetWriterImport.
/**
* Writer's imports superset of Reader's: (could be) fully optimized.
* TODO amzn/ion-java/issues/18 at the moment the compatability code requires
* exact-match on imports.
*/
@Test
public void testOptimizedWriteValueSupersetWriterImport() throws Exception {
SymbolTable fred2 = Symtabs.register("fred", 2, catalog());
byte[] source = encode(importFred1 + "fred_1 123 null");
ir = makeReaderProxy(source);
iw = makeWriter(fred2);
checkWriteValueWithIncompatibleSymtab();
checkWriteValueWithIncompatibleSymtab();
checkWriteValueWithIncompatibleSymtab();
iw.close();
assertIonIteratorEquals(system().iterate(source), system().iterate(outputByteArray()));
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class IonSystemLite method newDatagram.
public IonDatagram newDatagram(IonCatalog catalog, SymbolTable... imports) {
SymbolTable defaultSystemSymtab = getSystemSymbolTable();
SymbolTable symbols = initialSymtab(_lstFactory, defaultSystemSymtab, imports);
IonDatagramLite dg = newDatagram(catalog);
dg.appendTrailingSymbolTable(symbols);
return dg;
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class _Private_IonTextWriterBuilder method build.
/**
* Assumes that {@link #fillDefaults()} has been called.
*/
private IonWriter build(_Private_FastAppendable appender) {
IonCatalog catalog = getCatalog();
SymbolTable[] imports = getImports();
// TODO We shouldn't need a system here
IonSystem system = IonSystemBuilder.standard().withCatalog(catalog).build();
SymbolTable defaultSystemSymtab = system.getSystemSymbolTable();
IonWriterSystemText systemWriter = (getCallbackBuilder() == null ? new IonWriterSystemText(defaultSystemSymtab, this, appender) : new IonWriterSystemTextMarkup(defaultSystemSymtab, this, appender));
SymbolTable initialSymtab = initialSymtab(((_Private_ValueFactory) system).getLstFactory(), defaultSystemSymtab, imports);
return new IonWriterUser(catalog, system, systemWriter, initialSymtab);
}
Aggregations