Package org.eclipse.rdf4j.common.io
Class IndentingWriter
java.lang.Object
java.io.Writer
org.eclipse.rdf4j.common.io.IndentingWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A writer that adds indentation to written text.
- Author:
- Arjohn Kampman
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The current indentation level, i.e.protected Writer
The underlying writer. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Decrease indentation level by 1.void
flush()
int
Get the number of characters read since end-of-line.int
Get the indentation level (number of tabs or indentation string).Gets the string used for indentation.void
Increase indentation level by 1.void
setIndentationLevel
(int indentationLevel) Set indentation level (number of tabs or indentation string).void
setIndentationString
(String indentString) Sets the string that should be used for indentation.void
write
(char[] cbuf, int off, int len) void
void
writeEOL()
Writes an end-of-line character sequence and triggers the indentation for the text written on the next line.
-
Field Details
-
out
The underlying writer. -
indentationLevel
protected int indentationLevelThe current indentation level, i.e. the number of tabs to indent a start or end tag.
-
-
Constructor Details
-
IndentingWriter
-
-
Method Details
-
setIndentationString
Sets the string that should be used for indentation. The default indentation string is a tab character.- Parameters:
indentString
- The indentation string, e.g. a tab or a number of spaces.
-
getIndentationString
Gets the string used for indentation.- Returns:
- the indentation string.
-
getIndentationLevel
public int getIndentationLevel()Get the indentation level (number of tabs or indentation string).- Returns:
- level as an integer
-
setIndentationLevel
public void setIndentationLevel(int indentationLevel) Set indentation level (number of tabs or indentation string).- Parameters:
indentationLevel
- level as an integer
-
getCharactersSinceEOL
public int getCharactersSinceEOL()Get the number of characters read since end-of-line.- Returns:
- number of characters
-
increaseIndentation
public void increaseIndentation()Increase indentation level by 1. -
decreaseIndentation
public void decreaseIndentation()Decrease indentation level by 1. -
writeEOL
Writes an end-of-line character sequence and triggers the indentation for the text written on the next line.- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-