Class DebugDataOutputStream

All Implemented Interfaces:
com.oracle.coherence.common.io.OutputStreaming, OutputStreaming, Closeable, DataOutput, Flushable, AutoCloseable

public class DebugDataOutputStream extends FilterOutputStream implements DataOutput, OutputStreaming
This is an imitation DataOutputStream class that logs the output in a human-readable format for debugging purposes. All output will be
Author:
cp 2004.08.06
  • Field Summary

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a DebugDataOutputStream that will output to the specified Stream object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this OutputStream and releases any associated system resources.
    void
    Flushes this OutputStream and forces any buffered output bytes to be written.
    static void
    main(String[] asArg)
    Command line test.
    protected void
    Print the passed String to the underlying stream.
    void
    write(byte[] ab)
    Writes all the bytes in the array ab.
    void
    write(byte[] ab, int of, int cb)
    Writes cb bytes starting at offset of from the array ab.
    void
    write(int b)
    Writes the eight low-order bits of the argument b.
    void
    writeBoolean(boolean f)
    Writes the boolean value f.
    void
    writeByte(int b)
    Writes the eight low-order bits of the argument b.
    void
    Writes the String s, but only the low-order byte from each character of the String is written.
    void
    writeChar(int ch)
    Writes a char value, comprised of the 16 low-order bits of the argument ch; the 16 high-order bits of ch are ignored.
    void
    Writes the String s as a sequence of characters.
    void
    writeDouble(double dfl)
    Writes a double value.
    void
    writeFloat(float fl)
    Writes a float value.
    void
    writeInt(int n)
    Writes an int value.
    void
    writeLong(long l)
    Writes a long value.
    void
    writeShort(int n)
    Writes a short value, comprised of the 16 low-order bits of the argument n; the 16 high-order bits of n are ignored.
    void
    Writes the String s as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the corresponding DataInput.readUTF() method can reconstitute a String from the written data.

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DebugDataOutputStream

      public DebugDataOutputStream(OutputStream stream)
      Construct a DebugDataOutputStream that will output to the specified Stream object.
      Parameters:
      stream - an OutputStream to write to
  • Method Details

    • write

      public void write(int b) throws IOException
      Writes the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
      Specified by:
      write in interface DataOutput
      Specified by:
      write in interface com.oracle.coherence.common.io.OutputStreaming
      Overrides:
      write in class FilterOutputStream
      Parameters:
      b - the byte to write (passed as an integer)
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(byte[] ab) throws IOException
      Writes all the bytes in the array ab.
      Specified by:
      write in interface DataOutput
      Specified by:
      write in interface com.oracle.coherence.common.io.OutputStreaming
      Overrides:
      write in class FilterOutputStream
      Parameters:
      ab - the byte array to write
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if ab is null
    • write

      public void write(byte[] ab, int of, int cb) throws IOException
      Writes cb bytes starting at offset of from the array ab.
      Specified by:
      write in interface DataOutput
      Specified by:
      write in interface com.oracle.coherence.common.io.OutputStreaming
      Overrides:
      write in class FilterOutputStream
      Parameters:
      ab - the byte array to write from
      of - the offset into ab to start writing from
      cb - the number of bytes from ab to write
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if ab is null
      IndexOutOfBoundsException - if of is negative, or cb is negative, or of+cb is greater than ab.length
    • writeBoolean

      public void writeBoolean(boolean f) throws IOException
      Writes the boolean value f.
      Specified by:
      writeBoolean in interface DataOutput
      Parameters:
      f - the boolean to be written
      Throws:
      IOException - if an I/O error occurs
    • writeByte

      public void writeByte(int b) throws IOException
      Writes the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
      Specified by:
      writeByte in interface DataOutput
      Parameters:
      b - the byte to write (passed as an integer)
      Throws:
      IOException - if an I/O error occurs
    • writeShort

      public void writeShort(int n) throws IOException
      Writes a short value, comprised of the 16 low-order bits of the argument n; the 16 high-order bits of n are ignored.
      Specified by:
      writeShort in interface DataOutput
      Parameters:
      n - the short to write (passed as an integer)
      Throws:
      IOException - if an I/O error occurs
    • writeChar

      public void writeChar(int ch) throws IOException
      Writes a char value, comprised of the 16 low-order bits of the argument ch; the 16 high-order bits of ch are ignored.
      Specified by:
      writeChar in interface DataOutput
      Parameters:
      ch - the char to write (passed as an integer)
      Throws:
      IOException - if an I/O error occurs
    • writeInt

      public void writeInt(int n) throws IOException
      Writes an int value.
      Specified by:
      writeInt in interface DataOutput
      Parameters:
      n - the int to write
      Throws:
      IOException - if an I/O error occurs
    • writeLong

      public void writeLong(long l) throws IOException
      Writes a long value.
      Specified by:
      writeLong in interface DataOutput
      Parameters:
      l - the long to write
      Throws:
      IOException - if an I/O error occurs
    • writeFloat

      public void writeFloat(float fl) throws IOException
      Writes a float value.
      Specified by:
      writeFloat in interface DataOutput
      Parameters:
      fl - the float to write
      Throws:
      IOException - if an I/O error occurs
    • writeDouble

      public void writeDouble(double dfl) throws IOException
      Writes a double value.
      Specified by:
      writeDouble in interface DataOutput
      Parameters:
      dfl - the double to write
      Throws:
      IOException - if an I/O error occurs
    • writeBytes

      public void writeBytes(String s) throws IOException
      Writes the String s, but only the low-order byte from each character of the String is written.
      Specified by:
      writeBytes in interface DataOutput
      Parameters:
      s - the String to write
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if s is null
    • writeChars

      public void writeChars(String s) throws IOException
      Writes the String s as a sequence of characters.
      Specified by:
      writeChars in interface DataOutput
      Parameters:
      s - the String to write
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if s is null
    • writeUTF

      public void writeUTF(String s) throws IOException
      Writes the String s as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the corresponding DataInput.readUTF() method can reconstitute a String from the written data.
      Specified by:
      writeUTF in interface DataOutput
      Parameters:
      s - the String to write
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if s is null
    • flush

      public void flush() throws IOException
      Flushes this OutputStream and forces any buffered output bytes to be written.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface com.oracle.coherence.common.io.OutputStreaming
      Overrides:
      flush in class FilterOutputStream
      Throws:
      IOException - if an I/O error occurs
    • close

      public void close() throws IOException
      Closes this OutputStream and releases any associated system resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface com.oracle.coherence.common.io.OutputStreaming
      Overrides:
      close in class FilterOutputStream
      Throws:
      IOException - if an I/O error occurs
    • println

      protected void println(String s) throws IOException
      Print the passed String to the underlying stream.
      Parameters:
      s - the String to print
      Throws:
      IOException
    • main

      public static void main(String[] asArg) throws Exception
      Command line test.
      Throws:
      Exception