Search in sources :

Example 1 with com.amazon.ion.impl._Private_IonValue

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

the class StructTest method dump.

void dump(IonStruct s1_temp, ArrayList<TestField> s2) {
    _Private_IonValue s1 = ((_Private_IonValue) s1_temp);
    s1.dump(new PrintWriter(System.out));
    System.out.println("array: " + s2.toString());
}
Also used : com.amazon.ion.impl._Private_IonValue(com.amazon.ion.impl._Private_IonValue) PrintWriter(java.io.PrintWriter)

Example 2 with com.amazon.ion.impl._Private_IonValue

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

the class IonWriterSystemTree method stepOut.

public void stepOut() throws IOException {
    _Private_IonValue prior = (_Private_IonValue) _current_parent;
    popParent();
    if (_current_parent instanceof IonDatagram && valueIsLocalSymbolTable(prior)) {
        // We just finish writing a symbol table!
        SymbolTable symbol_table = _lst_factory.newLocalSymtab(_catalog, (IonStruct) prior);
        setSymbolTable(symbol_table);
    }
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) SymbolTable(com.amazon.ion.SymbolTable) com.amazon.ion.impl._Private_Utils.valueIsLocalSymbolTable(com.amazon.ion.impl._Private_Utils.valueIsLocalSymbolTable)

Example 3 with com.amazon.ion.impl._Private_IonValue

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

the class StructTest method compare_field_lists.

void compare_field_lists(IonStruct s1, ArrayList<TestField> s2, long seed) {
    String errors = "";
    boolean difference = false;
    // quick check - are the sizes the same?
    if (s1.size() != s2.size()) {
        errors += "sizes differ:";
        errors += "struct = " + s1.size();
        errors += " vs array = " + s2.size();
        errors += "\n";
    }
    // first see if every value in the struct is in the array
    Iterator<IonValue> it = s1.iterator();
    int struct_idx = 0;
    while (it.hasNext()) {
        IonValue v = it.next();
        if (find_field(s2, v) == false) {
            difference = true;
            errors += "extra field in struct " + v;
            errors += "\n";
        }
        if (v instanceof _Private_IonValue) {
            int eid = ((_Private_IonValue) v).getElementId();
            if (eid != struct_idx) {
                difference = true;
                errors += "index of struct field " + struct_idx + " doesn't match array index " + eid + ": " + v;
                errors += "\n";
            }
        }
        struct_idx++;
    }
    // now check if every value in the array is in the struct
    for (int ii = 0; ii < s2.size(); ii++) {
        TestField fld = s2.get(ii);
        IonValue v = fld._value;
        if (s1.containsValue(v) == false) {
            difference = true;
            errors += "field missing from struct " + v.toString();
            errors += "\n";
        }
    }
    if (_debug_print_flag) {
        // now check the map, if there is one
        _Private_IonValue l = (_Private_IonValue) s1;
        String map_error = l.validate();
        if (map_error != null) {
            errors += map_error;
            difference = true;
        }
    }
    // if so we're equal and everything's ok
    if (difference) {
        if (_debug_print_flag) {
            System.out.println(errors);
        }
        if (!difference) {
            this.compare_field_lists(s1, s2, seed);
        }
        errors += "\nSEED: " + seed;
        assertFalse(errors, difference);
    }
    return;
}
Also used : com.amazon.ion.impl._Private_IonValue(com.amazon.ion.impl._Private_IonValue) com.amazon.ion.impl._Private_IonValue(com.amazon.ion.impl._Private_IonValue)

Example 4 with com.amazon.ion.impl._Private_IonValue

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

the class TrueSequenceTestCase method set.

private void set(IonSequence s, int index) {
    IonValue origElement = s.get(index);
    IonValue newElement = system().newInt(index);
    IonSequence expectedElements = s.clone();
    expectedElements.remove(index);
    expectedElements.add(index, newElement.clone());
    IonValue removed = s.set(index, newElement);
    assertSame(newElement, s.get(index));
    assertSame(s, newElement.getContainer());
    assertSame(origElement, removed);
    assertEquals(null, removed.getContainer());
    assertEquals(index, ((_Private_IonValue) newElement).getElementId());
    assertEquals(expectedElements, s);
}
Also used : com.amazon.ion.impl._Private_IonValue(com.amazon.ion.impl._Private_IonValue)

Aggregations

com.amazon.ion.impl._Private_IonValue (com.amazon.ion.impl._Private_IonValue)3 IonDatagram (com.amazon.ion.IonDatagram)1 SymbolTable (com.amazon.ion.SymbolTable)1 com.amazon.ion.impl._Private_Utils.valueIsLocalSymbolTable (com.amazon.ion.impl._Private_Utils.valueIsLocalSymbolTable)1 PrintWriter (java.io.PrintWriter)1