source: josm/trunk/src/org/tukaani/xz/rangecoder/RangeDecoderFromStream.java@ 13350

Last change on this file since 13350 was 13350, checked in by stoecker, 6 years ago

see #15816 - add XZ support

File size: 1.0 KB
Line 
1/*
2 * RangeDecoderFromStream
3 *
4 * Authors: Lasse Collin <lasse.collin@tukaani.org>
5 * Igor Pavlov <http://7-zip.org/>
6 *
7 * This file has been put into the public domain.
8 * You can do whatever you want with this file.
9 */
10
11package org.tukaani.xz.rangecoder;
12
13import java.io.InputStream;
14import java.io.DataInputStream;
15import java.io.IOException;
16import org.tukaani.xz.CorruptedInputException;
17
18public final class RangeDecoderFromStream extends RangeDecoder {
19 private final DataInputStream inData;
20
21 public RangeDecoderFromStream(InputStream in) throws IOException {
22 inData = new DataInputStream(in);
23
24 if (inData.readUnsignedByte() != 0x00)
25 throw new CorruptedInputException();
26
27 code = inData.readInt();
28 range = 0xFFFFFFFF;
29 }
30
31 public boolean isFinished() {
32 return code == 0;
33 }
34
35 public void normalize() throws IOException {
36 if ((range & TOP_MASK) == 0) {
37 code = (code << SHIFT_BITS) | inData.readUnsignedByte();
38 range <<= SHIFT_BITS;
39 }
40 }
41}
Note: See TracBrowser for help on using the repository browser.