Skip navigation links


oracle.idm.io
Class IndentPrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by oracle.idm.io.IndentPrintWriter

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable, Indentable
Direct Known Subclasses:
XmlPrintWriter

public class IndentPrintWriter
extends java.io.PrintWriter
implements Indentable

IndentPrintWriter is a convenience class for indented printing. It extends the PrintWriter, and simplifies printing of indented information, such as XML tags. You can construct the IndentPrintWriter from any OutputStream or any Writer. If OutputStream or Writer used to construct the IndentPrintWriter is already an instance of IndentPrintStream or IndentPrintWriter, both will share the same Indentater.

Here is an example of how to use IndentPrintWriter:

 IndentPrintWriter out = new IndentPrintWriter(System.out);
 out.iprintln(...);
 out.increase();
 foo.print(out); // foo will print at increased indentation level
 out.decrease();
 out.iprintln(...);
 

Field Summary

 

Fields inherited from class java.io.PrintWriter
out

 

Fields inherited from class java.io.Writer
lock

 

Constructor Summary
IndentPrintWriter(java.io.OutputStream out)
          Constructor for indent print writer from output stream.
IndentPrintWriter(java.io.OutputStream out, boolean autoFlush)
          Constructor for indent print writer from output stream, given auto flush mode.
IndentPrintWriter(java.io.Writer out)
          Constructor for indent print writer from writer.
IndentPrintWriter(java.io.Writer out, boolean autoFlush)
          Constructor for indent print writer from writer, given auto flush mode.

 

Method Summary
 void decrease()
          This method decreases indentation level.
 Indenter getIndenter()
          Getter for the indenter of this indent print writer.
static IndentPrintWriter getIndentPrintWriter(java.io.Writer out)
          Factory method for indent print writers.
 void increase()
          This method increases indentation level.
 void indent()
          This method prints the indentation.
 void iprint(boolean b)
          Indents and prints a boolean.
 void iprint(char c)
          Indents and prints a char.
 void iprint(char[] s)
          Indents and prints a char[].
 void iprint(double d)
          Indents and prints a double.
 void iprint(float f)
          Indents and prints a float.
 void iprint(int i)
          Indents and prints an int.
 void iprint(long l)
          Indents and prints a long.
 void iprint(java.lang.Object o)
          Indents and prints an object.
 void iprint(java.lang.String s)
          Indents and prints a string.
 void iprintln()
          Indents and terminates the line.
 void iprintln(boolean b)
          Indents, prints a boolean, and terminates the line.
 void iprintln(char c)
          Indents, prints a char, and terminates the line.
 void iprintln(char[] s)
          Indents, prints a char[], and terminates the line.
 void iprintln(double d)
          Indents, prints a double, and terminates the line.
 void iprintln(float f)
          Indents, prints a float, and terminates the line.
 void iprintln(int i)
          Indents, prints an int, and terminates the line.
 void iprintln(long l)
          Indents, prints a long, and terminates the line.
 void iprintln(java.lang.Object o)
          Indents, prints an object, and terminates the line.
 void iprintln(java.lang.String s)
          Indents, prints a string, and terminates the line.
 void setIndenter(Indenter indenter)
          Setter for the indenter of this indent print writer.

 

Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, 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

IndentPrintWriter

public IndentPrintWriter(java.io.OutputStream out)
Constructor for indent print writer from output stream.

IndentPrintWriter

public IndentPrintWriter(java.io.OutputStream out,
                         boolean autoFlush)
Constructor for indent print writer from output stream, given auto flush mode.

IndentPrintWriter

public IndentPrintWriter(java.io.Writer out)
Constructor for indent print writer from writer.

IndentPrintWriter

public IndentPrintWriter(java.io.Writer out,
                         boolean autoFlush)
Constructor for indent print writer from writer, given auto flush mode.

Method Detail

getIndentPrintWriter

public static IndentPrintWriter getIndentPrintWriter(java.io.Writer out)
Factory method for indent print writers. If the writer input argument is already an indent print writer, it will be returned. Otherwise a new indent print writer will be constructed and returned.

getIndenter

public Indenter getIndenter()
Getter for the indenter of this indent print writer.
Specified by:
getIndenter in interface Indentable

setIndenter

public void setIndenter(Indenter indenter)
Setter for the indenter of this indent print writer.
Specified by:
setIndenter in interface Indentable

increase

public void increase()
This method increases indentation level.
Specified by:
increase in interface Indentable

decrease

public void decrease()
This method decreases indentation level.
Specified by:
decrease in interface Indentable

indent

public void indent()
This method prints the indentation.
Specified by:
indent in interface Indentable

iprint

public void iprint(boolean b)
Indents and prints a boolean.

iprint

public void iprint(char c)
Indents and prints a char.

iprint

public void iprint(int i)
Indents and prints an int.

iprint

public void iprint(long l)
Indents and prints a long.

iprint

public void iprint(float f)
Indents and prints a float.

iprint

public void iprint(double d)
Indents and prints a double.

iprint

public void iprint(char[] s)
Indents and prints a char[].

iprint

public void iprint(java.lang.String s)
Indents and prints a string.

iprint

public void iprint(java.lang.Object o)
Indents and prints an object.

iprintln

public void iprintln()
Indents and terminates the line.

iprintln

public void iprintln(boolean b)
Indents, prints a boolean, and terminates the line.

iprintln

public void iprintln(char c)
Indents, prints a char, and terminates the line.

iprintln

public void iprintln(int i)
Indents, prints an int, and terminates the line.

iprintln

public void iprintln(long l)
Indents, prints a long, and terminates the line.

iprintln

public void iprintln(float f)
Indents, prints a float, and terminates the line.

iprintln

public void iprintln(double d)
Indents, prints a double, and terminates the line.

iprintln

public void iprintln(char[] s)
Indents, prints a char[], and terminates the line.

iprintln

public void iprintln(java.lang.String s)
Indents, prints a string, and terminates the line.

iprintln

public void iprintln(java.lang.Object o)
Indents, prints an object, and terminates the line.

Skip navigation links