use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class IonReaderBuilderTest method testImmutable.
@Test
public void testImmutable() {
IonCatalog catalog = new SimpleCatalog();
IonReaderBuilder mutable = IonReaderBuilder.standard().withCatalog(catalog);
IonReaderBuilder immutable = mutable.immutable();
mutable.withCatalog(new SimpleCatalog());
assertNotSame(catalog, mutable.getCatalog());
assertSame(catalog, immutable.getCatalog());
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class IonReaderBuilderTest method testMutateCopiedImmutable.
@Test
public void testMutateCopiedImmutable() {
IonCatalog catalog = new SimpleCatalog();
IonReaderBuilder immutable = IonReaderBuilder.standard().withCatalog(catalog).immutable();
IonReaderBuilder mutableCopy = immutable.copy();
assertSame(immutable, immutable.immutable());
assertNotSame(immutable, mutableCopy);
assertSame(catalog, mutableCopy.getCatalog());
mutableCopy.withCatalog(new SimpleCatalog());
assertNotSame(catalog, mutableCopy.getCatalog());
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class BaseApp method getLatestSharedSymtab.
protected SymbolTable getLatestSharedSymtab(String name) {
IonCatalog catalog = mySystem.getCatalog();
SymbolTable table = catalog.getTable(name);
if (table == null) {
String message = "There's no symbol table in the catalog named " + name;
throw new RuntimeException(message);
}
logDebug("Found shared symbol table " + name + "@" + table.getVersion());
return table;
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class BaseApp method loadCatalog.
protected void loadCatalog(String catalogPath) {
System.err.println("Loading catalog from " + catalogPath);
File catalogFile = new File(catalogPath);
try {
InputStream in = new BufferedInputStream(new FileInputStream(catalogFile));
try {
IonReader reader = mySystem.newReader(in);
while (reader.next() != null) {
SymbolTable symtab = mySystem.newSharedSymbolTable(reader, true);
myCatalog.putTable(symtab);
}
} finally {
in.close();
}
} catch (Exception e) {
throw new RuntimeException("Error loading catalog from " + catalogPath + ": " + e.getMessage(), e);
}
IonCatalog catalog = mySystem.getCatalog();
assert myCatalog == catalog;
// logDebug("----Catalog content:");
// for (Iterator<StaticSymbolTable> i = catalog.iterator(); i.hasNext(); )
// {
// StaticSymbolTable table = i.next();
// logDebug(table.getName() + "@" + table.getVersion());
// }
// logDebug("----");
}
use of com.amazon.ion.IonCatalog in project ion-java by amzn.
the class _Private_IonWriterFactory method makeWriter.
/**
* @param container must not be null.
*/
public static IonWriter makeWriter(IonContainer container) {
IonSystem sys = container.getSystem();
IonCatalog cat = sys.getCatalog();
IonWriter writer = makeWriter(cat, container);
return writer;
}
Aggregations