org.apache.sanselan.common
Class BinaryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.sanselan.common.BinaryInputStream
All Implemented Interfaces:
java.io.Closeable, BinaryConstants

public class BinaryInputStream
extends java.io.InputStream
implements BinaryConstants


Field Summary
protected  boolean debug
           
 
Fields inherited from interface org.apache.sanselan.common.BinaryConstants
BYTE_ORDER_BIG_ENDIAN, BYTE_ORDER_INTEL, BYTE_ORDER_LEAST_SIGNIFICANT_BYTE, BYTE_ORDER_LITTLE_ENDIAN, BYTE_ORDER_LSB, BYTE_ORDER_MOST_SIGNIFICANT_BYTE, BYTE_ORDER_MOTOROLA, BYTE_ORDER_MSB, BYTE_ORDER_NETWORK
 
Constructor Summary
BinaryInputStream(byte[] bytes, int byteOrder)
           
BinaryInputStream(java.io.InputStream is)
           
BinaryInputStream(java.io.InputStream is, int byteOrder)
           
 
Method Summary
protected static int CharsToQuad(char c1, char c2, char c3, char c4)
           
 boolean compareByteArrays(byte[] a, int aStart, byte[] b, int bStart, int length)
           
protected  int convertByteArrayToInt(java.lang.String name, byte[] bytes)
           
protected  int convertByteArrayToInt(java.lang.String name, byte[] bytes, int byteOrder)
           
protected  int convertByteArrayToInt(java.lang.String name, byte[] bytes, int start, int length, int byteOrder)
           
protected  int[] convertByteArrayToIntArray(java.lang.String name, byte[] bytes, int start, int length, int byteOrder)
           
protected  RationalNumber convertByteArrayToRational(java.lang.String name, byte[] bytes, int byteOrder)
           
protected  RationalNumber convertByteArrayToRational(java.lang.String name, byte[] bytes, int start, int byteOrder)
           
protected  RationalNumber[] convertByteArrayToRationalArray(java.lang.String name, byte[] bytes, int start, int length, int byteOrder)
           
 int convertByteArrayToShort(java.lang.String name, byte[] bytes)
           
protected  int convertByteArrayToShort(java.lang.String name, byte[] bytes, int byteOrder)
           
 int convertByteArrayToShort(java.lang.String name, int start, byte[] bytes)
           
protected  int convertByteArrayToShort(java.lang.String name, int start, byte[] bytes, int byteOrder)
           
protected  int[] convertByteArrayToShortArray(java.lang.String name, byte[] bytes, int start, int length, int byteOrder)
           
protected  void debugByteArray(java.lang.String name, byte[] bytes)
           
 void debugNumber(java.lang.String msg, int data)
           
 void debugNumber(java.lang.String msg, int data, int bytes)
           
protected  void debugNumberArray(java.lang.String name, int[] numbers, int length)
           
 int findNull(byte[] src)
           
 int findNull(byte[] src, int start)
           
protected  byte[] getBytearrayHead(java.lang.String name, byte[] bytes, int count)
           
protected  byte[] getBytearrayTail(java.lang.String name, byte[] bytes, int count)
           
protected  int getByteOrder()
           
 boolean getDebug()
           
protected  byte[] getRAFBytes(java.io.RandomAccessFile raf, long pos, int length, java.lang.String exception)
           
protected  void printByteBits(java.lang.String msg, byte i)
           
protected  void printCharQuad(java.lang.String msg, int i)
           
 int read()
           
 int read1ByteInteger(java.lang.String exception)
           
 int read2ByteInteger(java.lang.String exception)
           
 int read2Bytes(java.lang.String name, java.lang.String exception)
           
protected  int read2Bytes(java.lang.String name, java.lang.String exception, int byteOrder)
           
 int read3Bytes(java.lang.String name, java.lang.String exception)
           
protected  int read3Bytes(java.lang.String name, java.lang.String exception, int byteOrder)
           
 int read4ByteInteger(java.lang.String exception)
           
 int read4Bytes(java.lang.String name, java.lang.String exception)
           
protected  int read4Bytes(java.lang.String name, java.lang.String exception, int byteOrder)
           
 void readAndVerifyBytes(byte[] expected, java.lang.String exception)
           
