Package org.geotools.util
Class IndentedLineWriter
Object
Writer
FilterWriter
IndentedLineWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A writer that put some spaces in front of every lines. The indentation is initially set to 0 spaces. Users must
invoke
setIndentation(int)
in order to set a different value.- Since:
- 2.4
- Author:
- Martin Desruisseaux
-
Field Summary
Fields inherited from class FilterWriter
out
-
Constructor Summary
ConstructorsConstructorDescriptionIndentedLineWriter
(Writer out) Constructs a stream which will add spaces in front of each line. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Invoked when a new line is begining.int
Returns the current indentation.void
setIndentation
(int width) Sets the indentation to the specified value.void
write
(char[] buffer, int offset, int length) Writes a portion of an array of characters.void
write
(int c) Writes a single character.void
Writes a portion of a string.Methods inherited from class FilterWriter
close, flush
-
Constructor Details
-
IndentedLineWriter
Constructs a stream which will add spaces in front of each line.- Parameters:
out
- The underlying stream to write to.
-
-
Method Details
-
getIdentation
public int getIdentation()Returns the current indentation.- Returns:
- The current indentation.
-
setIndentation
public void setIndentation(int width) Sets the indentation to the specified value.- Parameters:
width
- The new indentation.
-
beginNewLine
Invoked when a new line is begining. The default implementation writes the amount of spaces specified by the last call tosetIndentation(int)
.- Throws:
IOException
- If an I/O error occurs
-
write
Writes a single character.- Overrides:
write
in classFilterWriter
- Throws:
IOException
- If an I/O error occurs.
-
write
Writes a portion of an array of characters.- Overrides:
write
in classFilterWriter
- Parameters:
buffer
- Buffer of characters to be written.offset
- Offset from which to start reading characters.length
- Number of characters to be written.- Throws:
IOException
- If an I/O error occurs.
-
write
Writes a portion of a string.- Overrides:
write
in classFilterWriter
- Parameters:
string
- String to be written.offset
- Offset from which to start reading characters.length
- Number of characters to be written.- Throws:
IOException
- If an I/O error occurs.
-