Search in sources :

Example 6 with ImportDescriptor

use of com.amazon.tools.events.ImportDescriptor in project ion-java by amzn.

the class IonJavaCli method ionStreamToEvent.

private static Event ionStreamToEvent(IonReader ionReader) throws IllegalStateException {
    if (ionReader.getType() == null)
        throw new IllegalStateException("Can't convert ionReader null type to Event");
    IonType ionType = ionReader.getType();
    SymbolToken fieldName = ionReader.getFieldNameSymbol();
    SymbolToken[] annotations = ionReader.getTypeAnnotationSymbols();
    int depth = ionReader.getDepth();
    ImportDescriptor[] imports = null;
    EventType eventType;
    IonValue value = null;
    if (IonType.isContainer(ionType)) {
        eventType = EventType.CONTAINER_START;
    } else {
        eventType = EventType.SCALAR;
        value = ION_SYSTEM.newValue(ionReader);
        value.clearTypeAnnotations();
        if (isIonVersionMarker(value.toString())) {
            value.setTypeAnnotationSymbols(_Private_Utils.newSymbolToken("$ion_user_value", 0));
        }
    }
    return new Event(eventType, ionType, fieldName, annotations, value, imports, depth);
}
Also used : IonValue(com.amazon.ion.IonValue) IonType(com.amazon.ion.IonType) SymbolToken(com.amazon.ion.SymbolToken) EventType(com.amazon.tools.events.EventType) Event(com.amazon.tools.events.Event) ImportDescriptor(com.amazon.tools.events.ImportDescriptor)

Aggregations

ImportDescriptor (com.amazon.tools.events.ImportDescriptor)6 IonType (com.amazon.ion.IonType)3 IonValue (com.amazon.ion.IonValue)3 Event (com.amazon.tools.events.Event)3 IonException (com.amazon.ion.IonException)2 SymbolTable (com.amazon.ion.SymbolTable)2 SymbolToken (com.amazon.ion.SymbolToken)2 EventType (com.amazon.tools.events.EventType)2 ArrayList (java.util.ArrayList)2 IonReader (com.amazon.ion.IonReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1