FreeHEP API
Version current

org.freehep.util.io
Class BitInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.freehep.util.io.DecompressableInputStream
          extended byorg.freehep.util.io.BitInputStream
Direct Known Subclasses:
ByteOrderInputStream

public class BitInputStream
extends DecompressableInputStream

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.7 2003/04/19 16:48:34 duns Exp $
Author:
Mark Donszelmann, Charles Loomis
Source Code:
BitInputStream.java

Field Summary
protected static int[] BIT_MASK
           
protected static int[] FIELD_MASK
           
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.
 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 org.freehep.util.io.DecompressableInputStream
read, skip, startDecompressing
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset
 
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
Constructor Detail

BitInputStream

public BitInputStream(InputStream in)
Method Detail

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.

Throws:
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.

Throws:
IOException

readSBits

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

Throws:
IOException

readFBits

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

Throws:
IOException

readUBits

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

Throws:
IOException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.