java.lang.Object
java.io.Writer
java.io.BufferedWriter
org.glassfish.rmic.IndentingWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
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.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionIndentingWriter(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. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck if an indent needs to be written before writing the next character.protected voidindentIn()Increase the current indent by the indent step.protected voidDecrease the current indent by the indent step.voidnewLine()Write a line separator.voidWrite Object.voidWrite string.voidpI()Indent in.voidpln()End current line.voidWrite Object; end current line.voidWrite string; end current line.voidWrite Object; end current line; indent in.voidWrite string; end current line; indent in.voidpO()Indent out.voidIndent out; write Object.voidIndent out; write string.voidIndent out; write Object; end current line.voidIndent out; write string; end current line.voidIndent out; write Object; end current line; indent in.voidIndent out; write string; end current line; indent in.voidwrite(char[] cbuf, int off, int len) Write a portion of an array of characters.voidwrite(int c) Write a single character.voidWrite a portion of a String.Methods inherited from class java.io.BufferedWriter
close, flush
-
Constructor Details
-
IndentingWriter
Create a new IndentingWriter that writes indented text to the given Writer. Use the default indent step of four spaces. -
IndentingWriter
Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step. -
IndentingWriter
Create a new IndentingWriter that writes indented text to the given Writer and uses the supplied indent step and tab size.
-
-
Method Details
-
write
Write a single character.- Overrides:
writein classBufferedWriter- Throws:
IOException
-
write
Write a portion of an array of characters.- Overrides:
writein classBufferedWriter- Throws:
IOException
-
write
Write a portion of a String.- Overrides:
writein classBufferedWriter- Throws:
IOException
-
newLine
Write a line separator. The next character written will be preceded by an indent.- Overrides:
newLinein classBufferedWriter- Throws:
IOException
-
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
-
indentIn
protected void indentIn()Increase the current indent by the indent step. -
indentOut
protected void indentOut()Decrease the current indent by the indent step. -
pI
public void pI()Indent in. -
pO
public void pO()Indent out. -
p
Write string.- Throws:
IOException
-
pln
End current line.- Throws:
IOException
-
pln
Write string; end current line.- Throws:
IOException
-
plnI
Write string; end current line; indent in.- Throws:
IOException
-
pO
Indent out; write string.- Throws:
IOException
-
pOln
Indent out; write string; end current line.- Throws:
IOException
-
pOlnI
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
-
p
Write Object.- Throws:
IOException
-
pln
Write Object; end current line.- Throws:
IOException
-
plnI
Write Object; end current line; indent in.- Throws:
IOException
-
pO
Indent out; write Object.- Throws:
IOException
-
pOln
Indent out; write Object; end current line.- Throws:
IOException
-
pOlnI
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
-