use of com.amazon.ion.IonSystem in project ion-java by amzn.
the class _Private_IonBinaryWriterBuilder method fillLegacyDefaults.
/**
* Fills all properties and returns an immutable builder.
*/
private _Private_IonBinaryWriterBuilder fillLegacyDefaults() {
// amzn/ion-java/issues/59 Fix this to use the new writer or eliminate it
// Ensure that we don't modify the user's builder.
_Private_IonBinaryWriterBuilder b = copy();
if (b.getSymtabValueFactory() == null) {
IonSystem system = IonSystemBuilder.standard().build();
b.setSymtabValueFactory(system);
}
SymbolTable initialSymtab = b.getInitialSymbolTable();
if (initialSymtab == null) {
initialSymtab = initialSymtab(LocalSymbolTable.DEFAULT_LST_FACTORY, _Private_Utils.systemSymtab(1), b.getImports());
b.setInitialSymbolTable(initialSymtab);
} else if (initialSymtab.isSystemTable()) {
initialSymtab = initialSymtab(LocalSymbolTable.DEFAULT_LST_FACTORY, initialSymtab, b.getImports());
b.setInitialSymbolTable(initialSymtab);
}
return b.immutable();
}
use of com.amazon.ion.IonSystem in project ion-java by amzn.
the class _Private_IonBinaryWriterBuilder method fillDefaults.
// =========================================================================
/**
* Fills all properties and returns an immutable builder.
*/
private _Private_IonBinaryWriterBuilder fillDefaults() {
// Ensure that we don't modify the user's builder.
_Private_IonBinaryWriterBuilder b = copy();
if (b.getSymtabValueFactory() == null) {
IonSystem system = IonSystemBuilder.standard().build();
b.setSymtabValueFactory(system);
}
return b.immutable();
}
use of com.amazon.ion.IonSystem in project ion-java by amzn.
the class SymbolTableTest method testDupLocalSymbolOnDatagram.
@Test
public void testDupLocalSymbolOnDatagram() throws Exception {
final IonSystem ion1 = system();
final SymbolTable st = ion1.newSharedSymbolTable("foobar", 1, Arrays.asList("s1").iterator());
final IonMutableCatalog cat = new SimpleCatalog();
cat.putTable(st);
// amzn/ion-java/issues/46 has the datagram producing something like:
// $ion_1_0 $ion_symbol_table::{imports:[{name: "foobar", version: 1, max_id: 1}], symbols: ["s1", "l1"]} $11 $12
// local table should not have "s1", user values should be $10 $11
IonDatagram dg = ion1.newDatagram(st);
dg.add().newSymbol("s1");
dg.add().newSymbol("l1");
final IonSystem ion2 = newSystem(cat);
dg = ion2.getLoader().load(dg.getBytes());
checkSymbol("s1", 10, dg.get(0));
checkSymbol("l1", 11, dg.get(1));
}
use of com.amazon.ion.IonSystem in project ion-java by amzn.
the class SymbolTableTest method registerImportedV3.
public SymbolTable registerImportedV3() {
IonSystem system = system();
String importingText = SharedSymbolTablePrefix + "{" + " name:'''imported''', version:3," + " symbols:[" + " '''imported 1'''," + // Removed 'imported 2'
" null," + " '''fred3'''," + " '''fred4'''," + " '''fred5'''," + " ]" + "}";
SymbolTable shared = registerSharedSymtab(importingText);
assertEquals(IMPORTED_3_MAX_ID, shared.getMaxId());
SymbolTable importedTable = system.getCatalog().getTable("imported", 3);
assertSame(shared, importedTable);
return importedTable;
}
use of com.amazon.ion.IonSystem in project ion-java by amzn.
the class MiscStreamingTest method testQuoting.
@Test
@SuppressWarnings("deprecation")
public void testQuoting() throws Exception {
String s = " \"" + _QuotingString1_ion + "\" '" + _QuotingString2_ion + "' ";
// buffer should be 22 bytes long
// cookie (4 bytes)
// local symbol table (11 bytes):
// annotation (1 byte tid, len=10)
// annot size (1 byte: len=1)
// $ion_1_0 (1 byte sid)
// struct (1 byte tid, len=7)
// field 'symbols' (1 bytes sid)
// List (1 byte tid, len=5)
// str2 (5 bytes)
// value1 string "str1" (5 bytes: 1 typedesc + 4 text)
// value2 symbol 'str2' (2 bytes: 1 typedesc + 1 sid)
IonReader ir = system().newReader(s);
IonSystem system = system();
IonBinaryWriter wr = system.newBinaryWriter();
wr = system.newBinaryWriter();
wr.writeValues(ir);
byte[] buffer = wr.getBytes();
assertSame("this buffer length is known to be 22", buffer.length, 22);
IonReader sir = system().newReader(s);
IonReader bir = system().newReader(s);
checkIteratorForQuotingTest("string", sir);
checkIteratorForQuotingTest("binary", bir);
}
Aggregations