use of com.amazon.ion.IonValue in project ion-java by amzn.
the class ReverseBinaryEncoder method writeIonStructContent.
private void writeIonStructContent(IonStruct val) {
if (val.isNullValue()) {
writeByte((byte) (TYPE_STRUCT | NULL_LENGTH_MASK));
} else {
final int originalOffset = myBuffer.length - myOffset;
// TODO amzn/ion-java/issues/31 should not preserve the ordering of fields
ArrayList<IonValue> values = new ArrayList<IonValue>();
// references of the IonValues
for (IonValue curr : val) {
values.add(curr);
}
for (int i = values.size(); --i >= 0; ) {
IonValue v = values.get(i);
SymbolToken symToken = v.getFieldNameSymbol();
writeIonValue(v);
int sid = findSid(symToken);
writeVarUInt(sid);
}
// TODO amzn/ion-java/issues/41 Detect if the struct fields are sorted in ascending
// order of Sids. If so, 1 should be written into 'length' field.
// Note that this 'length' field is not the same as the four-bit
// length L in the type descriptor octet.
writePrefix(TYPE_STRUCT, myBuffer.length - myOffset - originalOffset);
}
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonStructLite method retainAll.
public boolean retainAll(String... fieldNames) {
checkForLock();
boolean removedAny = false;
int size = get_child_count();
for (int ii = size; ii > 0; ) {
ii--;
IonValue field = get_child(ii);
if (!isListedField(field, fieldNames)) {
field.removeFromContainer();
removedAny = true;
}
}
return removedAny;
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonStructLite method get.
public IonValue get(String fieldName) {
int field_idx = find_field_helper(fieldName);
IonValue field;
if (field_idx < 0) {
if (hasNullFieldName)
throw new UnknownSymbolException("Unable to determine whether the field exists because the struct contains field names with unknown text.");
field = null;
} else {
field = get_child(field_idx);
}
return field;
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonSequenceLite method sequenceHashCode.
protected int sequenceHashCode(int seed, SymbolTableProvider symbolTableProvider) {
final int prime = 8191;
int result = seed;
if (!isNullValue()) {
for (IonValue v : this) {
IonValueLite vLite = (IonValueLite) v;
result = prime * result + vLite.hashCode(symbolTableProvider);
// mixing at each step to make the hash code order-dependent
result ^= (result << 29) ^ (result >> 3);
}
}
return hashTypeAnnotations(result, symbolTableProvider);
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonDatagramLite method hashCode.
@Override
public int hashCode() {
int prime = 8191;
int result = HASH_SIGNATURE;
if (!isNullValue()) {
// own symbol table.
for (IonValue v : this) {
result = prime * result + v.hashCode();
// mixing at each step to make the hash code order-dependent
result ^= (result << 29) ^ (result >> 3);
}
}
return result;
}
Aggregations