@Test(expected = IllegalArgumentException.class) public void testInvalidSkip() { PositionedByteRange buff = new SimplePositionedByteRange(Bytes.toBytes("foo")); DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(), new byte[] { 0x00 }); type.skip(buff); }
@Override public int skip(PositionedByteRange src) { if (wrapped.isSkippable()) { int ret = wrapped.skip(src); src.setPosition(src.getPosition() + term.length); return ret + term.length; } else { final int start = src.getPosition(); int skipped = terminatorPosition(src); if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found."); skipped += term.length; src.setPosition(skipped); return skipped - start; } }
TerminatedWrapper implements DataType<T> { @Override public int skip(PositionedByteRange src) { if (wrapped.isSkippable()) { int ret = wrapped.skip(src); src.setPosition(src.getPosition() + term.length); return ret + term.length; } else { final int start = src.getPosition(); int skipped = terminatorPosition(src); if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found."); skipped += term.length; src.setPosition(skipped); return skipped - start; } } }
TerminatedWrapper implements DataType<T> { @Override public int skip(PositionedByteRange src) { if (wrapped.isSkippable()) { int ret = wrapped.skip(src); src.setPosition(src.getPosition() + term.length); return ret + term.length; } else { final int start = src.getPosition(); int skipped = terminatorPosition(src); if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found."); skipped += term.length; src.setPosition(skipped); return skipped - start; } } TerminatedWrapper(DataType<T> wrapped, byte[] term);  TerminatedWrapper(DataType<T> wrapped, String term); }
TerminatedWrapper implements DataType<T> { @Override public int skip(PositionedByteRange src) { if (wrapped.isSkippable()) { int ret = wrapped.skip(src); src.setPosition(src.getPosition() + term.length); return ret + term.length; } else { final int start = src.getPosition(); int skipped = terminatorPosition(src); if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found."); skipped += term.length; src.setPosition(skipped); return skipped - start; } } TerminatedWrapper(DataType<T> wrapped, byte[] term);  TerminatedWrapper(DataType<T> wrapped, String term); @Override boolean isOrderPreserving(); @Override Order getOrder(); @Override boolean isNullable(); @Override boolean isSkippable(); @Override int encodedLength(T val); @Override Class<T> encodedClass(); @Override int skip(PositionedByteRange src); @Override T decode(PositionedByteRange src); @Override int encode(PositionedByteRange dst, T val); }
TerminatedWrapper implements DataType<T> { @Override public int skip(PositionedByteRange src) { if (wrapped.isSkippable()) { int ret = wrapped.skip(src); src.setPosition(src.getPosition() + term.length); return ret + term.length; } else { final int start = src.getPosition(); int skipped = terminatorPosition(src); if (-1 == skipped) throw new IllegalArgumentException("Terminator sequence not found."); skipped += term.length; src.setPosition(skipped); return skipped - start; } } TerminatedWrapper(DataType<T> wrapped, byte[] term);  TerminatedWrapper(DataType<T> wrapped, String term); @Override boolean isOrderPreserving(); @Override Order getOrder(); @Override boolean isNullable(); @Override boolean isSkippable(); @Override int encodedLength(T val); @Override Class<T> encodedClass(); @Override int skip(PositionedByteRange src); @Override T decode(PositionedByteRange src); @Override int encode(PositionedByteRange dst, T val);  }