Websphere MQ Everyplace

examples.awt
Class AwtOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--examples.awt.AwtOutputStream
All Implemented Interfaces:
MQeClearable

public final class AwtOutputStream
extends java.io.FilterOutputStream
implements MQeClearable

A class which acts as an output stream and pushes anything it is passed into a java TextArea object.

The text area widget is passed by the caller of the constructor.

Lines longer than a set length are truncated.

When the maximum allowable amount of data has been collected , and put into the TextArea widget, then 66% of it is removed. In this manner, space is created for more recent trace information while retaining 33% of the recent history.

A filter string can be set into this object which will suppress output to the text area if the filter string does not exist in each line of output.


Field Summary
static short[] version
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
AwtOutputStream(java.awt.TextArea textArea)
          Constructor.
AwtOutputStream(java.awt.TextArea textArea, int maxLineLength, int maxHistoryChars)
          Constructor.
 
Method Summary
 void clear()
          From the MQeClearable interface.
protected  void dataOutput(java.lang.String data)
          Update the TextArea with the new message.
 java.lang.String filter(java.lang.String filter)
          Apply a filter to the output display (not applied to logfile).
protected  void finalize()
          Clean up before this object is garbage-collected.
 void flush()
          Required by the output stream interface.
protected  void format(java.lang.String data, int tabSize)
          Tormat tab, cr and lf characters if they are present.
protected  void output(java.lang.String data)
          Output the message data to display and/or to log (Filter permitting).
static java.lang.String replace(java.lang.String source, java.lang.String what, java.lang.String with)
          Replace one substring with another in a string.
 void saveAs(java.lang.String thisFile)
          Save the current Text area contents.
 void write(byte[] data)
          Write byte array.
 void write(byte[] data, int offset, int len)
          Write byte array.
 void write(int Data)
          Write character.
 
Methods inherited from class java.io.FilterOutputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static short[] version
Constructor Detail

AwtOutputStream

public AwtOutputStream(java.awt.TextArea textArea)
Constructor.

Parameters:
textArea - TextArea to which output passed to this output stream will be sent. Should not be null.

AwtOutputStream

public AwtOutputStream(java.awt.TextArea textArea,
                       int maxLineLength,
                       int maxHistoryChars)
Constructor.

Parameters:
textArea - TextArea to which output passed to this output stream will be sent. Should not be null.
maxLineLength - The max number of characters which are allowed per line of text. Lines longer than this are truncated to this length.
maxHistoryChars - The max number of characters which are held by the text area output stream. when full, 1/3rd of the data is thrown away, oldest data first.
Method Detail

dataOutput

protected void dataOutput(java.lang.String data)
Update the TextArea with the new message.

Parameters:
data - java.lang.String
Returns:
void

clear

public void clear()
From the MQeClearable interface. Clear all the output we have so far.

Specified by:
clear in interface MQeClearable

filter

public java.lang.String filter(java.lang.String filter)
Apply a filter to the output display (not applied to logfile).

Parameters:
filter - java.lang.String
Returns:
java.lang.String

finalize

protected void finalize()
Clean up before this object is garbage-collected.

Overrides:
finalize in class java.lang.Object

flush

public void flush()
Required by the output stream interface. This implementation does nothing.

Overrides:
flush in class java.io.FilterOutputStream

format

protected void format(java.lang.String data,
                      int tabSize)
Tormat tab, cr and lf characters if they are present. Pass the formatted data onto the output method.

Parameters:
data - The text to output.
tabSize - The number of spaces a tab should be substituted for.

replace

public static java.lang.String replace(java.lang.String source,
                                       java.lang.String what,
                                       java.lang.String with)
Replace one substring with another in a string.

Parameters:
source - String in which the sustring is to be replaced.
what - String that needs to be replaced
with - String to replace with
Returns:
java.lang.String

saveAs

public void saveAs(java.lang.String thisFile)
            throws java.lang.Exception
Save the current Text area contents.

Parameters:
thisFile - file name.
Returns:
void
Throws:
java.lang.Exception

output

protected void output(java.lang.String data)
Output the message data to display and/or to log (Filter permitting).

Parameters:
data - java.lang.String
Returns:
void

write

public void write(byte[] data,
                  int offset,
                  int len)
Write byte array.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
data - Data to be written in to the byte Array
offset - Offset from where the write should happen
len - The total number of bytes to be written
Returns:
void

write

public void write(byte[] data)
Write byte array.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
data - Data to be written in to the byte Array
Returns:
void

write

public void write(int Data)
Write character.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
Data - an integer
Returns:
void

Websphere MQ Everyplace