use of com.amazon.ion.IonList in project jackson-dataformats-binary by FasterXML.
the class DataBindWriteTest method initializeExpectedArray.
@Before
public void initializeExpectedArray() {
expectedArray = ion.newDatagram();
IonList list = ion.newEmptyList();
list.add().newInt(1);
list.add().newInt(2);
list.add().newInt(3);
expectedArray.add(list);
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableStructCache method makeIonRepresentation.
/**
* Create a new IonStruct representation of the symbol table.
* @param factory the {@link ValueFactory} from which to construct the IonStruct.
*/
private void makeIonRepresentation(ValueFactory factory) {
image = factory.newEmptyStruct();
image.addTypeAnnotation(ION_SYMBOL_TABLE);
if (importedTables.length > 0) {
// The system symbol table may be the first import. If it is, skip it.
int i = importedTables[0].isSystemTable() ? 1 : 0;
if (i < importedTables.length) {
IonList importsList = factory.newEmptyList();
while (i < importedTables.length) {
SymbolTable importedTable = importedTables[i];
IonStruct importStruct = factory.newEmptyStruct();
importStruct.add(NAME, factory.newString(importedTable.getName()));
importStruct.add(VERSION, factory.newInt(importedTable.getVersion()));
importStruct.add(MAX_ID, factory.newInt(importedTable.getMaxId()));
importsList.add(importStruct);
i++;
}
image.add(IMPORTS, importsList);
}
}
if (symbolTable.getMaxId() > symbolTable.getImportedMaxId()) {
Iterator<String> localSymbolIterator = symbolTable.iterateDeclaredSymbolNames();
int sid = symbolTable.getImportedMaxId() + 1;
while (localSymbolIterator.hasNext()) {
addSymbol(localSymbolIterator.next(), sid);
sid++;
}
}
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class _Private_CurriedValueFactory method newList.
public IonList newList(IonSequence firstChild) throws ContainedValueException, NullPointerException {
IonList v = myFactory.newList(firstChild);
handle(v);
return v;
}
use of com.amazon.ion.IonList 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.IonList 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