use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class _Private_IonTextWriterBuilder method build.
/**
* Assumes that {@link #fillDefaults()} has been called.
*/
private IonWriter build(_Private_FastAppendable appender) {
IonCatalog catalog = getCatalog();
SymbolTable[] imports = getImports();
// TODO We shouldn't need a system here
IonSystem system = IonSystemBuilder.standard().withCatalog(catalog).build();
SymbolTable defaultSystemSymtab = system.getSystemSymbolTable();
IonWriterSystemText systemWriter = (getCallbackBuilder() == null ? new IonWriterSystemText(defaultSystemSymtab, this, appender) : new IonWriterSystemTextMarkup(defaultSystemSymtab, this, appender));
SymbolTable initialSymtab = initialSymtab(((_Private_ValueFactory) system).getLstFactory(), defaultSystemSymtab, imports);
return new IonWriterUser(catalog, system, systemWriter, initialSymtab);
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class _Private_IonWriterFactory method makeSystemWriter.
/**
* @param container must not be null.
*/
public static IonWriter makeSystemWriter(IonContainer container) {
IonSystem sys = container.getSystem();
IonCatalog cat = sys.getCatalog();
SymbolTable defaultSystemSymtab = sys.getSystemSymbolTable();
IonWriter writer = new IonWriterSystemTree(defaultSystemSymtab, cat, container, null);
return writer;
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class IonSystemBuilderTest method testCopy.
@Test
public void testCopy() {
IonCatalog catalog = new SimpleCatalog();
IonSystemBuilder b1 = IonSystemBuilder.standard().withCatalog(catalog).withStreamCopyOptimized(true);
IonSystemBuilder b2 = b1.copy();
assertNotSame(b1, b2);
assertSame(b1.getCatalog(), b2.getCatalog());
assertSame(b1.isStreamCopyOptimized(), b2.isStreamCopyOptimized());
}
use of com.amazon.ion.IonCatalog 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.IonCatalog in project ion-java by amzn.
the class IonBinaryWriterBuilderTest method testCatalogImmutability.
@Test(expected = UnsupportedOperationException.class)
public void testCatalogImmutability() {
IonCatalog catalog = new SimpleCatalog();
IonBinaryWriterBuilder b = IonBinaryWriterBuilder.standard();
b.setCatalog(catalog);
IonBinaryWriterBuilder b2 = b.immutable();
assertSame(catalog, b2.getCatalog());
b2.setCatalog(null);
}
Aggregations