|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
org.webmacro.FastWriter
FastWriter attempts to optimize output speed in a WebMacro template through several specific optimizations:
Note that the FastWriter requires an explicit flush
If you re-use a FastWriter you must re-use it in a context which uses the SAME unicode conversion. The caches and internal data structures which the FastWriter allocates are tied to the encoding it was created with.
Field Summary | |
static java.lang.String |
SAFE_UNICODE_ENCODING
This encoding is either UTF16-BE or, if the platform does not support it, UTF8. |
Fields inherited from class java.io.Writer |
lock |
Constructor Summary | |
FastWriter(Broker broker,
java.io.OutputStream out,
java.lang.String encoding)
Create a FastWriter to the target outputstream. |
|
FastWriter(Broker broker,
java.lang.String encoding)
Create a new FastWriter with no output stream target. |
Method Summary | |
void |
bflush()
|
void |
close()
Return the FastWriter to the queue for later re-use. |
void |
flush()
Flush all data out to the OutputStream, if any, clearing the internal buffers. |
boolean |
getAsciiHack()
Returns true if we are mangling the unicode conversion in an attempt to eek out a bit of extra efficiency. |
Encoder |
getEncoder()
Get the encoder used by this FastWriter to transform char[] data into byte[] data. |
java.lang.String |
getEncoding()
Get the character encoding this FastWriter uses to convert characters to byte[] |
static FastWriter |
getInstance(Broker broker)
Return a FastWriter with default encoding and no output stream. |
static FastWriter |
getInstance(Broker broker,
java.io.OutputStream out,
java.lang.String encoding)
Get a new FastWriter. |
static FastWriter |
getInstance(Broker broker,
java.lang.String encoding)
Return a FastWriter with the specified encoding and no output stream. |
java.io.OutputStream |
getOutputStream()
Get the output stream this FastWriter sends output to. |
void |
reset(java.io.OutputStream out)
Reset the fastwriter, clearing any contents that have been generated so far. |
void |
setAsciiHack(boolean on)
Ordinarily an expensive char-to-byte routine is used to convert strings and char[]'s to byte format. |
int |
size()
Return the number of bytes that would be written out if flush() is called. |
byte[] |
toByteArray()
Copy the contents written so far into a byte array. |
java.lang.String |
toString()
Copy the contents written so far into a String. |
void |
write(byte[] rawBytes)
Write raw bytes to the underlying stream. |
void |
write(byte[] rawBytes,
int offset,
int len)
Write raw bytes to the underlying stream. |
void |
write(char[] cbuf)
Write characters to the output stream performing slow unicode conversion unless AsciiHack is on. |
void |
write(char[] cbuf,
int offset,
int len)
Write characters to to the output stream performing slow unicode conversion unless the AsciiHack is on. |
void |
write(int c)
Write a single character, performing slow unicode conversion unless AsciiHack is on. |
void |
write(java.lang.String s)
Write a string to the underlying output stream, performing unicode conversion. |
void |
write(java.lang.String s,
int off,
int len)
|
void |
writeStatic(java.lang.String s)
Write a string to the underlying output stream, performing unicode conversion if necessary--try and read the encoding from an encoding cache if possible. |
void |
writeTo(java.io.OutputStream out)
Copy the contents written so far to the suppiled output stream |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String SAFE_UNICODE_ENCODING
Constructor Detail |
public FastWriter(Broker broker, java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
public FastWriter(Broker broker, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Method Detail |
public java.lang.String getEncoding()
public Encoder getEncoder()
public java.io.OutputStream getOutputStream()
public void setAsciiHack(boolean on)
public boolean getAsciiHack()
public void write(char[] cbuf) throws java.io.IOException
java.io.IOException
public void write(char[] cbuf, int offset, int len) throws java.io.IOException
java.io.IOException
public void write(int c) throws java.io.IOException
java.io.IOException
public void write(java.lang.String s) throws java.io.IOException
java.io.IOException
public void write(java.lang.String s, int off, int len) throws java.io.IOException
java.io.IOException
public void writeStatic(java.lang.String s)
public void write(byte[] rawBytes)
public void write(byte[] rawBytes, int offset, int len)
public void bflush()
public void flush() throws java.io.IOException
java.io.IOException
public int size() throws java.io.IOException
java.io.IOException
public byte[] toByteArray()
public java.lang.String toString()
public void writeTo(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public void reset(java.io.OutputStream out)
public static FastWriter getInstance(Broker broker, java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static FastWriter getInstance(Broker broker, java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static FastWriter getInstance(Broker broker)
public void close() throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |