- All Known Implementing Classes:
JavaScriptWriter
,JsonWriter
,LdJsonWriter
,MysqlWriter
,PsqlWriter
,ShWriter
,StyleWriter
,TextWriter
,WhitespaceWriter
,XhtmlAttributeWriter
,XhtmlWriter
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The number of space characters per indentation level.static final char
The character used for newlines.static final char
The character used for space, which is' '
. -
Method Summary
Modifier and TypeMethodDescriptiondecDepth()
Decrements the indentation depth, if enabled.int
getDepth()
Gets the current indentation depth, which begins at zero.boolean
Gets if indentation is currently enabled, off by default.incDepth()
Increments the indentation depth, if enabled.default Whitespace
indent()
Writes the current indentation when indentation enabled.default Whitespace
indent
(int depthOffset) Writes the current indentation with a depth offset when indentation enabled.nl()
Writes a newline.default Whitespace
nli()
Writes a newline, followed by current indentation when indentation enabled.default Whitespace
nli
(int depthOffset) Writes a newline, followed by current indentation with a depth offset when indentation enabled.setDepth
(int depth) Sets the indentation depth.setIndent
(boolean indent) Enables or disabled indentation.default Whitespace
sp()
Writes one space character.sp
(int count) Writes the given number of space characters.
-
Field Details
-
NL
static final char NLThe character used for newlines.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- See Also:
-
INDENT_SPACES
static final int INDENT_SPACESThe number of space characters per indentation level.- See Also:
-
SPACE
static final char SPACEThe character used for space, which is' '
.- See Also:
-
-
Method Details
-
nl
Writes a newline.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Returns:
this
writer- Throws:
IOException
- See Also:
-
nli
Writes a newline, followed by current indentation when indentation enabled.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Returns:
this
writer- Throws:
IOException
- See Also:
-
nli
Writes a newline, followed by current indentation with a depth offset when indentation enabled.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Parameters:
depthOffset
- A value added to the current indentation depth. For example, pass-1
when performing a newline before a closing tag or ending curly brace.- Returns:
this
writer- Throws:
IOException
- See Also:
-
indent
Writes the current indentation when indentation enabled.- Returns:
this
writer- Throws:
IOException
- See Also:
-
indent
Writes the current indentation with a depth offset when indentation enabled.- Parameters:
depthOffset
- A value added to the current indentation depth. For example, pass-1
when performing a newline before a closing tag or ending curly brace.- Returns:
this
writer- Throws:
IOException
- See Also:
-
getIndent
boolean getIndent()Gets if indentation is currently enabled, off by default. -
setIndent
Enables or disabled indentation.- Returns:
this
writer
-
getDepth
int getDepth()Gets the current indentation depth, which begins at zero. This value is not updated when indentation is disabled. Not all tags will trigger indentation. -
setDepth
Sets the indentation depth.- Returns:
this
writer
-
incDepth
Whitespace incDepth()Increments the indentation depth, if enabled.- Returns:
this
writer
-
decDepth
Whitespace decDepth()Decrements the indentation depth, if enabled.- Returns:
this
writer
-
sp
Writes one space character.- Returns:
this
writer- Throws:
IOException
- See Also:
-
sp
Writes the given number of space characters.- Parameters:
count
- Whencount <= 0
, nothing is written.- Returns:
this
writer- Throws:
IOException
- See Also:
-