public final class StyleAppendable extends Object
Appendable
that provides a few convenience functions.
When not specifying a particular Appendable
then use toString()
to get the final output.
Constructor and Description |
---|
StyleAppendable()
Creates a new
StyleAppendable using a StringBuilder . |
StyleAppendable(Appendable appendable)
Creates a new
StyleAppendable using the given Appendable . |
Modifier and Type | Method and Description |
---|---|
StyleAppendable |
append(char c)
Appends the specified character.
|
StyleAppendable |
append(CharSequence sequence)
Appends the specified
CharSequence or String. |
StyleAppendable |
append(double d)
Appends the specified double.
|
StyleAppendable |
append(int i)
Appends the specified integer.
|
StyleAppendable |
append(long l)
Appends the specified long.
|
StyleAppendable |
indent()
Increases the indentation level.
|
int |
indentationLevel()
Gets the current indentation level.
|
StyleAppendable |
indentIf(boolean condition)
Increases the indentation level only if the given condition is true.
|
StyleAppendable |
newline()
Appends a newline character.
|
StyleAppendable |
newlineIf(boolean condition)
Appends a newline character only if the given condition is true.
|
StyleAppendable |
space()
Appends a single space character.
|
StyleAppendable |
spaceIf(boolean condition)
Appends a single space character only if the given condition is true.
|
String |
toString() |
StyleAppendable |
unindent()
Decreases the indentation level.
|
StyleAppendable |
unindentIf(boolean condition)
Decreases the indentation level only if the given condition is true.
|
public StyleAppendable()
public StyleAppendable(Appendable appendable)
StyleAppendable
using the given Appendable
.appendable
- Write to this Appendable
.public StyleAppendable append(char c) throws IOException
append(CharSequence)
.c
- The character to write.IOException
- If an I/O error occurs.public StyleAppendable append(int i) throws IOException
i
- The integer to write.IOException
- If an I/O error occurs.public StyleAppendable append(double d) throws IOException
d
- The double to write.IOException
- If an I/O error occurs.public StyleAppendable append(long l) throws IOException
l
- The long to write.IOException
- If an I/O error occurs.public StyleAppendable append(CharSequence sequence) throws IOException
CharSequence
or String.sequence
- The character sequence to append.IOException
- If an I/O error occurs.public StyleAppendable newline() throws IOException
IOException
- If an I/O error occurs.public StyleAppendable newlineIf(boolean condition) throws IOException
condition
- Only append a newline if this condition is true.IOException
- If an I/O error occurs.public StyleAppendable space() throws IOException
IOException
- If an I/O error occurs.public StyleAppendable spaceIf(boolean condition) throws IOException
condition
- Only append a newline if this condition is true.IOException
- If an I/O error occurs.public StyleAppendable indent()
newline()
or newlineIf(boolean)
are
called.public StyleAppendable indentIf(boolean condition)
newline()
or newlineIf(boolean)
are called.condition
- Only increase the indentation level if this condition is true.public StyleAppendable unindent()
public StyleAppendable unindentIf(boolean condition)
condition
- Only decrease the indentation level if this condition is true.public int indentationLevel()
Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.