Search in sources :

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

use of com.amazon.ion.impl._Private_IonTextWriterBuilder 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)

Aggregations

IonDatagram (com.amazon.ion.IonDatagram)1 IonReader (com.amazon.ion.IonReader)1 IonWriter (com.amazon.ion.IonWriter)1 com.amazon.ion.impl._Private_IonSystem (com.amazon.ion.impl._Private_IonSystem)1 com.amazon.ion.impl._Private_IonTextWriterBuilder (com.amazon.ion.impl._Private_IonTextWriterBuilder)1