org.tukaani.xz.rangecoder.RangeDecoderFromStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-compress Show documentation
Show all versions of commons-compress Show documentation
This artifact contains the same classes as
${modularized.groupId}%${modularized.artifactId}%${modularized.version}
but also a module-info.class
/*
* RangeDecoderFromStream
*
* Authors: Lasse Collin
* Igor Pavlov
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/
package org.tukaani.xz.rangecoder;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.IOException;
import org.tukaani.xz.CorruptedInputException;
public final class RangeDecoderFromStream extends RangeDecoder {
private final DataInputStream inData;
public RangeDecoderFromStream(InputStream in) throws IOException {
inData = new DataInputStream(in);
if (inData.readUnsignedByte() != 0x00)
throw new CorruptedInputException();
code = inData.readInt();
range = 0xFFFFFFFF;
}
public boolean isFinished() {
return code == 0;
}
public void normalize() throws IOException {
if ((range & TOP_MASK) == 0) {
code = (code << SHIFT_BITS) | inData.readUnsignedByte();
range <<= SHIFT_BITS;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy