Package com.fizzed.rocker.runtime
Class ArrayOfByteArraysOutput
java.lang.Object
com.fizzed.rocker.runtime.AbstractRockerOutput<ArrayOfByteArraysOutput>
com.fizzed.rocker.runtime.ArrayOfByteArraysOutput
- All Implemented Interfaces:
RockerOutput<AbstractRockerOutput>
Output stores a list of references to byte arrays. Extremely optimized for
taking static byte arrays (e.g. plain text) and just saving a pointer to it
rather than copying it. Optimized for writing bytes vs. Strings. Strings are
converted to bytes using the specified charset on each write and then that
byte array is internally stored as part of the underlying list. Thus, the
output will consist of reused byte arrays as well as new ones when Strings
are written to this output.
-
Field Summary
FieldsFields inherited from class com.fizzed.rocker.runtime.AbstractRockerOutput
byteLength, charset, contentType -
Constructor Summary
ConstructorsConstructorDescriptionArrayOfByteArraysOutput(ContentType contentType, String charsetName) ArrayOfByteArraysOutput(ContentType contentType, Charset charset) -
Method Summary
Methods inherited from class com.fizzed.rocker.runtime.AbstractRockerOutput
getByteLength, getCharset, getContentType
-
Field Details
-
FACTORY
-
arrays
-
-
Constructor Details
-
ArrayOfByteArraysOutput
-
ArrayOfByteArraysOutput
-
-
Method Details
-
getArrays
-
w
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:
IOException- Thrown on exception.
-
w
- Throws:
IOException
-
toByteArray
public byte[] toByteArray()Expensive operation of allocating a byte array to hold the entire contents of this output and then copying each underlying byte array into this new byte array. Lots of memory copying...- Returns:
- A new byte array
-
toString
- Specified by:
toStringin interfaceRockerOutput<AbstractRockerOutput>- Overrides:
toStringin classObject
-
asReadableByteChannel
-
asInputStream
-