protected  void readAndVerifyBytes(java.lang.String name, byte[] expected, java.lang.String exception)
           
 byte readByte(java.lang.String name, java.lang.String exception)
           
 byte[] readByteArray(int length, java.lang.String error)
           
 byte[] readByteArray(int length, java.lang.String error, boolean verbose, boolean strict)
           
 byte[] readBytearray(java.lang.String name, byte[] bytes, int start, int count)
           
 byte[] readByteArray(java.lang.String name, int length, java.lang.String exception)
           
protected  void readRandomBytes()
           
protected  void scanForByte(byte value)
           
protected  void setByteOrder(int byteOrder)
           
protected  void setByteOrder(int a, int b)
           
 void setDebug(boolean b)
           
protected  void skipBytes(int length)
           
 void skipBytes(int length, java.lang.String exception)
           
 
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

debug

protected boolean debug
Constructor Detail

BinaryInputStream

public BinaryInputStream(byte[] bytes,
                         int byteOrder)

BinaryInputStream

public BinaryInputStream(java.io.InputStream is,
                         int byteOrder)

BinaryInputStream

public BinaryInputStream(java.io.InputStream is)
Method Detail

setDebug

public final void setDebug(boolean b)

getDebug

public final boolean getDebug()

setByteOrder

protected void setByteOrder(int a,
                            int b)
                     throws ImageReadException,
                            java.io.IOException
Throws:
ImageReadException
java.io.IOException

setByteOrder

protected void setByteOrder(int byteOrder)

getByteOrder

protected int getByteOrder()

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

convertByteArrayToInt

protected final int convertByteArrayToInt(java.lang.String name,
                                          byte[] bytes)

convertByteArrayToShort

public final int convertByteArrayToShort(java.lang.String name,
                                         byte[] bytes)

convertByteArrayToShort

public final int convertByteArrayToShort(java.lang.String name,
                                         int start,
                                         byte[] bytes)

read4Bytes

public final int read4Bytes(java.lang.String name,
                            java.lang.String exception)
                     throws ImageReadException,
                            java.io.IOException
Throws:
ImageReadException
java.io.IOException

read3Bytes

public final int read3Bytes(java.lang.String name,
                            java.lang.String exception)
                     throws ImageReadException,
                            java.io.IOException
Throws:
ImageReadException
java.io.IOException

read2Bytes

public final int read2Bytes(java.lang.String name,
                            java.lang.String exception)
                     throws ImageReadException,
                            java.io.IOException
Throws:
ImageReadException
java.io.IOException

readRandomBytes

protected final void readRandomBytes()
                              throws ImageReadException,
                                     java.io.IOException
Throws:
ImageReadException
java.io.IOException

debugNumber

public final void debugNumber(java.lang.String msg,
                              int data)

debugNumber

public final void debugNumber(java.lang.String msg,
                              int data,
                              int bytes)

readAndVerifyBytes

public final void readAndVerifyBytes(byte[] expected,
                                     java.lang.String exception)
                              throws ImageReadException,
                                     java.io.IOException
Throws:
ImageReadException
java.io.IOException

readAndVerifyBytes

protected final void readAndVerifyBytes(java.lang.String name,
                                        byte[] expected,
                                        java.lang.String exception)
                                 throws ImageReadException,
                                        java.io.IOException
Throws:
ImageReadException
java.io.IOException

skipBytes

public final void skipBytes(int length,
                            java.lang.String exception)
                     throws java.io.IOException
Throws:
java.io.IOException

scanForByte

protected final void scanForByte(byte value)
                          throws java.io.IOException
Throws:
java.io.IOException

readByte

public final byte readByte(java.lang.String name,
                           java.lang.String exception)
                    throws java.io.IOException
Throws:
java.io.IOException

convertByteArrayToRationalArray

protected final RationalNumber[] convertByteArrayToRationalArray(java.lang.String name,
                                                                 byte[] bytes,
                                                                 int start,
                                                                 int length,
                                                                 int byteOrder)

convertByteArrayToRational

protected final RationalNumber convertByteArrayToRational(java.lang.String name,
                                                          byte[] bytes,
                                                          int byteOrder)

