/** * Read the field at {@code index}. {@code src}'s position is not affected. */ public Object decode(PositionedByteRange src, int index) { assert index >= 0; StructIterator it = iterator(src.shallowCopy()); for (; index > 0; index--) { it.skip(); } return it.next(); }
/** * Write instance {@code val} into buffer {@code dst}. * @throws IllegalArgumentException when the encoded representation of * {@code val} contains the {@code term} sequence. */ @Override public int encode(PositionedByteRange dst, T val) { final int start = dst.getPosition(); int written = wrapped.encode(dst, val); PositionedByteRange b = dst.shallowCopy(); b.setLength(dst.getPosition()); b.setPosition(start); if (-1 != terminatorPosition(b)) { dst.setPosition(start); throw new IllegalArgumentException("Encoded value contains terminator sequence."); } dst.put(term); return written + term.length; } }
/** * Read the field at {@code index}. {@code src}'s position is not affected. */ public Object decode(PositionedByteRange src, int index) { assert index >= 0; StructIterator it = iterator(src.shallowCopy()); for (; index > 0; index--) { it.skip(); } return it.next(); }
/** * Read the field at {@code index}. {@code src}'s position is not affected. */ public Object decode(PositionedByteRange src, int index) { assert index >= 0; StructIterator it = iterator(src.shallowCopy()); for (; index > 0; index--) { it.skip(); } return it.next(); }
/** * Read the field at {@code index}. {@code src}'s position is not affected. */ public Object decode(PositionedByteRange src, int index) { assert index >= 0; StructIterator it = iterator(src.shallowCopy()); for (; index > 0; index--) it.skip(); return it.next(); }
/** * Write instance {@code val} into buffer {@code dst}. * @throws IllegalArgumentException when the encoded representation of * {@code val} contains the {@code term} sequence. */ @Override public int encode(PositionedByteRange dst, T val) { final int start = dst.getPosition(); int written = wrapped.encode(dst, val); PositionedByteRange b = dst.shallowCopy(); b.setLength(dst.getPosition()); b.setPosition(start); if (-1 != terminatorPosition(b)) { dst.setPosition(start); throw new IllegalArgumentException("Encoded value contains terminator sequence."); } dst.put(term); return written + term.length; } }
/** * Write instance {@code val} into buffer {@code dst}. * @throws IllegalArgumentException when the encoded representation of * {@code val} contains the {@code term} sequence. */ @Override public int encode(PositionedByteRange dst, T val) { final int start = dst.getPosition(); int written = wrapped.encode(dst, val); PositionedByteRange b = dst.shallowCopy(); b.setLength(dst.getPosition()); b.setPosition(start); if (-1 != terminatorPosition(b)) { dst.setPosition(start); throw new IllegalArgumentException("Encoded value contains terminator sequence."); } dst.put(term); return written + term.length; } }
/** * Write instance {@code val} into buffer {@code dst}. * @throws IllegalArgumentException when the encoded representation of * {@code val} contains the {@code term} sequence. */ @Override public int encode(PositionedByteRange dst, T val) { final int start = dst.getPosition(); int written = wrapped.encode(dst, val); PositionedByteRange b = dst.shallowCopy(); b.setLength(dst.getPosition()); b.setPosition(start); if (-1 != terminatorPosition(b)) { dst.setPosition(start); throw new IllegalArgumentException("Encoded value contains terminator sequence."); } dst.put(term); return written + term.length; } }