use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class PrinterTest method testDatagramWithoutSymbols.
@Test
public void testDatagramWithoutSymbols() throws Exception {
IonDatagram dg = system().newDatagram();
dg.add().newInt(1);
checkRendering(ION_1_0 + " 1", dg);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class PrinterTest method testPrintingDatagram.
@Test
public void testPrintingDatagram() throws Exception {
IonDatagram dg = loader().load("a b c");
StringBuilder w = new StringBuilder();
myPrinter.print(dg, w);
String text = w.toString();
assertTrue("missing version marker", text.startsWith(ION_1_0 + ' '));
assertTrue("missing data", text.endsWith(" a b c"));
// Just force symtab analysis and make sure output is still okay
dg.getBytes(new byte[dg.byteSize()]);
text = w.toString();
assertTrue("missing version marker", text.startsWith(ION_1_0 + ' '));
assertTrue("missing data", text.endsWith(" a b c"));
// We shouldn't inject a local table if its not needed.
String data = "2 '+' [2,'+']";
String dataWithIvm = ION_1_0 + ' ' + data;
dg = loader().load(dataWithIvm);
checkRendering(dataWithIvm, dg);
myPrinter.setSkipSystemValues(true);
checkRendering(data, dg);
myPrinter.setPrintDatagramAsList(true);
checkRendering("[2,'+',[2,'+']]", dg);
myPrinter.setPrintDatagramAsList(false);
myPrinter.setSkipSystemValues(false);
myPrinter.setJsonMode();
checkRendering("[2,\"+\",[2,\"+\"]]", dg);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class PrinterTest method testSimplifyingChainedLocalSymtab.
@Test
public void testSimplifyingChainedLocalSymtab() throws Exception {
myPrinter.myOptions.simplifySystemValues = true;
String ionText = ION_SYMBOL_TABLE + "::{}" + " x" + " " + ION_SYMBOL_TABLE + "::{}" + " y";
IonDatagram dg = loader().load(ionText);
checkRendering(ION_1_0 + " x y", dg);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class IonWriterSystemTree method stepOut.
public void stepOut() throws IOException {
_Private_IonValue prior = (_Private_IonValue) _current_parent;
popParent();
if (_current_parent instanceof IonDatagram && valueIsLocalSymbolTable(prior)) {
// We just finish writing a symbol table!
SymbolTable symbol_table = _lst_factory.newLocalSymtab(_catalog, (IonStruct) prior);
setSymbolTable(symbol_table);
}
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class IonSystemLite method newDatagram.
public IonDatagram newDatagram() {
IonCatalog catalog = this.getCatalog();
IonDatagram dg = newDatagram(catalog);
return dg;
}
Aggregations