FreeHEP API
Version current

org.freehep.util.io
Class BitOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byorg.freehep.util.io.CompressableOutputStream
              extended byorg.freehep.util.io.BitOutputStream
All Implemented Interfaces:
FinishableOutputStream
Direct Known Subclasses:
ByteOrderOutputStream

public class BitOutputStream
extends CompressableOutputStream
implements FinishableOutputStream

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

Version:
$Id: BitOutputStream.java,v 1.10 2003/12/06 00:12:34 duns Exp $
Author:
Mark Donszelmann, Charles Loomis
Source Code:
BitOutputStream.java

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
BitOutputStream(OutputStream out)
           
 
Method Summary
 void byteAlign()
          A utility to force the next write to be byte-aligned.
 void close()
           
 void finish()
           
protected  void flushByte()
          A utility method to flush the next byte
static int minBits(float number)
          calculates the minumum number of bits necessary to write number.
static int minBits(long number)
           
static int minBits(long number, boolean signed)
           
 void write(int b)
           
 void writeBitFlag(boolean bit)
          Write a bit to the output stream.
 void writeFBits(float value, int n)
          Write a float value of n-bits to the stream.
 void writeSBits(long value, int n)
          Write a signed value of n-bits to the output stream.
 void writeUBits(long value, int n)
          Write an unsigned value of n-bits to the output stream.
 
Methods inherited from class org.freehep.util.io.CompressableOutputStream
startCompressing, write
 
Methods inherited from class java.io.FilterOutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitOutputStream

public BitOutputStream(OutputStream out)
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class CompressableOutputStream
Throws:
IOException

finish

public void finish()
            throws IOException
Specified by:
finish in interface FinishableOutputStream
Overrides:
finish in class CompressableOutputStream
Throws:
IOException

close

public void close()
           throws IOException
Overrides:
close in class CompressableOutputStream
Throws:
IOException

flushByte

protected void flushByte()
                  throws IOException
A utility method to flush the next byte

Throws:
IOException

byteAlign

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

Throws:
IOException

writeBitFlag

public void writeBitFlag(boolean bit)
                  throws IOException
Write a bit to the output stream. A 1-bit is true; a 0-bit is false.

Throws:
IOException

writeSBits

public void writeSBits(long value,
                       int n)
                throws IOException
Write a signed value of n-bits to the output stream.

Throws:
IOException

writeFBits

public void writeFBits(float value,
                       int n)
                throws IOException
Write a float value of n-bits to the stream.

Throws:
IOException

writeUBits

public void writeUBits(long value,
                       int n)
                throws IOException
Write an unsigned value of n-bits to the output stream.

Throws:
IOException

minBits

public static int minBits(float number)
calculates the minumum number of bits necessary to write number.

Parameters:
number - number
Returns:
minimum number of bits to store number

minBits

public static int minBits(long number)

minBits

public static int minBits(long number,
                          boolean signed)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.