public class

IndentingWriter

extends BufferedWriter
java.lang.Object
   ↳ java.io.Writer
     ↳ java.io.BufferedWriter
       ↳ sun.rmi.rmic.IndentingWriter

Class Overview

IndentingWriter is a BufferedWriter subclass that supports automatic indentation of lines of text written to the underlying Writer. Methods are provided for compact, convenient indenting, writing text, and writing lines in various combinations. WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.

Summary

[Expand]
Inherited Fields
From class java.io.Writer
Public Constructors
IndentingWriter(Writer out)
Create a new IndentingWriter that writes indented text to the given Writer.
IndentingWriter(Writer out, int step)
Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step.
IndentingWriter(Writer out, int step, int tabSize)
Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step and tab size.
Public Methods
void newLine()
Write a line separator.
void p(String s)
Write string.
void p(Object o)
Write Object.
void pI()
Indent in.
void pO()
Indent out.
void pO(String s)
Indent out; write string.
void pO(Object o)
Indent out; write Object.
void pOln(Object o)
Indent out; write Object; end current line.
void pOln(String s)
Indent out; write string; end current line.
void pOlnI(String s)
Indent out; write string; end current line; indent in.
void pOlnI(Object o)
Indent out; write Object; end current line; indent in.
void pln(String s)
Write string; end current line.
void pln()
End current line.
void pln(Object o)
Write Object; end current line.
void plnI(Object o)
Write Object; end current line; indent in.
void plnI(String s)
Write string; end current line; indent in.
void write(char[] cbuf, int off, int len)
Write a portion of an array of characters.
void write(int c)
Write a single character.
void write(String s, int off, int len)
Write a portion of a String.
Protected Methods
void checkWrite()
Check if an indent needs to be written before writing the next character.
void indentIn()
Increase the current indent by the indent step.
void indentOut()
Decrease the current indent by the indent step.
[Expand]
Inherited Methods
From class java.io.BufferedWriter
From class java.io.Writer
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.Appendable

Public Constructors

public IndentingWriter (Writer out)

Create a new IndentingWriter that writes indented text to the given Writer. Use the default indent step of four spaces.

public IndentingWriter (Writer out, int step)

Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step.

public IndentingWriter (Writer out, int step, int tabSize)

Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step and tab size.

Public Methods

public void newLine ()

Write a line separator. The next character written will be preceded by an indent.

Throws
IOException

public void p (String s)

Write string.

Throws
IOException

public void p (Object o)

Write Object.

Throws
IOException

public void pI ()

Indent in.

public void pO ()

Indent out.

public void pO (String s)

Indent out; write string.

Throws
IOException

public void pO (Object o)

Indent out; write Object.

Throws
IOException

public void pOln (Object o)

Indent out; write Object; end current line.

Throws
IOException

public void pOln (String s)

Indent out; write string; end current line.

Throws
IOException

public void pOlnI (String s)

Indent out; write string; end current line; indent in. This method is useful for generating lines of code that both end and begin nested blocks, like "} else {".

Throws
IOException

public void pOlnI (Object o)

Indent out; write Object; end current line; indent in. This method is useful for generating lines of code that both end and begin nested blocks, like "} else {".

Throws
IOException

public void pln (String s)

Write string; end current line.

Throws
IOException

public void pln ()

End current line.

Throws
IOException

public void pln (Object o)

Write Object; end current line.

Throws
IOException

public void plnI (Object o)

Write Object; end current line; indent in.

Throws
IOException

public void plnI (String s)

Write string; end current line; indent in.

Throws
IOException

public void write (char[] cbuf, int off, int len)

Write a portion of an array of characters.

Parameters
cbuf A character array
off Offset from which to start reading characters
len Number of characters to write
Throws
IOException

public void write (int c)

Write a single character.

Parameters
c int specifying a character to be written
Throws
IOException

public void write (String s, int off, int len)

Write a portion of a String.

Parameters
s String to be written
off Offset from which to start reading characters
len Number of characters to be written
Throws
IOException

Protected Methods

protected void checkWrite ()

Check if an indent needs to be written before writing the next character. The indent generation is optimized (and made consistent with certain coding conventions) by condensing groups of eight spaces into tab characters.

Throws
IOException

protected void indentIn ()

Increase the current indent by the indent step.

protected void indentOut ()

Decrease the current indent by the indent step.