public class

IndentingWriter

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

Class Overview

A BufferedWriter that supports automatic indentation of lines of text written to the underlying Writer. Methods are provided for compact/convenient indenting in and out, writing text, and writing lines of text 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)
Creates a new IndentingWriter that writes indented text to the given Writer.
IndentingWriter(Writer out, int indentStep)
Creates a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step.
IndentingWriter(Writer out, int indentStep, int tabSize)
Creates a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step and tab size.
Public Methods
void newLine()
Writes a line separator.
void p(String s)
Writes string.
void p(Object o)
Writes object.
void pI()
Indents in.
void pO()
Indents out.
void pO(String s)
Indents out; writes string.
void pO(Object o)
Indents out; writes object.
void pOln(Object o)
Indents out; writes object; ends current line.
void pOln(String s)
Indents out; writes string; ends current line.
void pOlnI(String s)
Indents out; writes string; ends current line; indents in.
void pOlnI(Object o)
Indents out; writes object; ends current line; indents in.
void pln(String s)
Writes string; ends current line.
void pln()
Ends current line.
void pln(Object o)
Writes object; ends current line.
void plnI(Object o)
Writes object; ends current line; indents in.
void plnI(String s)
Writes string; ends current line; indents in.
void write(char[] cbuf, int off, int len)
Writes a portion of an array of characters.
void write(int c)
Writes a single character.
void write(String s, int off, int len)
Writes a portion of a String.
Protected Methods
void checkWrite()
Checks if an indent needs to be written before writing the next character.
void indentIn()
Increases the current indent by the indent step.
void indentOut()
Decreases 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)

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

public IndentingWriter (Writer out, int indentStep)

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

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

Creates 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 ()

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

Throws
IOException

public void p (String s)

Writes string.

Throws
IOException

public void p (Object o)

Writes object.

Throws
IOException

public void pI ()

Indents in.

public void pO ()

Indents out.

public void pO (String s)

Indents out; writes string.

Throws
IOException

public void pO (Object o)

Indents out; writes object.

Throws
IOException

public void pOln (Object o)

Indents out; writes object; ends current line.

Throws
IOException

public void pOln (String s)

Indents out; writes string; ends current line.

Throws
IOException

public void pOlnI (String s)

Indents out; writes string; ends current line; indents 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)

Indents out; writes object; ends current line; indents 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)

Writes string; ends current line.

Throws
IOException

public void pln ()

Ends current line.

Throws
IOException

public void pln (Object o)

Writes object; ends current line.

Throws
IOException

public void plnI (Object o)

Writes object; ends current line; indents in.

Throws
IOException

public void plnI (String s)

Writes string; ends current line; indents in.

Throws
IOException

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

Writes 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)

Writes a single character.

Parameters
c int specifying a character to be written
Throws
IOException

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

Writes 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 ()

Checks 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 ()

Increases the current indent by the indent step.

protected void indentOut ()

Decreases the current indent by the indent step.