Search in sources :

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

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

the class IonBinaryWriterBuilderTest method testImmutableInitialSymtab.

@Test
public void testImmutableInitialSymtab() {
    SymbolTable sst = _Private_Utils.systemSymtab(1);
    // Immutable local symtabs shouldn't get copied.
    SymbolTable lst = Symtabs.localSymbolTableFactory().newLocalSymtab(sst);
    lst.intern("hello");
    lst.makeReadOnly();
    _Private_IonBinaryWriterBuilder b = _Private_IonBinaryWriterBuilder.standard();
    b.setInitialSymbolTable(lst);
    assertSame(lst, b.getInitialSymbolTable());
    OutputStream out = new ByteArrayOutputStream();
    IonWriter writer = b.build(out);
    assertTrue(symbolTableEquals(lst, writer.getSymbolTable()));
    writer = b.build(out);
    assertTrue(symbolTableEquals(lst, writer.getSymbolTable()));
}
Also used : com.amazon.ion.impl._Private_IonBinaryWriterBuilder(com.amazon.ion.impl._Private_IonBinaryWriterBuilder) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SymbolTable(com.amazon.ion.SymbolTable) IonWriter(com.amazon.ion.IonWriter) com.amazon.ion.impl._Private_IonWriter(com.amazon.ion.impl._Private_IonWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

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

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

the class IonBinaryWriterBuilderTest method testInitialSymtabImmutability.

@Test(expected = UnsupportedOperationException.class)
public void testInitialSymtabImmutability() {
    _Private_IonBinaryWriterBuilder b = _Private_IonBinaryWriterBuilder.standard();
    b.setInitialSymbolTable(null);
    _Private_IonBinaryWriterBuilder b2 = b.immutable();
    b2.setInitialSymbolTable(null);
}
Also used : com.amazon.ion.impl._Private_IonBinaryWriterBuilder(com.amazon.ion.impl._Private_IonBinaryWriterBuilder) Test(org.junit.Test)

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

use of com.amazon.ion.impl._Private_IonBinaryWriterBuilder 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 4 with com.amazon.ion.impl._Private_IonBinaryWriterBuilder

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

the class IonBinaryWriterBuilderTest method testSymtabValueFactory.

// -------------------------------------------------------------------------
@Test
public void testSymtabValueFactory() {
    IonSystem system = IonSystemBuilder.standard().build();
    _Private_IonBinaryWriterBuilder b = _Private_IonBinaryWriterBuilder.standard();
    b.setSymtabValueFactory(system);
    assertSame(system, b.getSymtabValueFactory());
// The value factory isn't visible through other APIs so we can't
// really test any further.
}
Also used : IonSystem(com.amazon.ion.IonSystem) com.amazon.ion.impl._Private_IonBinaryWriterBuilder(com.amazon.ion.impl._Private_IonBinaryWriterBuilder) Test(org.junit.Test)

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

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

the class IonBinaryWriterBuilderTest method testSymtabValueFactoryImmutability.

@Test(expected = UnsupportedOperationException.class)
public void testSymtabValueFactoryImmutability() {
    _Private_IonBinaryWriterBuilder b = _Private_IonBinaryWriterBuilder.standard();
    b.setSymtabValueFactory(IonSystemBuilder.standard().build());
    _Private_IonBinaryWriterBuilder b2 = b.immutable();
    b2.setSymtabValueFactory(null);
}
Also used : com.amazon.ion.impl._Private_IonBinaryWriterBuilder(com.amazon.ion.impl._Private_IonBinaryWriterBuilder) Test(org.junit.Test)

Aggregations

com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)6 Test (org.junit.Test)5 SymbolTable (com.amazon.ion.SymbolTable)3 IonWriter (com.amazon.ion.IonWriter)2 com.amazon.ion.impl._Private_IonWriter (com.amazon.ion.impl._Private_IonWriter)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 IonCatalog (com.amazon.ion.IonCatalog)1 IonSystem (com.amazon.ion.IonSystem)1