Search in sources :

Example 61 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class IonDatagramLite method getContextForIndex.

@Override
public IonContext getContextForIndex(IonValue element, int index) {
    if (index == this._pending_symbol_table_idx) {
        SymbolTable symbols = _pending_symbol_table;
        _pending_symbol_table = null;
        _pending_symbol_table_idx = -1;
        return TopLevelContext.wrap(symbols, this);
    }
    // the preceding elements symbol table is our next
    IonValueLite preceding = (index > 0) ? get_child(index - 1) : null;
    if (preceding != null && preceding._context != this) {
        return preceding._context;
    }
    // symbol table
    return TopLevelContext.wrap(null, this);
}
Also used : SymbolTable(com.amazon.ion.SymbolTable)

Example 62 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class IonReaderTextSystemX method resolveAnnotationSymbols.

/**
 * Resolve annotations with the current symbol table.
 */
private void resolveAnnotationSymbols(int count) {
    SymbolTable symbols = getSymbolTable();
    for (int i = 0; i < count; i++) {
        SymbolToken sym = _annotations[i];
        SymbolToken updated = _Private_Utils.localize(symbols, sym);
        if (updated != sym) {
            _annotations[i] = updated;
        }
    }
}
Also used : SymbolToken(com.amazon.ion.SymbolToken) SymbolTable(com.amazon.ion.SymbolTable)

Example 63 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class IonReaderTextSystemX method getFieldName.

@Override
public final String getFieldName() {
    // Superclass handles hoisting logic
    String text = getRawFieldName();
    if (text == null) {
        int id = getFieldId();
        if (id != SymbolTable.UNKNOWN_SYMBOL_ID) {
            SymbolTable symbols = getSymbolTable();
            text = symbols.findKnownSymbol(id);
            if (text == null) {
                throw new UnknownSymbolException(id);
            }
        }
    }
    return text;
}
Also used : UnknownSymbolException(com.amazon.ion.UnknownSymbolException) SymbolTable(com.amazon.ion.SymbolTable)

Example 64 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class IonWriterSystemBinary method inject_local_symbol_table.

@Override
final SymbolTable inject_local_symbol_table() throws IOException {
    SymbolTable symbols = super.inject_local_symbol_table();
    PatchedValues top;
    // find the parent
    for (top = _patch; top.getParent() != null; top = top.getParent()) {
    }
    // inject the symbol table; if @_patch is not the top element, then inject
    // the symtab before this top-level value begins
    super.startValue();
    top.injectSymbolTable(symbols, _patch.getParent() != null);
    super.endValue();
    return symbols;
}
Also used : SymbolTable(com.amazon.ion.SymbolTable)

Example 65 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class IonWriterSystemText method writeSymbolAsIs.

@Override
void writeSymbolAsIs(int symbolId) throws IOException {
    SymbolTable symtab = getSymbolTable();
    String text = symtab.findKnownSymbol(symbolId);
    if (text != null) {
        writeSymbolAsIs(text);
    } else {
        startValue();
        writeSidLiteral(symbolId);
        closeValue();
    }
}
Also used : SymbolTable(com.amazon.ion.SymbolTable)

Aggregations

SymbolTable (com.amazon.ion.SymbolTable)177 Test (org.junit.Test)105 IonValue (com.amazon.ion.IonValue)21 IonDatagram (com.amazon.ion.IonDatagram)18 com.amazon.ion.impl._Private_Utils.copyLocalSymbolTable (com.amazon.ion.impl._Private_Utils.copyLocalSymbolTable)17 SymbolToken (com.amazon.ion.SymbolToken)14 IonStruct (com.amazon.ion.IonStruct)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)13 IonWriter (com.amazon.ion.IonWriter)12 SimpleCatalog (com.amazon.ion.system.SimpleCatalog)12 IonReader (com.amazon.ion.IonReader)11 IonSystem (com.amazon.ion.IonSystem)10 IOException (java.io.IOException)9 IonType (com.amazon.ion.IonType)8 ArrayList (java.util.ArrayList)7 IonException (com.amazon.ion.IonException)6 com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)6 com.amazon.ion.impl.bin._Private_IonRawWriter (com.amazon.ion.impl.bin._Private_IonRawWriter)6 IonCatalog (com.amazon.ion.IonCatalog)5 IonList (com.amazon.ion.IonList)5