org.enhydra.xml.xmlc.codegen
Class IndentWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.PrintWriter
              |
              +--org.enhydra.xml.xmlc.codegen.IndentWriter
Direct Known Subclasses:
ParseTracer, StringIndentWriter

public class IndentWriter
extends PrintWriter

Class to print lines with indentation. Overrides all print methods to do indentation at the start of a line.


Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
IndentWriter(File src)
          Constructor given a file name.
IndentWriter(File src, String enc)
          Constructor given a file name and an encoding.
IndentWriter(Writer writer)
          Constructor from a Writer
IndentWriter(Writer writer, boolean autoflush)
          Constructor from a Writer
 
Method Summary
 boolean atBOLN()
          Are we at the beginning of a line?
 void close(boolean ignoreErrors)
          Called when through generating code.
 void enter()
          Increase indentation level.
 void flush()
          Flush output; indentation must be zero.
 int getIndentLevel()
          Get the indentation level.
 boolean getZeroCheck()
          Get value of zero-check flag.
 void leave()
          Decrease indentation level.
 void popAdditionalIndent()
          Remove the last amount of additional indentation that was added.
 void print(boolean b)
          Print a boolean value.
 void print(char c)
          Print a character.
 void print(char[] str)
          Print an array of characters, indenting at the beginning of lines.
 void print(double d)
          Print a double-precision floating-point number.
 void print(float f)
          Print a floating-point number.
 void print(long l)
          Print a long integer.
 void print(Object obj)
          Print an object.
 void print(String str)
          Print a string, indenting at the beginning of lines.
 void println()
          Terminate the current line by writing the line separator string.
 void println(String[] strs)
          Write an array of strings, one line per string.
protected  void printPrefix(String prefix)
          Print a prefix for a line.
 void pushAdditionalIndent(int numChars)
          Push an additional amount of indentation, in an arbitrary number of characters.
 void setZeroCheck(boolean value)
          Set value of zero-check flag.
 
Methods inherited from class java.io.PrintWriter
checkError, close, print, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndentWriter

public IndentWriter(Writer writer)
Constructor from a Writer

IndentWriter

public IndentWriter(Writer writer,
                    boolean autoflush)
Constructor from a Writer

IndentWriter

public IndentWriter(File src)
             throws IOException
Constructor given a file name. If the directory containing the file doesn't exist, it is created.

IndentWriter

public IndentWriter(File src,
                    String enc)
             throws IOException
Constructor given a file name and an encoding. If the directory containing the file doesn't exist, it is created.
Method Detail

setZeroCheck

public void setZeroCheck(boolean value)
Set value of zero-check flag. If true, then generate an error if indentation is not zero on close. Default is true.

getZeroCheck

public boolean getZeroCheck()
Get value of zero-check flag.

close

public void close(boolean ignoreErrors)
Called when through generating code. Close the contained stream and make sure that indentation is zero. If not, we might have screawed something up.
Parameters:
ignoreErrors - If true, ignore any errors and don't check for zero. This should be used only when calling this method while handling an error.

flush

public void flush()
Flush output; indentation must be zero.
Overrides:
flush in class PrintWriter

enter

public final void enter()
Increase indentation level.

leave

public final void leave()
Decrease indentation level.

getIndentLevel

public final int getIndentLevel()
Get the indentation level.

pushAdditionalIndent

public final void pushAdditionalIndent(int numChars)
Push an additional amount of indentation, in an arbitrary number of characters. This is used for aligning parameters, etc, which don't fall on the block-level indent boundry.

popAdditionalIndent

public final void popAdditionalIndent()
Remove the last amount of additional indentation that was added.

atBOLN

public boolean atBOLN()
Are we at the beginning of a line?

printPrefix

protected void printPrefix(String prefix)
Print a prefix for a line. If not at the beginning of a line, start a new one. Prefix will preceed indentation.

print

public void print(boolean b)
Print a boolean value.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(char c)
Print a character.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(long l)
Print a long integer.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(float f)
Print a floating-point number.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(double d)
Print a double-precision floating-point number.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(char[] str)
Print an array of characters, indenting at the beginning of lines. The string is split at embedded newlines.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(String str)
Print a string, indenting at the beginning of lines. The string is split at embedded newlines.
Overrides:
print in class PrintWriter
See Also:
Writer

print

public void print(Object obj)
Print an object.
Overrides:
print in class PrintWriter
See Also:
Writer

println

public void println()
Terminate the current line by writing the line separator string.
Overrides:
println in class PrintWriter
See Also:
Writer

println

public void println(String[] strs)
Write an array of strings, one line per string. Indenting at the beginning of the line. The string is split at embedded newlines.
See Also:
Writer


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.