@Override
        public LinkedBuffer writeByteArray(final byte[] value,
                final int offset, final int valueLen,
                final WriteSession session, final LinkedBuffer lb) throws IOException
        {
            if (valueLen == 0)
                return lb;

            session.size += valueLen;

            if (lb.offset + valueLen > lb.buffer.length)
            {
                // flush and reset
                lb.offset = session.flush(lb.buffer, lb.start, lb.offset - lb.start,
                        value, offset, valueLen);

                return lb;
            }

            System.arraycopy(value, offset, lb.buffer, lb.offset, valueLen);
            lb.offset += valueLen;

            return lb;
        }
The flexible output for outputs that use {@link WriteSession}.

@author David Yu
@created Sep 20, 2010
protostuff-api/src/main/java/io/protostuff/WriteSink.java