in activeio-core/src/main/java/org/apache/activeio/packet/ByteBufferPacket.java [246:270]
public int read(Packet dest) {
int rc = Math.min(dest.remaining(), remaining());
if( rc > 0 ) {
if( dest.getClass() == ByteBufferPacket.class ) {
// Adjust our limit so that we don't overflow the dest buffer.
int limit = limit();
limit(position()+rc);
((ByteBufferPacket)dest).buffer.put(buffer);
// restore the limit.
limit(limit);
return 0;
} else {
ByteSequence sequence = dest.asByteSequence();
rc = read(sequence.getData(), sequence.getOffset(), sequence.getLength());
dest.position(dest.position()+rc);
}
}
return rc;
}