@Override public void update(int b) { oneByte[0] = (byte) (b & 0xff); update(oneByte, 0, 1); }
private void writeFrameDescriptor() throws IOException { int flags = FramedLZ4CompressorInputStream.SUPPORTED_VERSION; if (!params.withBlockDependency) { flags |= FramedLZ4CompressorInputStream.BLOCK_INDEPENDENCE_MASK; } if (params.withContentChecksum) { flags |= FramedLZ4CompressorInputStream.CONTENT_CHECKSUM_MASK; } if (params.withBlockChecksum) { flags |= FramedLZ4CompressorInputStream.BLOCK_CHECKSUM_MASK; } out.write(flags); contentHash.update(flags); int bd = (params.blockSize.getIndex() << 4) & FramedLZ4CompressorInputStream.BLOCK_MAX_SIZE_MASK; out.write(bd); contentHash.update(bd); out.write((int) ((contentHash.getValue() >> 8) & 0xff)); contentHash.reset(); }
@Override public void write(byte[] data, int off, int len) throws IOException { if (params.withContentChecksum) { contentHash.update(data, off, len); } if (currentIndex + len > blockData.length) { flushBlock(); while (len > blockData.length) { System.arraycopy(data, off, blockData, 0, blockData.length); off += blockData.length; len -= blockData.length; currentIndex = blockData.length; flushBlock(); } } System.arraycopy(data, off, blockData, currentIndex, len); currentIndex += len; }
throw new IOException("Premature end of stream while reading frame flags"); contentHash.update(flags); if ((flags & VERSION_MASK) != SUPPORTED_VERSION) { throw new IOException("Unsupported version " + (flags >> 6)); throw new IOException("Premature end of stream while reading frame BD byte"); contentHash.update(bdByte); if (expectContentSize) { // for now we don't care, contains the uncompressed size byte[] contentSize = new byte[8]; throw new IOException("Premature end of stream while reading content size"); contentHash.update(contentSize, 0, contentSize.length);
/** {@inheritDoc} */ @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (endReached) { return -1; } int r = readOnce(b, off, len); if (r == -1) { nextBlock(); if (!endReached) { r = readOnce(b, off, len); } } if (r != -1) { if (expectBlockDependency) { appendToBlockDependencyBuffer(b, off, r); } if (expectContentChecksum) { contentHash.update(b, off, r); } } return r; }
@Override public void update(int b) { oneByte[0] = (byte) (b & 0xff); update(oneByte, 0, 1); }
private void writeFrameDescriptor() throws IOException { int flags = FramedLZ4CompressorInputStream.SUPPORTED_VERSION; if (!params.withBlockDependency) { flags |= FramedLZ4CompressorInputStream.BLOCK_INDEPENDENCE_MASK; } if (params.withContentChecksum) { flags |= FramedLZ4CompressorInputStream.CONTENT_CHECKSUM_MASK; } if (params.withBlockChecksum) { flags |= FramedLZ4CompressorInputStream.BLOCK_CHECKSUM_MASK; } out.write(flags); contentHash.update(flags); int bd = (params.blockSize.getIndex() << 4) & FramedLZ4CompressorInputStream.BLOCK_MAX_SIZE_MASK; out.write(bd); contentHash.update(bd); out.write((int) ((contentHash.getValue() >> 8) & 0xff)); contentHash.reset(); }
@Override public void write(byte[] data, int off, int len) throws IOException { if (params.withContentChecksum) { contentHash.update(data, off, len); } if (currentIndex + len > blockData.length) { flushBlock(); while (len > blockData.length) { System.arraycopy(data, off, blockData, 0, blockData.length); off += blockData.length; len -= blockData.length; currentIndex = blockData.length; flushBlock(); } } System.arraycopy(data, off, blockData, currentIndex, len); currentIndex += len; }
throw new IOException("Premature end of stream while reading frame flags"); contentHash.update(flags); if ((flags & VERSION_MASK) != SUPPORTED_VERSION) { throw new IOException("Unsupported version " + (flags >> 6)); throw new IOException("Premature end of stream while reading frame BD byte"); contentHash.update(bdByte); if (expectContentSize) { // for now we don't care, contains the uncompressed size byte[] contentSize = new byte[8]; throw new IOException("Premature end of stream while reading content size"); contentHash.update(contentSize, 0, contentSize.length);
/** {@inheritDoc} */ @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (endReached) { return -1; } int r = readOnce(b, off, len); if (r == -1) { nextBlock(); if (!endReached) { r = readOnce(b, off, len); } } if (r != -1) { if (expectBlockDependency) { appendToBlockDependencyBuffer(b, off, r); } if (expectContentChecksum) { contentHash.update(b, off, r); } } return r; }