All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.bmrb.starlibj.StarUnparser

java.lang.Object
   |
   +----EDU.bmrb.starlibj.StarUnparser

public class StarUnparser
extends Object
implements Cloneable
The inverse of class StarParse: This class will print out a star file (or subset thereof) into a previously opened output stream. Many of the output options can be manipulated with get... and set... functions.

This class is thread-safe if and only if each thread that uses it has its own separate instances of this class. (There are no static entities that step on each other in this class, so each instance of it is independant, but there are some dynamic entities that do get in each other's way if multiple threads try to run methods in the same object.)


Variable Index

 o formatting
 o indentSize
 o oWrit

Constructor Index

 o StarUnparser(OutputStream)
Constructor: Pass in an already-opened output stream and the output will end up there - buffered.
 o StarUnparser(OutputStream, boolean)
Constructor: Pass in an already-opened output stream and the output will end up there - and choose the flushing flag.
 o StarUnparser(StarUnparser)
copy constructor: copies an existing StarUnparser object:

Method Index

 o clone(StarUnparser)
clone - needed so that this type can be stored inside the container classes in java.util.*.
 o finalize()
Flush the output one last time before ending.
 o getFormatting()
Gets the value of current formatting flag.
 o getIndentSize()
Gets the number of characters to indent when printing.
 o isItNumeric(String)
 o setFormatting(boolean)
Turns off (or on) the formatting code for output.
 o setIndentSize(int)
Sets the number of characters to indent when printing.
 o writeBlockNode(BlockNode, int)
 o writeDataItemNode(DataItemNode, int, int)
 o writeDataLoopNameListNode(DataLoopNameListNode, int)
 o writeDataLoopNode(DataLoopNode, int)
 o writeDataNameNode(DataNameNode, int)
 o writeDataValueNode(DataValueNode, int, int, int)
 o writeIndent(int)
 o writeLoopNameListNode(LoopNameListNode, int)
 o writeLoopRowNode(LoopRowNode, int, Vector, Vector)
 o writeLoopTableNode(LoopTableNode, int)
 o writeOut(StarNode, int)
Writes out the StarNode-derived object given.
 o writeOut(StarNode, int, int)
Writes out the StarNode-derived object given.
 o writePreComment(String, int)
 o writeSaveFrameNode(SaveFrameNode, int)
 o writeStarFileNode(StarFileNode, int)

Variables

 o indentSize
 protected int indentSize
 o formatting
 protected boolean formatting
 o oWrit
 protected PrintWriter oWrit

Constructors

 o StarUnparser
 public StarUnparser(OutputStream out)
Constructor: Pass in an already-opened output stream and the output will end up there - buffered. Output will appear without flushing each line.

Parameters:
out - The output stream to print on.
 o StarUnparser
 public StarUnparser(OutputStream out,
                     boolean autoFlush)
Constructor: Pass in an already-opened output stream and the output will end up there - and choose the flushing flag.

Parameters:
out - The output stream to print on.
autoFlush - true = flush each line, false = don't flush output on each line. Setting it false is the default.
 o StarUnparser
 public StarUnparser(StarUnparser copyMe)
copy constructor: copies an existing StarUnparser object:

Methods

 o finalize
 protected void finalize()
Flush the output one last time before ending. DOES NOT CLOSE THE STREAM, since this class did not create the stream.

Overrides:
finalize in class Object
 o clone
 public StarUnparser clone(StarUnparser copyMe)
clone - needed so that this type can be stored inside the container classes in java.util.*. It mimics the functionality of a copy constructor, but with a different syntax.

 o writeOut
 public void writeOut(StarNode node,
                      int indentLvl)
Writes out the StarNode-derived object given. pass a StarFileNode and it prints the whole file. Pass a single DataValueNode and it just prints that one value. The output can happen at any subset of the StarNode hierarchy.

Parameters:
node - The StarNode to print out.
indentLvl - The starting indent level to
longest - The longest string in the value. print at, typically zero. The number of characters indented will be = (indentLvl * getIndentSize()).
See Also:
setIndentSize
 o writeOut
 protected void writeOut(StarNode node,
                         int indentLvl,
                         int longest)
Writes out the StarNode-derived object given. pass a StarFileNode and it prints the whole file. Pass a single DataValueNode and it just prints that one value. The output can happen at any subset of the StarNode hierarchy.

Parameters:
node - The StarNode to print out.
indentLvl - The starting indent level to
longest - The longest string in the value. print at, typically zero. The number of characters indented will be = (indentLvl * getIndentSize()).
See Also:
setIndentSize
 o writeIndent
 protected void writeIndent(int indentLvl)
 o writePreComment
 protected void writePreComment(String cmt,
                                int indentLvl)
 o writeDataValueNode
 protected void writeDataValueNode(DataValueNode node,
                                   int indentLvl,
                                   int preSize,
                                   int postSize)
 o writeDataNameNode
 protected void writeDataNameNode(DataNameNode node,
                                  int indentLvl)
 o writeDataItemNode
 protected void writeDataItemNode(DataItemNode node,
                                  int indentLvl,
                                  int longest)
 o writeDataLoopNode
 protected void writeDataLoopNode(DataLoopNode node,
                                  int indentLvl)
 o writeDataLoopNameListNode
 protected void writeDataLoopNameListNode(DataLoopNameListNode node,
                                          int indentLvl)
 o writeLoopNameListNode
 protected void writeLoopNameListNode(LoopNameListNode node,
                                      int indentLvl)
 o writeLoopTableNode
 protected void writeLoopTableNode(LoopTableNode node,
                                   int indentLvl)
 o writeLoopRowNode
 protected void writeLoopRowNode(LoopRowNode node,
                                 int indentLvl,
                                 Vector preSizes,
                                 Vector postSizes)
 o writeSaveFrameNode
 protected void writeSaveFrameNode(SaveFrameNode node,
                                   int indentLvl)
 o writeBlockNode
 protected void writeBlockNode(BlockNode node,
                               int indentLvl)
 o writeStarFileNode
 protected void writeStarFileNode(StarFileNode node,
                                  int indentLvl)
 o setIndentSize
 public void setIndentSize(int s)
Sets the number of characters to indent when printing. Each time the output formatter needs to indent one more level, this is the number of spaces it will indent.

 o getIndentSize
 public int getIndentSize()
Gets the number of characters to indent when printing. Each time the output formatter needs to indent one more level, this is the number of spaces it will indent.

Returns:
number of characters.
 o setFormatting
 public void setFormatting(boolean isOn)
Turns off (or on) the formatting code for output. By default, the formatting is always on. The formatting can be turned off if the output does not need to be made 'pretty', and only needs to be syntactically correct. This is mostly useful when you are creating STAR syntax that you intend to be read by another computer program and you don't think a human's eyes will ever need to look at the output. Formatting slows down the output because multiple passes are required to count characters in values to make the values line up with each other. Turning the formatting off will speed up the output at the expense of human readability. Turning off formatting also condenses the whitespace down to the smallest it can be while still preserving syntax.

One example of a place where this could be useful is when two programs are communicating using STAR syntax over a pipe or socket.

Parameters:
isOn - true (default) == formatting is on, false == turn formatting off.
 o getFormatting
 public boolean getFormatting()
Gets the value of current formatting flag.

Returns:
the formatting flag.
See Also:
setFormatting
 o isItNumeric
 protected boolean isItNumeric(String str)

All Packages  Class Hierarchy  This Package  Previous  Next  Index