Class MC68000OutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.monte.media.iff.MC68000OutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class MC68000OutputStream extends FilterOutputStream
MC68000OutputStream.
Author:
Werner Randelshofer
  • Field Details

    • written

      protected long written
      The number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE.
  • Constructor Details

    • MC68000OutputStream

      public MC68000OutputStream(OutputStream out)
      Creates a new instance.
  • Method Details

    • writeLONG

      public void writeLONG(int v) throws IOException
      Throws:
      IOException
    • writeULONG

      public void writeULONG(long v) throws IOException
      Throws:
      IOException
    • writeWORD

      public void writeWORD(int v) throws IOException
      Throws:
      IOException
    • writeUWORD

      public void writeUWORD(int v) throws IOException
      Throws:
      IOException
    • writeUBYTE

      public void writeUBYTE(int v) throws IOException
      Throws:
      IOException
    • writeByteRun1

      public void writeByteRun1(byte[] data) throws IOException
      ByteRun1 Run Encoding.

      The run encoding scheme in byteRun1 is best described by pseudo code for the decoder Unpacker (called UnPackBits in the Macintosh toolbox):

       UnPacker:
          LOOP until produced the desired number of bytes
             Read the next source byte into n
             SELECT n FROM
                [ 0..127 ] ⇒ copy the next n+1 bytes literally
                [-1..-127] ⇒ replicate the next byte -n+1 timees
                -128       ⇒ no operation
             ENDCASE
          ENDLOOP
       
      Throws:
      IOException
    • writeByteRun1

      public void writeByteRun1(byte[] data, int offset, int length) throws IOException
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • writeType

      public void writeType(String s) throws IOException
      Writes an chunk type identifier (4 bytes).
      Parameters:
      s - A string with a length of 4 characters.
      Throws:
      IOException
    • size

      public final long size()
      Returns the current value of the counter written, the number of bytes written to this data output stream so far. If the counter overflows, it will be wrapped to Integer.MAX_VALUE.
      Returns:
      the value of the written field.
      See Also:
    • clearCount

      public void clearCount()
      Sets the value of the counter written to 0.
    • incCount

      protected void incCount(int value)
      Increases the written counter by the specified value until it reaches Long.MAX_VALUE.