java.lang.Object
gg.jte.output.Utf8ByteOutput
- All Implemented Interfaces:
TemplateOutput
UTF-8 template output, designed to be CPU and memory friendly.
You may want to use this class, if you write to a low-level binary output stream, and you need the exact content-size of the output.
CAUTION: You must enable
TemplateEngine.setBinaryStaticContent(boolean), otherwise this class won't provide any benefits over StringOutput!-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbyte[]voidwriteBinaryContent(byte[] value) voidvoidwriteContent(String s, int beginIndex, int endIndex) voidwriteTo(Utf8ByteOutput.DataConsumer dataConsumer) Passes all collected bytes to the given data consumer.voidwriteTo(OutputStream os) Passes all collected bytes to the given output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gg.jte.TemplateOutput
writeUnsafeContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent, writeUserContent
-
Constructor Details
-
Utf8ByteOutput
public Utf8ByteOutput() -
Utf8ByteOutput
public Utf8ByteOutput(int initialCapacity)
-
-
Method Details
-
getContentLength
public int getContentLength()- Returns:
- The amount of bytes written to this output.
-
writeTo
Passes all collected bytes to the given output stream. Does not close the stream.- Parameters:
os- the output stream- Throws:
IOException- in case the stream operation fails
-
writeTo
Passes all collected bytes to the given data consumer. CAUTION: For performance reasons no copy of the byte arrays is made. It is the consumer's duty to never alter their content!- Parameters:
dataConsumer- the data consumer- Throws:
IOException- in case the consume operation fails
-
toByteArray
public byte[] toByteArray() -
writeContent
- Specified by:
writeContentin interfaceTemplateOutput
-
writeContent
- Specified by:
writeContentin interfaceTemplateOutput
-
writeBinaryContent
public void writeBinaryContent(byte[] value) - Specified by:
writeBinaryContentin interfaceTemplateOutput
-