use of com.amazon.ion.impl.UnifiedInputStreamX.FromByteArray in project ion-java by amzn.
the class IonReaderBinaryUserX method seek.
public void seek(IonReaderBinarySpan position) {
IonReaderBinarySpan pos = position;
if (pos == null) {
throw new IllegalArgumentException("Position invalid for binary reader");
}
if (!(_input instanceof FromByteArray)) {
throw new UnsupportedOperationException("Binary seek not implemented for non-byte array backed sources");
}
// TODO test that span is within the bounds of the input byte[]
// manually reset the input specific type of input stream
FromByteArray input = (FromByteArray) _input;
input._pos = (int) (pos._offset + _physical_start_offset);
input._limit = (int) (pos._limit + _physical_start_offset);
// TODO: these (eof and save points) should be put into
// a re-init method on the input stream
input._eof = false;
for (; ; ) {
SavePoint sp = input._save_points._active_stack;
if (sp == null)
break;
input._save_points.savePointPopActive(sp);
sp.free();
}
// reset the raw reader
re_init_raw();
// reset the system reader
// - nothing to do
// reset the user reader
init_user(this._catalog);
// now we need to set our symbol table
_symbols = pos._symbol_table;
// and the other misc state variables we had
// read past before getPosition gets called
// Don't do this, we'll re-read the data from the stream.
// Otherwise, this reader will be in the wrong state.
// For example, getType() will return non-null but that
// shouldn't happen until the user calls next().
// _state = pos._state;
// _value_type = pos._value_type;
// _value_is_null = pos._value_is_null;
// _value_is_true = pos._value_is_true;
// _is_in_struct = false;
}
Aggregations