DixShtix

com.dixshtix.riff
Class OutStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.dixshtix.riff.OutStream
Direct Known Subclasses:
NOutputStream

public class OutStream
extends java.io.OutputStream

Stack-based output for creation of RIFF file streams.


Field Summary
private  boolean isLittleEndian
          A marker which is true if we are writing INTEL-order binary data.
private  java.io.OutputStream out
          The wrapped OutputStream.
private  java.util.Stack stack
          The stack of open chunks.
 
Constructor Summary
OutStream(java.io.OutputStream o)
          Create a wrapper about an OutputStream.
 
Method Summary
 void close()
          Close output stream.
static byte[] cvt(boolean isLittleEndian, char data)
          Create a formated array of two bytes representing a Java long.
static byte[] cvt(boolean isLittleEndian, int data)
          Create a formated array of four bytes representing a Java long.
static byte[] cvt(boolean isLittleEndian, long data)
          Create a formated array of eight bytes representing a Java long.
 byte[] cvt(char data)
          Format for output two bytes of binary numerical output.
 byte[] cvt(int data)
          Format for output four bytes of binary numerical output.
 byte[] cvt(long data)
          Format for output eight bytes of binary numerical output.
 void flush()
          Flush output to the stream.
 boolean isEmpty()
          Test if no more chunks are left on stack.
 IOChunk peek()
          List chunk on top of stack.
 IOChunk pop()
          Pop a chunk, and write content to parent chunk or the final output.
 void push(IOChunk chunk)
          Push chunk on stack.
 void write(byte[] b)
          Write an array of bytes.
 void write(byte[] b, int off, int len)
          Write a portion of an array of bytes.
 void write(FourByteConstant fcc)
          Write a four-byte constant as used in RIFF files.
 void write(int b_y_t_e)
          Write a single byte.
 void write(java.lang.String s)
          Write a UTF-encoded string.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

out

private java.io.OutputStream out
The wrapped OutputStream.

stack

private java.util.Stack stack
The stack of open chunks.

isLittleEndian

private boolean isLittleEndian
A marker which is true if we are writing INTEL-order binary data.
Constructor Detail

OutStream

public OutStream(java.io.OutputStream o)
Create a wrapper about an OutputStream.
Method Detail

isEmpty

public boolean isEmpty()
Test if no more chunks are left on stack.

peek

public IOChunk peek()
List chunk on top of stack.

pop

public IOChunk pop()
            throws java.io.IOException
Pop a chunk, and write content to parent chunk or the final output.

push

public void push(IOChunk chunk)
Push chunk on stack. May set the isLittleEndian flag.

close

public void close()
           throws java.io.IOException
Close output stream. May be enhanced in future.
Overrides:
close in class java.io.OutputStream

flush

public void flush()
           throws java.io.IOException
Flush output to the stream.
Overrides:
flush in class java.io.OutputStream

write

public void write(int b_y_t_e)
           throws java.io.IOException
Write a single byte.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of an array of bytes.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b)
           throws java.io.IOException
Write an array of bytes.
Overrides:
write in class java.io.OutputStream

write

public void write(java.lang.String s)
           throws java.io.IOException
Write a UTF-encoded string. This is ASCII if the string is composed of ASCII characters.

write

public void write(FourByteConstant fcc)
           throws java.io.IOException
Write a four-byte constant as used in RIFF files.

cvt

public static byte[] cvt(boolean isLittleEndian,
                         char data)
Create a formated array of two bytes representing a Java long.

cvt

public static byte[] cvt(boolean isLittleEndian,
                         int data)
Create a formated array of four bytes representing a Java long.

cvt

public static byte[] cvt(boolean isLittleEndian,
                         long data)
Create a formated array of eight bytes representing a Java long.

cvt

public byte[] cvt(char data)
Format for output two bytes of binary numerical output.

cvt

public byte[] cvt(int data)
Format for output four bytes of binary numerical output.

cvt

public byte[] cvt(long data)
Format for output eight bytes of binary numerical output.

DixShtix