final class WriteBehindStateWriter
extends java.io.Writer
Writer
to efficiently handle the state manager replacement
marker written out by MultiViewHandler.writeState(javax.faces.context.FacesContext)
.Modifier and Type | Field and Description |
---|---|
private char[] |
buf |
private int |
bufSize |
private javax.faces.context.FacesContext |
context |
private static java.lang.ThreadLocal<WriteBehindStateWriter> |
CUR_WRITER |
private FastStringWriter |
fWriter |
private java.io.Writer |
orig |
private java.io.Writer |
out |
private java.lang.Object |
state |
private static int |
STATE_MARKER_LEN |
private boolean |
stateWritten |
Constructor and Description |
---|
WriteBehindStateWriter(java.io.Writer out,
javax.faces.context.FacesContext context,
int bufSize)
Constructs a new
WriteBehindStateWriter instance. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This is a no-op.
|
void |
flush()
This is a no-op.
|
void |
flushToWriter()
Write directly from our FastStringWriter to the provided writer.
|
static WriteBehindStateWriter |
getCurrentInstance() |
private static int |
getNextDelimiterIndex(java.lang.StringBuilder builder,
int offset) |
private java.lang.StringBuilder |
getState(javax.faces.application.StateManager stateManager,
javax.faces.context.ResponseWriter origWriter)
Get the state.
|
void |
release()
Clear the ThreadLocal state.
|
boolean |
stateWritten() |
void |
write(char[] cbuf)
Writes directly to the current
out . |
void |
write(char[] cbuf,
int off,
int len)
Writes directly to the current
out . |
void |
write(int c)
Writes directly to the current
out . |
void |
write(java.lang.String str)
Writes directly to the current
out . |
void |
write(java.lang.String str,
int off,
int len)
Writes directly to the current
out . |
void |
writingState()
When called, the original writer is backed up and replaced
with a new FastStringWriter.
|
private static final int STATE_MARKER_LEN
private static final java.lang.ThreadLocal<WriteBehindStateWriter> CUR_WRITER
private java.io.Writer out
private java.io.Writer orig
private FastStringWriter fWriter
private boolean stateWritten
private int bufSize
private char[] buf
private javax.faces.context.FacesContext context
private java.lang.Object state
public WriteBehindStateWriter(java.io.Writer out, javax.faces.context.FacesContext context, int bufSize)
WriteBehindStateWriter
instance.out
- the writer we write non-buffered content tocontext
- the FacesContext
for the current requestbufSize
- the buffer size for post-processing buffered contentpublic void write(int c) throws java.io.IOException
out
.write
in class java.io.Writer
java.io.IOException
Writer.write(int)
public void write(char[] cbuf) throws java.io.IOException
out
.write
in class java.io.Writer
java.io.IOException
Writer.write(char[])
public void write(java.lang.String str) throws java.io.IOException
out
.write
in class java.io.Writer
java.io.IOException
Writer.write(String)
public void write(java.lang.String str, int off, int len) throws java.io.IOException
out
.write
in class java.io.Writer
java.io.IOException
Writer.write(String, int, int)
public void write(char[] cbuf, int off, int len) throws java.io.IOException
out
.write
in class java.io.Writer
java.io.IOException
Writer.write(char[], int, int)
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
public static WriteBehindStateWriter getCurrentInstance()
WriteBehindStateWriter
being used for processing
this requestpublic void release()
public void writingState()
public boolean stateWritten()
true
if writingState()
has been called,
otherwise returns false
public void flushToWriter() throws java.io.IOException
Write directly from our FastStringWriter to the provided writer.
java.io.IOException
- if an error occursprivate java.lang.StringBuilder getState(javax.faces.application.StateManager stateManager, javax.faces.context.ResponseWriter origWriter) throws java.io.IOException
In JSF 2.2 it is required by the specification that the view state hidden input in each h:form has a unique id. So we have to call this method multiple times as each h:form needs to generate the element id for itself.
stateManager
- the state manager.origWriter
- the original response writer.java.io.IOException
- when an I/O error occurs.private static int getNextDelimiterIndex(java.lang.StringBuilder builder, int offset)
builder
- buffered contentoffset
- the offset to start the search fromCopyright © 2002-2013 Oracle America, Inc. All Rights Reserved.