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());
}
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);
}
}
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;
}
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);
}
Aggregations