Package com.algo.export
Class IndentedWriter
- java.lang.Object
-
- com.algo.export.IndentedWriter
-
public class IndentedWriter extends java.lang.ObjectA stream writer keeping track of indentation. Prefixes strings given to it with the current indentation in form of spaces before writing them to the underlying Writer object.
-
-
Constructor Summary
Constructors Constructor Description IndentedWriter(java.io.Writer out, int spacesPerIndent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecreaseIndent()Decreases the indentation one step.voidincreaseIndent()Increases the indentation one step.voidwrite(java.lang.String s)Writes a string with the current indentation.voidwriteLine(java.lang.String s)Writes a string with the current indentation, followed by a newline.voidwriteLineNoIndent(java.lang.String s)Writes a string without indentation, followed by a newline.voidwriteNoIndent(java.lang.String s)Writes a string without indentation.
-
-
-
Method Detail
-
increaseIndent
public void increaseIndent()
Increases the indentation one step. Subsequent writes will receive more leading spaces.
-
decreaseIndent
public void decreaseIndent()
Decreases the indentation one step. Subsequent writes will receive fewer leading spaces. Does nothing if the indent would become negative.
-
write
public void write(java.lang.String s) throws java.io.IOExceptionWrites a string with the current indentation.- Parameters:
s- The string to write.- Throws:
java.io.IOException- Throws if the underlying Writer instance throws.
-
writeNoIndent
public void writeNoIndent(java.lang.String s) throws java.io.IOExceptionWrites a string without indentation.- Parameters:
s- The string to write- Throws:
java.io.IOException- Throws if the underlying Writer instance throws.
-
writeLine
public void writeLine(java.lang.String s) throws java.io.IOExceptionWrites a string with the current indentation, followed by a newline.- Parameters:
s- The string to write- Throws:
java.io.IOException- Throws if the underlying Writer instance throws.
-
writeLineNoIndent
public void writeLineNoIndent(java.lang.String s) throws java.io.IOExceptionWrites a string without indentation, followed by a newline.- Parameters:
s- The string to write- Throws:
java.io.IOException- Throws if the underlying Writer instance throws.
-
-