org.omegahat.Environment.IO
Class BasicObjectDisplay

java.lang.Object
  |
  +--org.omegahat.Environment.IO.BasicObjectDisplay
All Implemented Interfaces:
ObjectDisplayFilter
Direct Known Subclasses:
TruncatedObjectDisplay

public class BasicObjectDisplay
extends java.lang.Object
implements ObjectDisplayFilter

This class takes care of displaying different objects on a output stream in simple ascii text with no markup. This is suitable for output to the console. It knows about certain types (such as array, Vector, etc.) and delegates some control to the individual objects that implement SelfDisplaying. This can be extended to add markup for different output devices such as TeX and HTML.


Field Summary
static java.lang.String OutputElementSeparator
          The separator between the display of the different sub-elements of a container objects (e.g.
protected  java.io.PrintWriter stdout
           
 
Constructor Summary
BasicObjectDisplay()
          Default constructor that uses the standard output device from System.out as the output stream.
BasicObjectDisplay(java.io.PrintWriter out)
          Constructor with the output stream specified.
 
Method Summary
 boolean defaultDisplay(java.lang.Object obj)
          Default display method which simply prints the object to the output stream (without a newline).
 boolean defaultDisplay(java.lang.Object obj, long level)
          Default display that preserves the level of nesting of the output.
 boolean display(java.util.Enumeration e)
          Display the contents of an Enumeration just as we show the contents of an array displayArray(Object), separating each element with the OutputElementSeparator.
 boolean display(java.lang.Object obj)
          Display the given object considering it as the top-level object being displayed.
 boolean display(java.lang.Object obj, long level)
          Display the given object assuming it is nested level objects within the top-level object being displayed by display(Object).
 boolean displayArray(java.lang.Object obj)
          Display an array object, writing each element to the output stream, separating each from the previous value by the separator OutputElementSeparator.
 java.io.PrintWriter stdout()
          Retrieve the current output stream on which the objects are being displayed.
 java.io.PrintWriter stdout(java.io.PrintWriter w)
          Specify the output stream to which the object representations should be written.
 java.lang.String toString(java.lang.Object obj)
          Get the string representation of the given object as this filter would mark it up.
 java.io.Writer toWriter(java.lang.Object obj)
          Display the given object on the filter's output stream using the representation of the object from toString(Object)
 java.io.Writer writer()
          Retrieve the (default) output stream to which the display is writing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OutputElementSeparator

public static java.lang.String OutputElementSeparator
The separator between the display of the different sub-elements of a container objects (e.g. array, Vector, etc.) This can be easily modified to change the containers to be displayed on the same line separated by e.g. ", " rather than a new-line. This is shared by all instances of this class. This may need to be make instance-specific. It is public to allow easy access to modifying it interactively.

stdout

protected java.io.PrintWriter stdout
Constructor Detail

BasicObjectDisplay

public BasicObjectDisplay()
Default constructor that uses the standard output device from System.out as the output stream.

BasicObjectDisplay

public BasicObjectDisplay(java.io.PrintWriter out)
Constructor with the output stream specified.
Parameters:
out - the output stream on which the contents of objects should be displayed.
Method Detail

toString

public java.lang.String toString(java.lang.Object obj)
Get the string representation of the given object as this filter would mark it up. This is used primarily by other output mechanisms which wish to control the form of the overall layout of a collection of objects without changing the format of the individual elements. For example, the layout of a table rather than sequential elements or inserting the entire output of an element within an HTML link would use this.
Specified by:
toString in interface ObjectDisplayFilter

toWriter

public java.io.Writer toWriter(java.lang.Object obj)
Display the given object on the filter's output stream using the representation of the object from toString(Object)
Specified by:
toWriter in interface ObjectDisplayFilter

writer

public java.io.Writer writer()
Retrieve the (default) output stream to which the display is writing.
Specified by:
writer in interface ObjectDisplayFilter

display

public boolean display(java.lang.Object obj)
Display the given object considering it as the top-level object being displayed.
Specified by:
display in interface ObjectDisplayFilter
Following copied from interface: org.omegahat.Environment.IO.ObjectDisplayFilter
See Also:
ObjectDisplayFilter.display(java.lang.Object, long)

display

public boolean display(java.lang.Object obj,
                       long level)
Display the given object assuming it is nested level objects within the top-level object being displayed by display(Object).
Specified by:
display in interface ObjectDisplayFilter

displayArray

public boolean displayArray(java.lang.Object obj)
Display an array object, writing each element to the output stream, separating each from the previous value by the separator OutputElementSeparator.

display

public boolean display(java.util.Enumeration e)
Display the contents of an Enumeration just as we show the contents of an array displayArray(Object), separating each element with the OutputElementSeparator. separator.

defaultDisplay

public boolean defaultDisplay(java.lang.Object obj)
Default display method which simply prints the object to the output stream (without a newline).

defaultDisplay

public boolean defaultDisplay(java.lang.Object obj,
                              long level)
Default display that preserves the level of nesting of the output.

stdout

public java.io.PrintWriter stdout()
Retrieve the current output stream on which the objects are being displayed.

stdout

public java.io.PrintWriter stdout(java.io.PrintWriter w)
Specify the output stream to which the object representations should be written.