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.)
-
formatting
-
-
indentSize
-
-
oWrit
-
-
StarUnparser(OutputStream)
- Constructor: Pass in an already-opened output stream
and the output will end up there - buffered.
-
StarUnparser(OutputStream, boolean)
- Constructor: Pass in an already-opened output stream
and the output will end up there - and choose the
flushing flag.
-
StarUnparser(StarUnparser)
- copy constructor: copies an existing StarUnparser
object:
-
clone(StarUnparser)
- clone - needed so that this type can be stored inside
the container classes in java.util.*.
-
finalize()
- Flush the output one last time before ending.
-
getFormatting()
- Gets the value of current formatting flag.
-
getIndentSize()
- Gets the number of characters to indent when printing.
-
isItNumeric(String)
-
-
setFormatting(boolean)
- Turns off (or on) the formatting code for output.
-
setIndentSize(int)
- Sets the number of characters to indent when printing.
-
writeBlockNode(BlockNode, int)
-
-
writeDataItemNode(DataItemNode, int, int)
-
-
writeDataLoopNameListNode(DataLoopNameListNode, int)
-
-
writeDataLoopNode(DataLoopNode, int)
-
-
writeDataNameNode(DataNameNode, int)
-
-
writeDataValueNode(DataValueNode, int, int, int)
-
-
writeIndent(int)
-
-
writeLoopNameListNode(LoopNameListNode, int)
-
-
writeLoopRowNode(LoopRowNode, int, Vector, Vector)
-
-
writeLoopTableNode(LoopTableNode, int)
-
-
writeOut(StarNode, int)
- Writes out the StarNode-derived object given.
-
writeOut(StarNode, int, int)
- Writes out the StarNode-derived object given.
-
writePreComment(String, int)
-
-
writeSaveFrameNode(SaveFrameNode, int)
-
-
writeStarFileNode(StarFileNode, int)
-
indentSize
protected int indentSize
formatting
protected boolean formatting
oWrit
protected PrintWriter oWrit
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.
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.
StarUnparser
public StarUnparser(StarUnparser copyMe)
- copy constructor: copies an existing StarUnparser
object:
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
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.
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
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
writeIndent
protected void writeIndent(int indentLvl)
writePreComment
protected void writePreComment(String cmt,
int indentLvl)
writeDataValueNode
protected void writeDataValueNode(DataValueNode node,
int indentLvl,
int preSize,
int postSize)
writeDataNameNode
protected void writeDataNameNode(DataNameNode node,
int indentLvl)
writeDataItemNode
protected void writeDataItemNode(DataItemNode node,
int indentLvl,
int longest)
writeDataLoopNode
protected void writeDataLoopNode(DataLoopNode node,
int indentLvl)
writeDataLoopNameListNode
protected void writeDataLoopNameListNode(DataLoopNameListNode node,
int indentLvl)
writeLoopNameListNode
protected void writeLoopNameListNode(LoopNameListNode node,
int indentLvl)
writeLoopTableNode
protected void writeLoopTableNode(LoopTableNode node,
int indentLvl)
writeLoopRowNode
protected void writeLoopRowNode(LoopRowNode node,
int indentLvl,
Vector preSizes,
Vector postSizes)
writeSaveFrameNode
protected void writeSaveFrameNode(SaveFrameNode node,
int indentLvl)
writeBlockNode
protected void writeBlockNode(BlockNode node,
int indentLvl)
writeStarFileNode
protected void writeStarFileNode(StarFileNode node,
int indentLvl)
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.
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.
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.
getFormatting
public boolean getFormatting()
- Gets the value of current formatting flag.
- Returns:
- the formatting flag.
- See Also:
- setFormatting
isItNumeric
protected boolean isItNumeric(String str)
All Packages Class Hierarchy This Package Previous Next Index