Search in sources :

Example 1 with com.amazon.ion.impl._Private_IonSystem

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

the class IonTestCase method newSystem.

/**
 * Returns a new IonSystem for each call, using the passed in IonCatalog
 * to build the IonSystem.
 *
 * @param catalog
 *          the catalog to use when building the IonSystem
 *
 * @return
 *          a new IonSystem instance, stream-copy optimized depending on the
 *          injected {@link #myStreamCopyOptimized}.
 */
protected _Private_IonSystem newSystem(IonCatalog catalog) {
    IonSystemBuilder b = IonSystemBuilder.standard().withCatalog(catalog);
    b.withStreamCopyOptimized(myStreamCopyOptimized);
    b.withReaderBuilder(getStreamingMode().getReaderBuilder());
    IonSystem system = b.build();
    return (_Private_IonSystem) system;
}
Also used : com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem) com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem) IonSystemBuilder(com.amazon.ion.system.IonSystemBuilder)

Example 2 with com.amazon.ion.impl._Private_IonSystem

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

the class TextIteratorSystemProcessingTest method systemIterate.

@Override
protected Iterator<IonValue> systemIterate() throws Exception {
    _Private_IonSystem sys = system();
    Iterator<IonValue> it = sys.systemIterate(myText);
    return it;
}
Also used : com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem)

Example 3 with com.amazon.ion.impl._Private_IonSystem

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

the class Printer method print.

// =========================================================================
// Print methods
public void print(IonValue value, Appendable out) throws IOException {
    // Copy the options so visitor won't see changes made while printing.
    Options options;
    synchronized (// So we don't clone in the midst of changes
    this) {
        options = myOptions.clone();
    }
    if (true) {
        _print(value, makeVisitor(options, out));
    } else {
        // Bridge to the configurable text writer. This is here for
        // testing purposes. It *almost* works except for printing
        // datagram as list.
        boolean dg = value instanceof IonDatagram;
        _Private_IonTextWriterBuilder o = _Private_IonTextWriterBuilder.standard();
        o.setCharset(IonTextWriterBuilder.ASCII);
        if (dg) {
            if (options.skipSystemValues) {
                o.withMinimalSystemData();
            } else if (options.simplifySystemValues) {
                o.setIvmMinimizing(IvmMinimizing.DISTANT);
                o.setLstMinimizing(LstMinimizing.LOCALS);
            }
        }
        o._blob_as_string = options.blobAsString;
        o._clob_as_string = options.clobAsString;
        o._decimal_as_float = options.decimalAsFloat;
        // TODO datagram as list
        o._sexp_as_list = options.sexpAsList;
        o._skip_annotations = options.skipAnnotations;
        o._string_as_json = options.stringAsJson;
        o._symbol_as_string = options.symbolAsString;
        o._timestamp_as_millis = options.timestampAsMillis;
        o._timestamp_as_string = options.timestampAsString;
        o._untyped_nulls = options.untypedNulls;
        IonWriter writer = o.build(out);
        // TODO doesn't work for datagram since it skips system values
        // value.writeTo(writer);
        _Private_IonSystem system = (_Private_IonSystem) value.getSystem();
        IonReader reader = system.newSystemReader(value);
        writer.writeValues(reader);
        writer.finish();
    }
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) IonReader(com.amazon.ion.IonReader) com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem) IonWriter(com.amazon.ion.IonWriter) com.amazon.ion.impl._Private_IonTextWriterBuilder(com.amazon.ion.impl._Private_IonTextWriterBuilder)

Example 4 with com.amazon.ion.impl._Private_IonSystem

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

the class DatagramTest method testAutomaticIVM.

@Test
public void testAutomaticIVM() throws Exception {
    _Private_IonSystem system = system();
    SymbolTable systemSymtab_1_0 = system.getSystemSymbolTable(ION_1_0);
    IonDatagram dg = system.newDatagram();
    IonNull v = system.newNull();
    assertTrue(v.getSymbolTable() == null || v.getSymbolTable().isSystemTable());
    dg.add(v);
    IonValue sysId = dg.systemGet(0);
    checkSymbol(ION_1_0, ION_1_0_SID, sysId);
    assertSame(systemSymtab_1_0, sysId.getSymbolTable());
    assertSame(systemSymtab_1_0, v.getSymbolTable());
}
Also used : com.amazon.ion.impl._Private_IonValue(com.amazon.ion.impl._Private_IonValue) com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem) Test(org.junit.Test)

Example 5 with com.amazon.ion.impl._Private_IonSystem

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

the class DatagramTest method testManualIVM.

@Test
public void testManualIVM() throws Exception {
    _Private_IonSystem system = system();
    SymbolTable systemSymtab_1_0 = system.getSystemSymbolTable(ION_1_0);
    IonDatagram dg = system.newDatagram();
    IonSymbol sysId = system.newSymbol(ION_1_0);
    assertTrue(sysId.getSymbolTable() == null || sysId.getSymbolTable().isSystemTable());
    // $ion_1_0 at the front top-level is a systemId
    dg.add(sysId);
    assertSame(systemSymtab_1_0, sysId.getSymbolTable());
// TODO amzn/ion-java/issues/20
// assertEquals(0, dg.size());
// TODO adding $ion_1_1 should fail: unsupported version
}
Also used : com.amazon.ion.impl._Private_IonSystem(com.amazon.ion.impl._Private_IonSystem) Test(org.junit.Test)

Aggregations

com.amazon.ion.impl._Private_IonSystem (com.amazon.ion.impl._Private_IonSystem)5 Test (org.junit.Test)2 IonDatagram (com.amazon.ion.IonDatagram)1 IonReader (com.amazon.ion.IonReader)1 IonWriter (com.amazon.ion.IonWriter)1 com.amazon.ion.impl._Private_IonTextWriterBuilder (com.amazon.ion.impl._Private_IonTextWriterBuilder)1 com.amazon.ion.impl._Private_IonValue (com.amazon.ion.impl._Private_IonValue)1 IonSystemBuilder (com.amazon.ion.system.IonSystemBuilder)1