Search in sources :

Example 6 with IonSystem

use of com.amazon.ion.IonSystem in project ion-java by amzn.

the class SymbolTableTest method testSymtabImageMaintenance.

@Test
public void testSymtabImageMaintenance() {
    IonSystem system = system();
    SymbolTable st = ((_Private_ValueFactory) system).getLstFactory().newLocalSymtab(system.getSystemSymbolTable());
    st.intern("foo");
    IonStruct image = symtabTree(st, system);
    st.intern("bar");
    image = symtabTree(st, system);
    IonList symbols = (IonList) image.get(SYMBOLS);
    assertEquals("[\"foo\",\"bar\"]", symbols.toString());
}
Also used : IonSystem(com.amazon.ion.IonSystem) IonStruct(com.amazon.ion.IonStruct) IonList(com.amazon.ion.IonList) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 7 with IonSystem

use of com.amazon.ion.IonSystem in project ion-java by amzn.

the class IonReaderBinaryIncrementalTest method incrementalMultipleValuesIterateFromInputStream.

@Test
public void incrementalMultipleValuesIterateFromInputStream() throws Exception {
    ResizingPipedInputStream pipe = new ResizingPipedInputStream(128);
    IonSystem system = IonSystemBuilder.standard().withReaderBuilder(STANDARD_READER_BUILDER).build();
    Iterator<IonValue> iterator = system.iterate(pipe);
    incrementalMultipleValuesIterate(iterator, pipe);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSystem(com.amazon.ion.IonSystem) Test(org.junit.Test)

Example 8 with IonSystem

use of com.amazon.ion.IonSystem 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);
}
Also used : IonSystem(com.amazon.ion.IonSystem) IonCatalog(com.amazon.ion.IonCatalog) SymbolTable(com.amazon.ion.SymbolTable)

Example 9 with IonSystem

use of com.amazon.ion.IonSystem in project ion-java by amzn.

the class _Private_IonWriterFactory method makeSystemWriter.

/**
 * @param container must not be null.
 */
public static IonWriter makeSystemWriter(IonContainer container) {
    IonSystem sys = container.getSystem();
    IonCatalog cat = sys.getCatalog();
    SymbolTable defaultSystemSymtab = sys.getSystemSymbolTable();
    IonWriter writer = new IonWriterSystemTree(defaultSystemSymtab, cat, container, null);
    return writer;
}
Also used : IonSystem(com.amazon.ion.IonSystem) IonCatalog(com.amazon.ion.IonCatalog) SymbolTable(com.amazon.ion.SymbolTable) IonWriter(com.amazon.ion.IonWriter)

Example 10 with IonSystem

use of com.amazon.ion.IonSystem in project ion-java by amzn.

the class _Private_IonWriterFactory method makeWriter.

/**
 * @param container must not be null.
 */
public static IonWriter makeWriter(IonCatalog catalog, IonContainer container) {
    IonSystem sys = container.getSystem();
    SymbolTable defaultSystemSymtab = sys.getSystemSymbolTable();
    // TODO the SUPPRESS here is a nasty discontinuity with other places
    // that create this kind of reader.  It prevents the Lite DG system
    // iterator from returning two IVMs at the start of the data.
    // The Span tests detect that problem.
    IonWriterSystemTree system_writer = new IonWriterSystemTree(defaultSystemSymtab, catalog, container, InitialIvmHandling.SUPPRESS);
    return new IonWriterUser(catalog, sys, system_writer);
}
Also used : IonSystem(com.amazon.ion.IonSystem) SymbolTable(com.amazon.ion.SymbolTable)

Aggregations

IonSystem (com.amazon.ion.IonSystem)39 Test (org.junit.Test)27 IonValue (com.amazon.ion.IonValue)12 SymbolTable (com.amazon.ion.SymbolTable)10 IonReader (com.amazon.ion.IonReader)8 IonWriter (com.amazon.ion.IonWriter)8 IonDatagram (com.amazon.ion.IonDatagram)6 IonStruct (com.amazon.ion.IonStruct)6 IonCatalog (com.amazon.ion.IonCatalog)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 IonString (com.amazon.ion.IonString)4 com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)4 com.amazon.ion.impl._Private_IonWriter (com.amazon.ion.impl._Private_IonWriter)4 BinaryTest (com.amazon.ion.BinaryTest)3 IonBinaryWriter (com.amazon.ion.IonBinaryWriter)2 IonType (com.amazon.ion.IonType)2 SimpleCatalog (com.amazon.ion.system.SimpleCatalog)2 IOException (java.io.IOException)2 BigInteger (java.math.BigInteger)2 Date (java.util.Date)2