/** * Returns total number of bytes stored in this link and all its predecessors. * * @return total number of bytes stored in this link and all its predecessors */ public int getTotalSize() { return (prev == null) ? usedSize : prev.getTotalSize() + usedSize; }
@Override public long getSize() { return buffer.getLast().getTotalSize(); }
@Override public long getSize() { return buffer.getLast().getTotalSize(); }
/** * @see java.io.InputStream#mark(int) */ public void mark(int readAheadLimit) { if (current == null) { mark = 0; } else { mark = index; ByteBuffer b = current.getPrevious(); if (b != null) { mark += b.getTotalSize(); } } }
private byte[] getBufferBytes() { byte[] bs = new byte[buffer.getLast().getTotalSize()]; int pos = 0; ByteBuffer currentBuffer = buffer; while (currentBuffer != null) { System.arraycopy(currentBuffer.getBytes(), 0, bs, pos, currentBuffer.getUsedSize()); pos += currentBuffer.getUsedSize(); currentBuffer = currentBuffer.getNext(); } return bs; }
private byte[] getBufferBytes() { byte[] bs = new byte[buffer.getLast().getTotalSize()]; int pos = 0; ByteBuffer currentBuffer = buffer; while (currentBuffer != null) { System.arraycopy(currentBuffer.getBytes(), 0, bs, pos, currentBuffer.getUsedSize()); pos += currentBuffer.getUsedSize(); currentBuffer = currentBuffer.getNext(); } return bs; }
public byte[] toByteArray() { ByteBuffer b = getFirstBuffer(); if (b == null) { return new byte[0]; } ByteBuffer l = b; while (l.getNext() != null) { l = l.getNext(); } byte[] result = new byte[l.getTotalSize()]; int index = 0; while (b != null) { int s = b.getUsedSize(); System.arraycopy(b.getBytes(), 0, result, index, s); index += s; b = b.getNext(); } return result; }