nom.tam.util
Class BufferedDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by nom.tam.util.BufferedDataInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class BufferedDataInputStream
extends java.io.BufferedInputStream
implements java.io.DataInput


Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
BufferedDataInputStream(java.io.InputStream o)
          Use the BufferedInputStream constructor
BufferedDataInputStream(java.io.InputStream o, int bufLength)
          Use the BufferedInputStream constructor
 
Method Summary
static void main(java.lang.String[] args)
          This method is used to test and time the buffered data methods.
protected  int primitiveArrayRecurse(java.lang.Object o)
           
protected  void primitiveEOFThrower()
           
 void printStatus()
           
 int read()
           
 int read(byte[] buf, int offset, int len)
           
 boolean readBoolean()
          Read a boolean value
protected  int readBooleanArray(boolean[] b)
           
 byte readByte()
           
 char readChar()
           
protected  int readCharArray(char[] c)
           
 double readDouble()
           
protected  int readDoubleArray(double[] d)
           
 float readFloat()
           
protected  int readFloatArray(float[] f)
           
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
           
protected  int readIntArray(int[] i)
           
 java.lang.String readLine()
          Deprecated.  
 long readLong()
           
protected  int readLongArray(long[] l)
           
 int readPrimitiveArray(java.lang.Object o)
          This routine provides efficient reading of arrays of any primitive type.
 short readShort()
           
protected  int readShortArray(short[] s)
           
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 java.lang.String readUTF()
           
 long skip(long offset)
           
 int skipBytes(int toSkip)
           
 java.lang.String toString()
           
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferedDataInputStream

public BufferedDataInputStream(java.io.InputStream o)
Use the BufferedInputStream constructor


BufferedDataInputStream

public BufferedDataInputStream(java.io.InputStream o,
                               int bufLength)
Use the BufferedInputStream constructor

Method Detail

read

public int read(byte[] buf,
                int offset,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.BufferedInputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.BufferedInputStream
Throws:
java.io.IOException

skip

public long skip(long offset)
          throws java.io.IOException
Overrides:
skip in class java.io.BufferedInputStream
Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Read a boolean value

Specified by:
readBoolean in interface java.io.DataInput
Parameters:
b - The value to be written. Externally true is represented as a byte of 1 and false as a byte value of 0.
Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException
Specified by:
readByte in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException
Specified by:
readUnsignedByte in interface java.io.DataInput
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Specified by:
readInt in interface java.io.DataInput
Throws:
java.io.IOException

readShort

public short readShort()
                throws java.io.IOException
Specified by:
readShort in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException
Specified by:
readUnsignedShort in interface java.io.DataInput
Throws:
java.io.IOException

readChar

public char readChar()
              throws java.io.IOException
Specified by:
readChar in interface java.io.DataInput
Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException
Specified by:
readLong in interface java.io.DataInput
Throws:
java.io.IOException

readFloat

public float readFloat()
                throws java.io.IOException
Specified by:
readFloat in interface java.io.DataInput
Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException
Specified by:
readDouble in interface java.io.DataInput
Throws:
java.io.IOException

readFully

public void readFully(byte[] b)
               throws java.io.IOException
Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

skipBytes

public int skipBytes(int toSkip)
              throws java.io.IOException
Specified by:
skipBytes in interface java.io.DataInput
Throws:
java.io.IOException

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException
Specified by:
readUTF in interface java.io.DataInput
Throws:
java.io.IOException

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Deprecated. 

This routine uses the deprecated DataInputStream.readLine() method. However, we really want to simulate the behavior of that method so that's what we used.

Specified by:
readLine in interface java.io.DataInput
Throws:
java.io.IOException

readPrimitiveArray

public int readPrimitiveArray(java.lang.Object o)
                       throws java.io.IOException
This routine provides efficient reading of arrays of any primitive type. It is an error to invoke this method with an object that is not an array of some primitive type. Note that there is no corresponding capability to writePrimitiveArray in BufferedDataOutputStream to read in an array of Strings.

Parameters:
o - The object to be read. It must be an array of a primitive type, or an array of Object's.
Throws:
java.io.IOException

primitiveArrayRecurse

protected int primitiveArrayRecurse(java.lang.Object o)
                             throws java.io.IOException
Throws:
java.io.IOException

readBooleanArray

protected int readBooleanArray(boolean[] b)
                        throws java.io.IOException
Throws:
java.io.IOException

readShortArray

protected int readShortArray(short[] s)
                      throws java.io.IOException
Throws:
java.io.IOException

readCharArray

protected int readCharArray(char[] c)
                     throws java.io.IOException
Throws:
java.io.IOException

readIntArray

protected int readIntArray(int[] i)
                    throws java.io.IOException
Throws:
java.io.IOException

readLongArray

protected int readLongArray(long[] l)
                     throws java.io.IOException
Throws:
java.io.IOException

readFloatArray

protected int readFloatArray(float[] f)
                      throws java.io.IOException
Throws:
java.io.IOException

readDoubleArray

protected int readDoubleArray(double[] d)
                       throws java.io.IOException
Throws:
java.io.IOException

primitiveEOFThrower

protected void primitiveEOFThrower()
                            throws java.io.EOFException
Throws:
java.io.EOFException

printStatus

public void printStatus()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
This method is used to test and time the buffered data methods. Note that the BufferedDataOutputStream.main simply calls this method which is used to test both classes in conjunction.

Throws:
java.lang.Exception