|
|||||||||
| Home >> All >> com >> sun >> [ facelets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.sun.facelets
Class StateWriter

java.lang.Objectjava.io.Writer
com.sun.facelets.StateWriter
- final class StateWriter
- extends java.io.Writer
A class for handling state insertion. Content is written directly to "out" until an attempt to write state; at that point, it's redirected into a buffer that can be picked through in theory, this buffer should be very small, since it only needs to be enough to contain all the content after the close of the first (and, hopefully, only) form.
Potential optimizations:
- If we created a new FastWriter at each call to writingState(), and stored a List of them, then we'd know that state tokens could only possibly be near the start of each buffer (and might not be there at all). (There might be a close-element before the state token). Then, we'd only need to check the start of the buffer for the state token; if it's there, write out the real state, then blast the rest of the buffer out. This wouldn't even require toString(), which for large buffers is expensive. However, this optimization is only going to be especially meaningful for the multi-form case.
- More of a FastWriter optimization than a StateWriter, but: it is far faster to create a set of small 1K buffers than constantly reallocating one big buffer.
- Version:
- $Id: StateWriter.java,v 1.1 2006/04/12 05:50:45 adamwiner Exp $
| Field Summary | |
private static java.lang.ThreadLocal |
CURRENT_WRITER
|
private com.sun.facelets.util.FastWriter |
fast
|
private int |
initialSize
|
private java.io.Writer |
out
|
private boolean |
writtenState
|
| Fields inherited from class java.io.Writer |
lock |
| Constructor Summary | |
StateWriter(java.io.Writer initialOut,
int initialSize)
|
|
| Method Summary | |
void |
close()
This method closes the stream. |
void |
flush()
This method forces any data that may have been buffered to be written to the underlying output device. |
java.lang.String |
getAndResetBuffer()
|
static StateWriter |
getCurrentInstance()
|
boolean |
isStateWritten()
|
void |
release()
|
void |
write(char[] cbuf)
This method all the writes char from the passed array to the output stream. |
void |
write(char[] cbuf,
int off,
int len)
This method writes len char from the specified array
buf starting at index offset into the array. |
void |
write(int c)
This method writes a single char to the output stream. |
void |
write(java.lang.String str)
This method writes all the characters in a String to the
output. |
void |
write(java.lang.String str,
int off,
int len)
This method writes len chars from the String
starting at position offset. |
void |
writingState()
Mark that state is about to be written. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
initialSize
private int initialSize
out
private java.io.Writer out
fast
private com.sun.facelets.util.FastWriter fast
writtenState
private boolean writtenState
CURRENT_WRITER
private static final java.lang.ThreadLocal CURRENT_WRITER
| Constructor Detail |
StateWriter
public StateWriter(java.io.Writer initialOut, int initialSize)
| Method Detail |
getCurrentInstance
public static StateWriter getCurrentInstance()
writingState
public void writingState()
- Mark that state is about to be written. Contrary to what you'd expect,
we cannot and should not assume that this location is really going
to have state; it is perfectly legit to have a ResponseWriter that
filters out content, and ignores an attempt to write out state
at this point. So, we have to check after the fact to see
if there really are state markers.
isStateWritten
public boolean isStateWritten()
close
public void close()
throws java.io.IOException
- Description copied from class:
java.io.Writer - This method closes the stream. Any internal or native resources
associated
with this stream are freed. Any subsequent attempt to access the stream
might throw an exception.
This method in this class does nothing.
flush
public void flush()
throws java.io.IOException
- Description copied from class:
java.io.Writer - This method forces any data that may have been buffered to be written
to the underlying output device. Please note that the host environment
might perform its own buffering unbeknowst to Java. In that case, a
write made (for example, to a disk drive) might be cached in OS
buffers instead of actually being written to disk.
write
public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
- Description copied from class:
java.io.Writer - This method writes
lenchar from the specified arraybufstarting at indexoffsetinto the array.Subclasses must provide an implementation of this abstract method.
write
public void write(char[] cbuf)
throws java.io.IOException
- Description copied from class:
java.io.Writer - This method all the writes char from the passed array to the output
stream. This method is equivalent to
write(buf, 0, buf.length)which is exactly how it is implemented in this class.
write
public void write(int c)
throws java.io.IOException
- Description copied from class:
java.io.Writer - This method writes a single char to the output stream.
write
public void write(java.lang.String str, int off, int len) throws java.io.IOException
- Description copied from class:
java.io.Writer - This method writes
lenchars from theStringstarting at positionoffset.
write
public void write(java.lang.String str) throws java.io.IOException
- Description copied from class:
java.io.Writer - This method writes all the characters in a
Stringto the output.
getAndResetBuffer
public java.lang.String getAndResetBuffer()
release
public void release()
|
|||||||||
| Home >> All >> com >> sun >> [ facelets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC