use of com.amazon.ion.SubstituteSymbolTableException in project ion-java by amzn.
the class _Private_IonBinaryWriterBuilder method setInitialSymbolTable.
/**
* Declares the symbol table to use for encoded data.
* To avoid conflicts between different data streams, if the given instance
* is mutable, it will be copied when {@code build()} is called.
*
* @param symtab must be a local or system symbol table.
* May be null, in which case the initial symtab is that of
* {@code $ion_1_0}.
*
* @throws SubstituteSymbolTableException
* if any imported table is a substitute (see {@link SymbolTable}).
*/
@Override
public void setInitialSymbolTable(SymbolTable symtab) {
mutationCheck();
if (symtab != null) {
if (symtab.isLocalTable()) {
SymbolTable[] imports = ((LocalSymbolTable) symtab).getImportedTablesNoCopy();
for (SymbolTable imported : imports) {
if (imported.isSubstitute()) {
String message = "Cannot encode with substitute symbol table: " + imported.getName();
throw new SubstituteSymbolTableException(message);
}
}
} else if (!symtab.isSystemTable()) {
String message = "symtab must be local or system table";
throw new IllegalArgumentException(message);
}
}
myInitialSymbolTable = symtab;
myBinaryWriterBuilder.withInitialSymbolTable(symtab);
}
Aggregations