use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class _Private_CurriedValueFactory method newNullStruct.
// -------------------------------------------------------------------------
public IonStruct newNullStruct() {
IonStruct v = myFactory.newNullStruct();
handle(v);
return v;
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class OptimizedBinaryWriterLengthPatchingTest method testOptimizedWriteLengthPatching.
/**
* Tests that the internal implementation of binary {@link IonWriter}'s
* patching mechanism is correct.
*
* @see IonWriterSystemBinary
*/
@Test
public void testOptimizedWriteLengthPatching() throws Exception {
iw = makeWriter();
// The expected datagram - as values are copied to the IonWriter, we
// book-keep the values written so as to do an equality check at the end.
IonDatagram expected = system().newDatagram();
// === top level ===
writeAndAddTypeDescLengthVariants(expected);
// === nested list ===
iw.stepIn(IonType.LIST);
IonList expectedNestedList = expected.add().newEmptyList();
{
writeAndAddTypeDescLengthVariants(expectedNestedList);
}
iw.stepOut();
// === nested sexp ===
iw.stepIn(IonType.SEXP);
IonSexp expectedNestedSexp = expected.add().newEmptySexp();
{
writeAndAddTypeDescLengthVariants(expectedNestedSexp);
}
iw.stepOut();
// === nested struct ===
iw.stepIn(IonType.STRUCT);
IonStruct expectedNestedStruct = expected.add().newEmptyStruct();
{
writeAndAddTypeDescLengthVariants(expectedNestedStruct);
}
iw.stepOut();
// === deeply nested list ===
iw.stepIn(IonType.LIST);
IonList nestedList1 = expected.add().newEmptyList();
{
writeAndAddTypeDescLengthVariants(nestedList1);
iw.stepIn(IonType.LIST);
{
IonList nestedList2 = nestedList1.add().newEmptyList();
writeAndAddTypeDescLengthVariants(nestedList2);
}
iw.stepOut();
}
iw.stepOut();
IonDatagram actual = loader().load(outputByteArray());
assertIonEquals(expected, actual);
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class IonManagedBinaryWriterTest method testNoNewSymbolsAfterFlush.
@Test
public void testNoNewSymbolsAfterFlush() throws Exception {
writer.writeSymbol("taco");
writer.flush();
writer.writeInt(123);
writer.finish();
IonDatagram dg = system().getLoader().load(writer.getBytes());
// Should be IVM SYMTAB taco 123
assertEquals(4, dg.systemSize());
assertEquals("$ion_symbol_table", ((IonStruct) dg.systemGet(1)).getTypeAnnotations()[0]);
assertEquals("taco", ((IonSymbol) dg.systemGet(2)).stringValue());
assertEquals(123, ((IonInt) dg.systemGet(3)).intValue());
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class IonManagedBinaryWriterTest method testFlushImmediatelyAfterIVM.
@Test
public void testFlushImmediatelyAfterIVM() throws Exception {
writer.flush();
writer.writeSymbol("burrito");
writer.finish();
IonReader reader = system().newReader(writer.getBytes());
reader.next();
assertEquals(reader.getSymbolTable().findSymbol("taco"), -1);
assertEquals(reader.getSymbolTable().findSymbol("burrito"), 15);
assertNull(reader.next());
IonDatagram dg = system().getLoader().load(writer.getBytes());
// Should be IVM SYMTAB burrito
assertEquals(3, dg.systemSize());
assertEquals("$ion_symbol_table", ((IonStruct) dg.systemGet(1)).getTypeAnnotations()[0]);
assertEquals("burrito", ((IonSymbol) dg.systemGet(2)).stringValue());
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method checkFirstImport.
static void checkFirstImport(String name, int version, String[] expectedSymbols, IonStruct symtab) throws IOException {
IonList imports = (IonList) symtab.get(SystemSymbols.IMPORTS);
IonStruct i0 = (IonStruct) imports.get(0);
checkString(name, i0.get(SystemSymbols.NAME));
checkInt(version, i0.get(SystemSymbols.VERSION));
checkInt(expectedSymbols.length, i0.get(SystemSymbols.MAX_ID));
}
Aggregations