ucar.nc2.iosp.bufr
Class BitReader

java.lang.Object
  extended by ucar.nc2.iosp.bufr.BitReader

public class BitReader
extends Object

Helper for reading data that has been bit packed.

Since:
Apr 7, 2008
Author:
caron

Constructor Summary
BitReader(RandomAccessFile raf, long startPos)
          Constructor
 
Method Summary
 long bits2UInt(int nb)
          Read the next nb bits and return an Unsigned Long .
 long getPos()
           
static void main(String[] args)
           
 void setBitOffset(int bitOffset)
          Position file at bitOffset from startPos
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitReader

public BitReader(RandomAccessFile raf,
                 long startPos)
          throws IOException
Constructor

Parameters:
raf - the RandomAccessFile
startPos - points to start of data in data section, in bytes
Throws:
IOException - on read error
Method Detail

setBitOffset

public void setBitOffset(int bitOffset)
                  throws IOException
Position file at bitOffset from startPos

Parameters:
bitOffset - bit offset from starting position
Throws:
IOException - on io error

bits2UInt

public long bits2UInt(int nb)
               throws IOException
Read the next nb bits and return an Unsigned Long .

Parameters:
nb - the number of bits to convert to int, must be <= 64.
Returns:
result
Throws:
IOException - on read error

getPos

public long getPos()
            throws IOException
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.