FreeHEP API
Version v1.1

org.freehep.util.io
Class BitInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.freehep.util.io.BitInputStream
Direct Known Subclasses:
ByteOrderInputStream

public class BitInputStream
extends InputStream

Class to read bits from a Stream, allowing for byte synchronization. Signed, Unsigned, Booleans and Floats can be read.

Version:
$Id: BitInputStream.java,v 1.6 2002/09/04 22:00:00 duns Exp $
Author:
Mark Donszelmann, Charles Loomis

Field Summary
protected static int[] BIT_MASK
           
protected static int[] FIELD_MASK
           
protected  InputStream in
           
protected static int MASK_SIZE
           
protected static int ONES
           
protected static int ZERO
           
 
Constructor Summary
BitInputStream(InputStream in)
           
 
Method Summary
 void byteAlign()
          A utility to force the next read to be byte-aligned.
protected  void fetchByte()
          A utility method to fetch the next byte in preparation for constructing a bit field.
 int read()
           
 boolean readBitFlag()
          Read a bit from the input stream and interpret this as a boolean value.
 float readFBits(int n)
          Read a float value of n-bits from the stream.
 long readSBits(int n)
          Read a signed value of n-bits from the input stream.
 long readUBits(int n)
          Read an unsigned value of n-bits from the input stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASK_SIZE

protected static final int MASK_SIZE
See Also:
Constant Field Values

ZERO

protected static final int ZERO
See Also:
Constant Field Values

ONES

protected static final int ONES
See Also:
Constant Field Values

BIT_MASK

protected static final int[] BIT_MASK

FIELD_MASK

protected static final int[] FIELD_MASK

in

protected InputStream in
Constructor Detail

BitInputStream

public BitInputStream(InputStream in)
Method Detail

read

public int read()
         throws IOException
Specified by:
read in class InputStream
IOException

fetchByte

protected void fetchByte()
                  throws IOException
A utility method to fetch the next byte in preparation for constructing a bit field. There is no protection for this method; ensure that it is only called when a byte must be fetched.

IOException

byteAlign

public void byteAlign()
A utility to force the next read to be byte-aligned.


readBitFlag

public boolean readBitFlag()
                    throws IOException
Read a bit from the input stream and interpret this as a boolean value. A 1-bit is true; a 0-bit is false.

IOException

readSBits

public long readSBits(int n)
               throws IOException
Read a signed value of n-bits from the input stream.

IOException

readFBits

public float readFBits(int n)
                throws IOException
Read a float value of n-bits from the stream.

IOException

readUBits

public long readUBits(int n)
               throws IOException
Read an unsigned value of n-bits from the input stream.

IOException

FreeHEP API
Version v1.1

Copyright © 2000-2002 FreeHEP, All Rights Reserved.