use of com.amazon.ion.impl._Private_IonWriter in project ion-java by amzn.
the class IonValueLite method writeTo.
final void writeTo(IonWriter writer, SymbolTableProvider symbolTableProvider) {
if (writer.isInStruct() && !((_Private_IonWriter) writer).isFieldNameSet()) {
SymbolToken tok = getFieldNameSymbol(symbolTableProvider);
if (tok == null) {
throw new IllegalStateException("Field name not set");
}
writer.setFieldNameSymbol(tok);
}
SymbolToken[] annotations = getTypeAnnotationSymbols(symbolTableProvider);
writer.setTypeAnnotationSymbols(annotations);
try {
writeBodyTo(writer, symbolTableProvider);
} catch (IOException e) {
throw new IonException(e);
}
}
use of com.amazon.ion.impl._Private_IonWriter in project ion-java by amzn.
the class IonBinaryWriterBuilderTest method testCustomCatalog.
// -------------------------------------------------------------------------
@Test
public void testCustomCatalog() {
IonCatalog catalog = new SimpleCatalog();
IonBinaryWriterBuilder b = IonBinaryWriterBuilder.standard();
b.setCatalog(catalog);
assertSame(catalog, b.getCatalog());
OutputStream out = new ByteArrayOutputStream();
IonWriter writer = b.build(out);
assertSame(catalog, ((_Private_IonWriter) writer).getCatalog());
IonCatalog catalog2 = new SimpleCatalog();
b.setCatalog(catalog2);
assertSame(catalog2, b.getCatalog());
// Test with...() on mutable builder
IonBinaryWriterBuilder b2 = b.withCatalog(catalog);
assertSame(b, b2);
assertSame(catalog, b2.getCatalog());
// Test with...() on immutable builder
b2 = b.immutable();
assertSame(catalog, b2.getCatalog());
IonBinaryWriterBuilder b3 = b2.withCatalog(catalog2);
assertNotSame(b2, b3);
assertSame(catalog, b2.getCatalog());
assertSame(catalog2, b3.getCatalog());
}
use of com.amazon.ion.impl._Private_IonWriter in project ion-java by amzn.
the class IonBinaryWriterBuilderTest method testStreamCopyOptimized.
// -------------------------------------------------------------------------
@Test
public void testStreamCopyOptimized() {
IonBinaryWriterBuilder b = IonBinaryWriterBuilder.standard();
b.setStreamCopyOptimized(true);
assertTrue(b.isStreamCopyOptimized());
OutputStream out = new ByteArrayOutputStream();
IonWriter w = b.build(out);
assertTrue(((_Private_IonWriter) w).isStreamCopyOptimized());
}
use of com.amazon.ion.impl._Private_IonWriter in project ion-java by amzn.
the class IonSystemBuilderTest method testStreamCopyOptimized.
// -------------------------------------------------------------------------
@Test
public void testStreamCopyOptimized() {
IonSystemBuilder b = IonSystemBuilder.standard().copy();
b.setStreamCopyOptimized(true);
IonSystem ion = b.build();
assertTrue(isLiteSystem(ion));
ByteArrayOutputStream out = new ByteArrayOutputStream();
IonWriter w = ion.newBinaryWriter(out);
assertTrue(((_Private_IonWriter) w).isStreamCopyOptimized());
}
use of com.amazon.ion.impl._Private_IonWriter in project ion-java by amzn.
the class IonTextWriterBuilderTest method testCustomCatalog.
// -------------------------------------------------------------------------
@Test
public void testCustomCatalog() {
IonCatalog catalog = new SimpleCatalog();
IonTextWriterBuilder b = IonTextWriterBuilder.standard();
b.setCatalog(catalog);
assertSame(catalog, b.getCatalog());
StringBuilder out = new StringBuilder();
IonWriter writer = b.build(out);
assertSame(catalog, ((_Private_IonWriter) writer).getCatalog());
IonCatalog catalog2 = new SimpleCatalog();
b.setCatalog(catalog2);
assertSame(catalog2, b.getCatalog());
// Test with...() on mutable builder
IonTextWriterBuilder b2 = b.withCatalog(catalog);
assertSame(b, b2);
assertSame(catalog, b2.getCatalog());
// Test with...() on immutable builder
b2 = b.immutable();
assertSame(catalog, b2.getCatalog());
IonTextWriterBuilder b3 = b2.withCatalog(catalog2);
assertNotSame(b2, b3);
assertSame(catalog, b2.getCatalog());
assertSame(catalog2, b3.getCatalog());
}
Aggregations