DixShtix

com.dixshtix.riff
Class InStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.dixshtix.riff.InStream

public class InStream
extends java.io.InputStream

InputStream with pushback facilities for implementing read of nested chunks.


Field Summary
private  java.io.InputStream in
          Wrapped InputStream.
private  boolean isLittleEndian
          A Mark for forms with bit-reversal.
private  java.util.Stack stack
          Stack for pushing read container Chunks.
 
Fields inherited from class java.io.InputStream
SKIP_BUFFER_SIZE, skipBuffer
 
Constructor Summary
InStream(java.io.InputStream inpStr)
          Constructor which wraps an InputStream.
 
Method Summary
 int available()
          Under construction.
 void chunkAscend(IOChunk c)
          After all chunk data has been read, this will close and pop the chunk.
 IOChunk chunkDescend()
          Read a chunk header and push on stack.
 IOChunk chunkDescend(FourByteConstant fcc)
          Given a four-byte-constant, complete reading of the chunk header and push on stack.
 boolean chunkEnd()
          Detect end of current chunk.
 void close()
          Close input file.
 void fsf(long bytes)
          Forwards-space (mark off) bytes read on all open chunks.
 boolean isContainerType(FourByteConstant fcc)
          Utility to interpret a FourByteConstant.
 boolean isEmpty()
          Test if this is outside the Form chunk.
 void mark(int readlimit)
          Under construction.
 boolean markSupported()
          Under construction.
 IOChunk peek()
          Return the currently open chunk.
 IOChunk pop()
          Pop a chunk off the stack.
 void push(IOChunk chunk)
          Push a chunk onto the stack.
 int read()
          Read a single byte.
 int read(byte[] b)
          Fill a pre-allocated buffer with read bytes.
 int read(byte[] b, int off, int len)
          Read a few bytes.
 char readChar()
          Read two bytes as a binary number.
 FourByteConstant readFourByteConstant()
          Utility to read four bytes.
 FourByteConstant readFourByteConstant(byte[] buf4)
          Utility to read four bytes, using preallocated buffer.
 int readInt()
          Read four bytes as a binary number.
 long readLong()
          Read eight bytes as a binary number.
 void reset()
          Rewind.
 long skip(long n)
          Skip over data bytes.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

in

private java.io.InputStream in
Wrapped InputStream.

stack

private java.util.Stack stack
Stack for pushing read container Chunks.

isLittleEndian

private boolean isLittleEndian
A Mark for forms with bit-reversal.
Constructor Detail

InStream

public InStream(java.io.InputStream inpStr)
Constructor which wraps an InputStream.
Parameters:
inpStr - An InputStream positioned at the beginning of a form chunk.
Method Detail

isEmpty

public boolean isEmpty()
Test if this is outside the Form chunk.

peek

public IOChunk peek()
Return the currently open chunk.

pop

public IOChunk pop()
Pop a chunk off the stack. No side effects.

push

public void push(IOChunk chunk)
Push a chunk onto the stack. No side effects.

fsf

public void fsf(long bytes)
Forwards-space (mark off) bytes read on all open chunks.
Parameters:
bytes - The number bytes read.

available

public int available()
              throws java.io.IOException
Under construction.
Overrides:
available in class java.io.InputStream

close

public void close()
           throws java.io.IOException
Close input file. No side effects.
Overrides:
close in class java.io.InputStream

mark

public void mark(int readlimit)
Under construction.
Overrides:
mark in class java.io.InputStream

markSupported

public boolean markSupported()
Under construction.
Overrides:
markSupported in class java.io.InputStream

read

public int read()
         throws java.io.IOException
Read a single byte.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] b)
         throws java.io.IOException
Fill a pre-allocated buffer with read bytes.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read a few bytes.
Overrides:
read in class java.io.InputStream

readChar

public char readChar()
              throws java.io.IOException
Read two bytes as a binary number.

readInt

public int readInt()
            throws java.io.IOException
Read four bytes as a binary number.

readLong

public long readLong()
              throws java.io.IOException
Read eight bytes as a binary number.

reset

public void reset()
           throws java.io.IOException
Rewind.
Overrides:
reset in class java.io.InputStream

skip

public long skip(long n)
          throws java.io.IOException
Skip over data bytes.
Overrides:
skip in class java.io.InputStream

readFourByteConstant

public FourByteConstant readFourByteConstant()
                                      throws java.io.IOException
Utility to read four bytes.

readFourByteConstant

public FourByteConstant readFourByteConstant(byte[] buf4)
                                      throws java.io.IOException
Utility to read four bytes, using preallocated buffer.
Parameters:
buf4 - Allocation for four bytes.

chunkDescend

public IOChunk chunkDescend()
                     throws java.io.IOException
Read a chunk header and push on stack.

chunkDescend

public IOChunk chunkDescend(FourByteConstant fcc)
                     throws java.io.IOException
Given a four-byte-constant, complete reading of the chunk header and push on stack.
Parameters:
fcc - A recently read four-byte chunk id.

chunkEnd

public boolean chunkEnd()
Detect end of current chunk.

chunkAscend

public void chunkAscend(IOChunk c)
                 throws java.io.IOException
After all chunk data has been read, this will close and pop the chunk. For RIFF files, this routine is also responsible for advancing over any padding bytes.
Parameters:
c - The chunk to pop.

isContainerType

public boolean isContainerType(FourByteConstant fcc)
Utility to interpret a FourByteConstant.
Parameters:
fcc - A recently-read chunk type.
Returns:
true if this is a standard RIFF container chunk.

DixShtix