Search in sources :

Example 11 with IonCatalog

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

the class IonSystemLite method newDatagram.

public IonDatagram newDatagram() {
    IonCatalog catalog = this.getCatalog();
    IonDatagram dg = newDatagram(catalog);
    return dg;
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) IonCatalog(com.amazon.ion.IonCatalog)

Example 12 with IonCatalog

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

the class IonSystemBuilder method build.

// =========================================================================
/**
 * Builds a new {@link IonSystem} instance based on this builder's
 * configuration properties.
 */
public final IonSystem build() {
    IonCatalog catalog = (myCatalog != null ? myCatalog : new SimpleCatalog());
    IonTextWriterBuilder twb = IonTextWriterBuilder.standard().withCharsetAscii();
    twb.setCatalog(catalog);
    _Private_IonBinaryWriterBuilder bwb = _Private_IonBinaryWriterBuilder.standard();
    bwb.setCatalog(catalog);
    bwb.setStreamCopyOptimized(myStreamCopyOptimized);
    // TODO Would be nice to remove this since it's implied by the BWB.
    // However that currently causes problems in the IonSystem
    // constructors (which get a null initialSymtab).
    SymbolTable systemSymtab = _Private_Utils.systemSymtab(1);
    bwb.setInitialSymbolTable(systemSymtab);
    // This is what we need, more or less.
    // bwb = bwb.fillDefaults();
    IonReaderBuilder rb = readerBuilder == null ? IonReaderBuilder.standard() : readerBuilder;
    rb = rb.withCatalog(catalog);
    return newLiteSystem(twb, bwb, rb);
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) com.amazon.ion.impl._Private_IonBinaryWriterBuilder(com.amazon.ion.impl._Private_IonBinaryWriterBuilder) SymbolTable(com.amazon.ion.SymbolTable)

Example 13 with IonCatalog

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

the class IonReaderBuilderTest method testMutable.

@Test
public void testMutable() {
    IonCatalog catalog = new SimpleCatalog();
    IonReaderBuilder mutable = IonReaderBuilder.standard().withCatalog(catalog);
    assertSame(catalog, mutable.getCatalog());
    IonReaderBuilder mutableSame = mutable.withCatalog(new SimpleCatalog());
    assertNotSame(catalog, mutable.getCatalog());
    assertSame(mutable, mutableSame);
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Example 14 with IonCatalog

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

the class IonReaderBuilderTest method testMutateCopiedMutable.

@Test
public void testMutateCopiedMutable() {
    IonCatalog catalog = new SimpleCatalog();
    IonReaderBuilder mutable = IonReaderBuilder.standard().withCatalog(catalog);
    IonReaderBuilder mutableCopy = mutable.copy();
    assertNotSame(mutable, mutable.immutable());
    assertNotSame(mutable, mutableCopy);
    assertSame(mutable, mutable.mutable());
    assertSame(catalog, mutableCopy.getCatalog());
    IonReaderBuilder mutableSame = mutableCopy.withCatalog(new SimpleCatalog());
    assertNotSame(catalog, mutableCopy.getCatalog());
    assertSame(mutableCopy, mutableSame);
}
Also used : IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Example 15 with IonCatalog

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

the class IonSystemBuilderTest method testFluidStyle.

// -------------------------------------------------------------------------
@Test
public void testFluidStyle() {
    IonCatalog catalog = new SimpleCatalog();
    IonSystem ion = IonSystemBuilder.standard().withCatalog(catalog).withStreamCopyOptimized(true).build();
    assertSame(catalog, ion.getCatalog());
}
Also used : IonSystem(com.amazon.ion.IonSystem) IonCatalog(com.amazon.ion.IonCatalog) Test(org.junit.Test)

Aggregations

IonCatalog (com.amazon.ion.IonCatalog)19 Test (org.junit.Test)12 IonSystem (com.amazon.ion.IonSystem)5 SymbolTable (com.amazon.ion.SymbolTable)5 IonWriter (com.amazon.ion.IonWriter)4 com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)3 com.amazon.ion.impl._Private_IonWriter (com.amazon.ion.impl._Private_IonWriter)2 IonDatagram (com.amazon.ion.IonDatagram)1 IonException (com.amazon.ion.IonException)1 IonReader (com.amazon.ion.IonReader)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1