@Override public IN apply(Buffer buffer) { if (consumer != null) { int pos; while ((pos = buffer.position()) < buffer.limit()) { super.apply(buffer); if (pos == buffer.position()) { break; } } return null; } return super.apply(buffer); }
@Override public Buffer get() { Buffer b = Buffer.this.duplicate(); b.limit(end); b.position(start); return b; }
@Override public Buffer.View next() { int limit = buffer.limit(); int endchunk = canDecodeNext(buffer, context); if (endchunk == -1) { return null; } Buffer.View view = buffer.createView(buffer.position(), endchunk); if (buffer.remaining() > 0) { buffer.position(Math.min(limit, view.getEnd())); buffer.limit(limit); } return view; }
@Override protected IN decodeNext(Buffer buffer, Object context) { try { Class<IN> clazz = readType(buffer); byte[] bytes = buffer.asBytes(); buffer.position(buffer.limit()); return deserializer(engine, clazz).apply(bytes); } catch (RuntimeException e) { if (log.isErrorEnabled()) { log.error("Could not decode " + buffer, e); } throw e; } }