convertByteArrayToRational

protected final RationalNumber convertByteArrayToRational(java.lang.String name,
                                                          byte[] bytes,
                                                          int start,
                                                          int byteOrder)

convertByteArrayToInt

protected final int convertByteArrayToInt(java.lang.String name,
                                          byte[] bytes,
                                          int byteOrder)

convertByteArrayToInt

protected final int convertByteArrayToInt(java.lang.String name,
                                          byte[] bytes,
                                          int start,
                                          int length,
                                          int byteOrder)

convertByteArrayToIntArray

protected final int[] convertByteArrayToIntArray(java.lang.String name,
                                                 byte[] bytes,
                                                 int start,
                                                 int length,
                                                 int byteOrder)

convertByteArrayToShort

protected final int convertByteArrayToShort(java.lang.String name,
                                            byte[] bytes,
                                            int byteOrder)

convertByteArrayToShort

protected final int convertByteArrayToShort(java.lang.String name,
                                            int start,
                                            byte[] bytes,
                                            int byteOrder)

convertByteArrayToShortArray

protected final int[] convertByteArrayToShortArray(java.lang.String name,
                                                   byte[] bytes,
                                                   int start,
                                                   int length,
                                                   int byteOrder)

readByteArray

public final byte[] readByteArray(java.lang.String name,
                                  int length,
                                  java.lang.String exception)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

debugByteArray

protected final void debugByteArray(java.lang.String name,
                                    byte[] bytes)

debugNumberArray

protected final void debugNumberArray(java.lang.String name,
                                      int[] numbers,
                                      int length)

readBytearray

public final byte[] readBytearray(java.lang.String name,
                                  byte[] bytes,
                                  int start,
                                  int count)

readByteArray

public final byte[] readByteArray(int length,
                                  java.lang.String error)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

readByteArray

public final byte[] readByteArray(int length,
                                  java.lang.String error,
                                  boolean verbose,
                                  boolean strict)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

getBytearrayTail

protected final byte[] getBytearrayTail(java.lang.String name,
                                        byte[] bytes,
                                        int count)

getBytearrayHead

protected final byte[] getBytearrayHead(java.lang.String name,
                                        byte[] bytes,
                                        int count)

compareByteArrays

public final boolean compareByteArrays(byte[] a,
                                       int aStart,
                                       byte[] b,
                                       int bStart,
                                       int length)

read4Bytes

protected final int read4Bytes(java.lang.String name,
                               java.lang.String exception,
                               int byteOrder)
                        throws ImageReadException,
                               java.io.IOException
Throws:
ImageReadException
java.io.IOException

read3Bytes

protected final int read3Bytes(java.lang.String name,
                               java.lang.String exception,
                               int byteOrder)
                        throws ImageReadException,
                               java.io.IOException
Throws:
ImageReadException
java.io.IOException

read2Bytes

protected final int read2Bytes(java.lang.String name,
                               java.lang.String exception,
                               int byteOrder)
                        throws ImageReadException,
                               java.io.IOException
Throws:
ImageReadException
java.io.IOException

read1ByteInteger

public final int read1ByteInteger(java.lang.String exception)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

read2ByteInteger

public final int read2ByteInteger(java.lang.String exception)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

read4ByteInteger

public final int read4ByteInteger(java.lang.String exception)
                           throws ImageReadException,
                                  java.io.IOException
Throws:
ImageReadException
java.io.IOException

printCharQuad

protected final void printCharQuad(java.lang.String msg,
                                   int i)

printByteBits

protected final void printByteBits(java.lang.String msg,
                                   byte i)

CharsToQuad

protected static final int CharsToQuad(char c1,
                                       char c2,
                                       char c3,
                                       char c4)

findNull

public final int findNull(byte[] src)

findNull

public final int findNull(byte[] src,
                          int start)

getRAFBytes

protected final byte[] getRAFBytes(java.io.RandomAccessFile raf,
                                   long pos,
                                   int length,
                                   java.lang.String exception)
                            throws java.io.IOException
Throws:
java.io.IOException

skipBytes

protected void skipBytes(int length)
                  throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2007-2009. All Rights Reserved.