Search in sources :

Example 11 with IonSymbol

use of com.amazon.ion.IonSymbol in project ion-hive-serde by amzn.

the class IonStructToMapObjectInspector method getMapValueElement.

@Override
public Object getMapValueElement(final Object data, final Object key) {
    if (IonUtil.isIonNull((IonValue) data)) {
        return null;
    }
    if (key == null) {
        throw new IllegalArgumentException("key cannot be null");
    }
    final IonStruct struct = (IonStruct) data;
    final IonSymbol symbol = (IonSymbol) key;
    return struct.get(symbol.stringValue());
}
Also used : IonSymbol(com.amazon.ion.IonSymbol) IonStruct(com.amazon.ion.IonStruct)

Example 12 with IonSymbol

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

the class IonReaderTreeUserX method next_helper_user.

boolean next_helper_user() {
    if (_eof)
        return false;
    if (_next != null)
        return true;
    clear_system_value_stack();
    // read values from the system
    // reader and if they are system values
    // process them.  Return when we've
    // read all the immediate system values
    IonType next_type;
    for (; ; ) {
        next_type = next_helper_system();
        if (_top == 0 && _parent instanceof IonDatagram) {
            if (IonType.SYMBOL.equals(next_type)) {
                assert (_next instanceof IonSymbol);
                IonSymbol sym = (IonSymbol) _next;
                if (sym.isNullValue()) {
                    // there are no null values we will consume here
                    break;
                }
                int sid = sym.getSymbolId();
                if (sid == UNKNOWN_SYMBOL_ID) {
                    String name = sym.stringValue();
                    if (name != null) {
                        sid = _system_symtab.findSymbol(name);
                    }
                }
                if (sid == ION_1_0_SID && _next.getTypeAnnotationSymbols().length == 0) {
                    // $ion_1_0 is read as an IVM only if it is not annotated
                    SymbolTable symbols = _system_symtab;
                    _symbols = symbols;
                    push_symbol_table(symbols);
                    _next = null;
                    continue;
                }
            } else if (IonType.STRUCT.equals(next_type) && _next.findTypeAnnotation(ION_SYMBOL_TABLE) == 0) {
                assert (_next instanceof IonStruct);
                // read a local symbol table
                IonReader reader = new IonReaderTreeUserX(_next, _catalog, _lstFactory);
                SymbolTable symtab = _lstFactory.newLocalSymtab(_catalog, reader, false);
                _symbols = symtab;
                push_symbol_table(symtab);
                _next = null;
                continue;
            }
        }
        // so this is a value the user gets
        break;
    }
    return (next_type != null);
}
Also used : IonSymbol(com.amazon.ion.IonSymbol) IonStruct(com.amazon.ion.IonStruct) IonType(com.amazon.ion.IonType) IonDatagram(com.amazon.ion.IonDatagram) IonReader(com.amazon.ion.IonReader) SymbolTable(com.amazon.ion.SymbolTable)

Example 13 with IonSymbol

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

the class _Private_CurriedValueFactory method newSymbol.

public IonSymbol newSymbol(SymbolToken value) {
    IonSymbol v = myFactory.newSymbol(value);
    handle(v);
    return v;
}
Also used : IonSymbol(com.amazon.ion.IonSymbol)

Example 14 with IonSymbol

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

the class _Private_CurriedValueFactory method newNullSymbol.

// -------------------------------------------------------------------------
public IonSymbol newNullSymbol() {
    IonSymbol v = myFactory.newNullSymbol();
    handle(v);
    return v;
}
Also used : IonSymbol(com.amazon.ion.IonSymbol)

Example 15 with IonSymbol

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

the class IonWriterTestCase method testWriteSymbolTokenWithGoodSid.

@Test
public void testWriteSymbolTokenWithGoodSid() throws Exception {
    iw = makeWriter();
    iw.writeSymbolToken(newSymbolToken((String) null, NAME_SID));
    IonDatagram dg = reload();
    IonSymbol s = (IonSymbol) dg.get(0);
    checkSymbol(SystemSymbols.NAME, NAME_SID, s);
}
Also used : IonSymbol(com.amazon.ion.IonSymbol) IonDatagram(com.amazon.ion.IonDatagram) IonString(com.amazon.ion.IonString) Test(org.junit.Test)

Aggregations

IonSymbol (com.amazon.ion.IonSymbol)18 Test (org.junit.Test)9 IonDatagram (com.amazon.ion.IonDatagram)6 IonReader (com.amazon.ion.IonReader)4 IonString (com.amazon.ion.IonString)4 IonStruct (com.amazon.ion.IonStruct)4 SymbolTable (com.amazon.ion.SymbolTable)4 IonList (com.amazon.ion.IonList)3 BlobTest (com.amazon.ion.BlobTest)2 ClobTest (com.amazon.ion.ClobTest)2 IntTest (com.amazon.ion.IntTest)2 IonBool (com.amazon.ion.IonBool)2 IonFloat (com.amazon.ion.IonFloat)2 IonInt (com.amazon.ion.IonInt)2 IonTimestamp (com.amazon.ion.IonTimestamp)2 IonType (com.amazon.ion.IonType)2 IonValue (com.amazon.ion.IonValue)2 BinaryTest (com.amazon.ion.BinaryTest)1 IonBlob (com.amazon.ion.IonBlob)1 IonClob (com.amazon.ion.IonClob)1