org.apache.myfaces.view.facelets
Class StateWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.apache.myfaces.view.facelets.StateWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public 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:

Version:
$Id: StateWriter.java,v 1.2 2008/07/13 19:01:40 rlubke Exp $
Author:
Adam Winer

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
StateWriter(java.io.Writer initialOut, int initialSize)
           
 
Method Summary
 void close()
           
 void flush()
           
 java.lang.String getAndResetBuffer()
           
static StateWriter getCurrentInstance()
           
 boolean isStateWritten()
           
 void release()
           
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 void write(java.lang.String str)
           
 void write(java.lang.String str, int off, int len)
           
 void writingState()
          Mark that state is about to be written.
 
Methods inherited from class java.io.Writer
append, append, append
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in class java.io.Writer
Throws:
java.io.IOException

write

public void write(char[] cbuf)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException

write

public void write(int c)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException

write

public void write(java.lang.String str,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException

write

public void write(java.lang.String str)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException

getAndResetBuffer

public java.lang.String getAndResetBuffer()

release

public void release()


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.