private void readSizes() throws IOException { int nextBlock = readOneByte(); if (nextBlock == -1) { throw new IOException("Premature end of stream while looking for next block"); } nextBackReferenceSize = nextBlock & BACK_REFERENCE_SIZE_MASK; long literalSizePart = (nextBlock & LITERAL_SIZE_MASK) >> SIZE_BITS; if (literalSizePart == BACK_REFERENCE_SIZE_MASK) { literalSizePart += readSizeBytes(); } startLiteral(literalSizePart); state = State.IN_LITERAL; }
/** * @return false if there is no more back-reference - this means this is the * last block of the stream. */ private boolean initializeBackReference() throws IOException { int backReferenceOffset = 0; try { backReferenceOffset = (int) ByteUtils.fromLittleEndian(supplier, 2); } catch (IOException ex) { if (nextBackReferenceSize == 0) { // the last block has no back-reference return false; } throw ex; } long backReferenceSize = nextBackReferenceSize; if (nextBackReferenceSize == BACK_REFERENCE_SIZE_MASK) { backReferenceSize += readSizeBytes(); } // minimal match length 4 is encoded as 0 startBackReference(backReferenceOffset, backReferenceSize + 4); state = State.IN_BACK_REFERENCE; return true; }
private void readSizes() throws IOException { int nextBlock = readOneByte(); if (nextBlock == -1) { throw new IOException("Premature end of stream while looking for next block"); } nextBackReferenceSize = nextBlock & BACK_REFERENCE_SIZE_MASK; long literalSizePart = (nextBlock & LITERAL_SIZE_MASK) >> SIZE_BITS; if (literalSizePart == BACK_REFERENCE_SIZE_MASK) { literalSizePart += readSizeBytes(); } startLiteral(literalSizePart); state = State.IN_LITERAL; }
/** * @return false if there is no more back-reference - this means this is the * last block of the stream. */ private boolean initializeBackReference() throws IOException { int backReferenceOffset = 0; try { backReferenceOffset = (int) ByteUtils.fromLittleEndian(supplier, 2); } catch (IOException ex) { if (nextBackReferenceSize == 0) { // the last block has no back-reference return false; } throw ex; } long backReferenceSize = nextBackReferenceSize; if (nextBackReferenceSize == BACK_REFERENCE_SIZE_MASK) { backReferenceSize += readSizeBytes(); } // minimal match length 4 is encoded as 0 startBackReference(backReferenceOffset, backReferenceSize + 4); state = State.IN_BACK_REFERENCE; return true; }