Skip navigation links


oracle.idm.io
Class IndentPrintStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.PrintStream
              extended by oracle.idm.io.IndentPrintStream

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable, Indentable

public class IndentPrintStream
extends java.io.PrintStream
implements Indentable

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

Here is an example of how to use IndentPrintStream:

 IndentPrintStream out = new IndentPrintStream(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.FilterOutputStream
out

 

Constructor Summary
IndentPrintStream(java.io.OutputStream out)
          Constructor for indent print stream from output stream.
IndentPrintStream(java.io.OutputStream out, boolean autoFlush)
          Constructor for indent print stream from output stream, given auto flush mode.
IndentPrintStream(java.io.OutputStream out, boolean autoFlush, java.lang.String encoding)
          Constructor for indent print stream from output stream, given auto flush mode and encoding.

 

Method Summary
 void decrease()
          This method decreases indentation level.
 Indenter getIndenter()
          Getter for the indenter of this indent print stream.
static IndentPrintStream getIndentPrintStream(java.io.OutputStream out)
          Factory method for indent print streams.
 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 stream.

 

Methods inherited from class java.io.PrintStream
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

 

Methods inherited from class java.io.FilterOutputStream
write

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

IndentPrintStream

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

IndentPrintStream

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

IndentPrintStream

public IndentPrintStream(java.io.OutputStream out,
                         boolean autoFlush,
                         java.lang.String encoding)
                  throws java.io.UnsupportedEncodingException
Constructor for indent print stream from output stream, given auto flush mode and encoding.
Throws:
java.io.UnsupportedEncodingException

Method Detail

getIndentPrintStream

public static IndentPrintStream getIndentPrintStream(java.io.OutputStream out)
Factory method for indent print streams. If the output stream input argument is already an indent print stream, it will be returned. Otherwise a new indent print stream will be constructed and returned.

getIndenter

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

setIndenter

public void setIndenter(Indenter indenter)
Setter for the indenter of this indent print stream.
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