Package com.fizzed.rocker.runtime
Class StringBuilderOutput
- java.lang.Object
-
- com.fizzed.rocker.runtime.AbstractRockerOutput<StringBuilderOutput>
-
- com.fizzed.rocker.runtime.StringBuilderOutput
-
- All Implemented Interfaces:
RockerOutput<AbstractRockerOutput>
public class StringBuilderOutput extends AbstractRockerOutput<StringBuilderOutput>
Output that wraps anStringBuilder. Optimized for writing Strings vs. Bytes. Bytes are converted to Strings using the specified charset on each write.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilderbufferstatic RockerOutputFactory<StringBuilderOutput>FACTORY-
Fields inherited from class com.fizzed.rocker.runtime.AbstractRockerOutput
byteLength, charset, contentType
-
-
Constructor Summary
Constructors Constructor Description StringBuilderOutput(ContentType contentType, java.lang.String charsetName)StringBuilderOutput(ContentType contentType, java.lang.String charsetName, int intialSize)StringBuilderOutput(ContentType contentType, java.nio.charset.Charset charset)StringBuilderOutput(ContentType contentType, java.nio.charset.Charset charset, int intialSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuildergetBuffer()java.lang.StringtoString()StringBuilderOutputw(byte[] bytes)StringBuilderOutputw(java.lang.String string)Writes a String to the output.-
Methods inherited from class com.fizzed.rocker.runtime.AbstractRockerOutput
getByteLength, getCharset, getContentType
-
-
-
-
Field Detail
-
FACTORY
public static RockerOutputFactory<StringBuilderOutput> FACTORY
-
buffer
private final java.lang.StringBuilder buffer
-
-
Constructor Detail
-
StringBuilderOutput
public StringBuilderOutput(ContentType contentType, java.lang.String charsetName)
-
StringBuilderOutput
public StringBuilderOutput(ContentType contentType, java.lang.String charsetName, int intialSize)
-
StringBuilderOutput
public StringBuilderOutput(ContentType contentType, java.nio.charset.Charset charset)
-
StringBuilderOutput
public StringBuilderOutput(ContentType contentType, java.nio.charset.Charset charset, int intialSize)
-
-
Method Detail
-
getBuffer
public java.lang.StringBuilder getBuffer()
-
w
public StringBuilderOutput w(java.lang.String string) throws java.io.IOException
Description copied from interface:RockerOutputWrites a String to the output. Implementations are responsible for handling the conversion to the correct charset. Note that underlying implementations may be optimized to handle Strings vs. Bytes.- Parameters:
string- The string to write- Returns:
- This output (so builder pattern can be used)
- Throws:
java.io.IOException- Thrown on exception.
-
w
public StringBuilderOutput w(byte[] bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfaceRockerOutput<AbstractRockerOutput>- Overrides:
toStringin classjava.lang.Object
-
-