Search in sources :

Example 1 with LstMinimizing

use of com.amazon.ion.system.IonTextWriterBuilder.LstMinimizing in project ion-java by amzn.

the class IonWriterSystemText method writeLocalSymtab.

@Override
void writeLocalSymtab(SymbolTable symtab) throws IOException {
    SymbolTable[] imports = symtab.getImportedTables();
    LstMinimizing min = _options.getLstMinimizing();
    if (min == null) {
        symtab.writeTo(this);
    } else if (min == LstMinimizing.LOCALS && imports.length > 0) {
        // Copy the symtab, but filter out local symbols.
        IonReader reader = new SymbolTableReader(symtab);
        // move onto and write the struct header
        IonType t = reader.next();
        assert (IonType.STRUCT.equals(t));
        SymbolToken[] a = reader.getTypeAnnotationSymbols();
        // you (should) always have the $ion_symbol_table annotation
        assert (a != null && a.length >= 1);
        // now we'll start a local symbol table struct
        // in the underlying system writer
        setTypeAnnotationSymbols(a);
        stepIn(IonType.STRUCT);
        // step into the symbol table struct and
        // write the values - EXCEPT the symbols field
        reader.stepIn();
        for (; ; ) {
            t = reader.next();
            if (t == null)
                break;
            // get the field name and skip over 'symbols'
            String name = reader.getFieldName();
            if (SYMBOLS.equals(name)) {
                continue;
            }
            writeValue(reader);
        }
        // we're done step out and move along
        stepOut();
    } else // Collapse to IVM
    {
        SymbolTable systemSymtab = symtab.getSystemSymbolTable();
        writeIonVersionMarker(systemSymtab);
    }
    super.writeLocalSymtab(symtab);
}
Also used : IonType(com.amazon.ion.IonType) LstMinimizing(com.amazon.ion.system.IonTextWriterBuilder.LstMinimizing) IonReader(com.amazon.ion.IonReader) SymbolTable(com.amazon.ion.SymbolTable)

Aggregations

IonReader (com.amazon.ion.IonReader)1 IonType (com.amazon.ion.IonType)1 SymbolTable (com.amazon.ion.SymbolTable)1 LstMinimizing (com.amazon.ion.system.IonTextWriterBuilder.LstMinimizing)1