org.springframework.extensions.surf.util
Class FakeBodyContent

java.lang.Object
  extended by java.io.Writer
      extended by javax.servlet.jsp.JspWriter
          extended by javax.servlet.jsp.tagext.BodyContent
              extended by org.springframework.extensions.surf.util.FakeBodyContent
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class FakeBodyContent
extends javax.servlet.jsp.tagext.BodyContent

Implementation of the JSP BodyContent class. BodyContent extends JspWriter to allow access to the underlying buffer. The buffer can be cleared, converted to a string, or read through a Reader. It also has the notion of an enclosed writer, which is in essence a parent BodyContent. Finally, it has a writeOut method which allows for efficiently writing its contents to its parent (or another writer).

Author:
muzquiano

Field Summary
 boolean unbounded
          The unbounded.
 
Fields inherited from class javax.servlet.jsp.JspWriter
autoFlush, bufferSize, DEFAULT_BUFFER, NO_BUFFER, UNBOUNDED_BUFFER
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
FakeBodyContent(javax.servlet.jsp.JspWriter encl)
          Instantiates a new fake body content.
 
Method Summary
 void clear()
          Clear the contents of the buffer, unless it was flushed.
 void clearBuffer()
          Clear the contents of the buffer.
 void close()
          Close is a no-op in BodyContent.
 void flush()
          Flush is a no-op in BodyContent, since you have to explicitly write its contents to the enclosing writer.
 javax.servlet.jsp.JspWriter getEnclosingWriter()
          Get the enclosing JspWriter.
 Reader getReader()
          Return the value of this BodyContent as a Reader.
 int getRemaining()
          Return remaining size in the buffer.
 String getString()
          Return the value of the BodyContent as a String.
 void newLine()
          Add a newline to the buffer.
 void print(boolean b)
           
 void print(char c)
           
 void print(char[] c)
           
 void print(double d)
           
 void print(float f)
           
 void print(int i)
           
 void print(long l)
           
 void print(Object o)
           
 void print(String s)
           
 void println()
           
 void println(boolean b)
           
 void println(char c)
           
 void println(char[] c)
           
 void println(double d)
           
 void println(float f)
           
 void println(int i)
           
 void println(long l)
           
 void println(Object o)
           
 void println(String s)
           
protected  void setEnclosingWriter(javax.servlet.jsp.JspWriter encl)
          Sets the enclosing writer.
 void write(char[] c, int off, int len)
          Write an array of characters to the buffer.
 void write(int i)
          Write the character represented by the integer i to the buffer.
 void write(String s)
          Write the String s to the buffer.
 void writeOut(Writer out)
          Write the contents of this BodyContent into a Writer.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyContent
clearBody
 
Methods inherited from class javax.servlet.jsp.JspWriter
getBufferSize, isAutoFlush
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unbounded

public boolean unbounded
The unbounded.

Constructor Detail

FakeBodyContent

public FakeBodyContent(javax.servlet.jsp.JspWriter encl)
Instantiates a new fake body content.

Parameters:
encl - the encl
Method Detail

write

public void write(String s)
           throws IOException
Write the String s to the buffer.

Overrides:
write in class Writer
Parameters:
s - the s
Throws:
IOException - Signals that an I/O exception has occurred.

write

public void write(int i)
           throws IOException
Write the character represented by the integer i to the buffer.

Overrides:
write in class Writer
Parameters:
i - the i
Throws:
IOException - Signals that an I/O exception has occurred.

write

public void write(char[] c,
                  int off,
                  int len)
           throws IOException
Write an array of characters to the buffer.

Specified by:
write in class Writer
Parameters:
c - the c
off - the off
len - the len
Throws:
IOException - Signals that an I/O exception has occurred.

print

public void print(char c)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(double d)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(boolean b)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(long l)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(float f)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(int i)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(Object o)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(char[] c)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

print

public void print(String s)
           throws IOException
Specified by:
print in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println()
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(String s)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(char c)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(char[] c)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(long l)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(int i)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(double d)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(float f)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(boolean b)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

println

public void println(Object o)
             throws IOException
Specified by:
println in class javax.servlet.jsp.JspWriter
Throws:
IOException

close

public void close()
           throws IOException
Close is a no-op in BodyContent.

Specified by:
close in interface Closeable
Specified by:
close in class javax.servlet.jsp.JspWriter
Throws:
IOException - Signals that an I/O exception has occurred.

flush

public void flush()
           throws IOException
Flush is a no-op in BodyContent, since you have to explicitly write its contents to the enclosing writer.

Specified by:
flush in interface Flushable
Overrides:
flush in class javax.servlet.jsp.tagext.BodyContent
Throws:
IOException - Signals that an I/O exception has occurred.

getRemaining

public int getRemaining()
Return remaining size in the buffer. This shouldn't be a concern, since this implementation always grows the buffer.

Specified by:
getRemaining in class javax.servlet.jsp.JspWriter
Returns:
the remaining

clear

public void clear()
           throws IOException
Clear the contents of the buffer, unless it was flushed.

Specified by:
clear in class javax.servlet.jsp.JspWriter
Throws:
IOException - Signals that an I/O exception has occurred.

clearBuffer

public void clearBuffer()
                 throws IOException
Clear the contents of the buffer.

Specified by:
clearBuffer in class javax.servlet.jsp.JspWriter
Throws:
IOException - Signals that an I/O exception has occurred.

newLine

public void newLine()
             throws IOException
Add a newline to the buffer.

Specified by:
newLine in class javax.servlet.jsp.JspWriter
Throws:
IOException - Signals that an I/O exception has occurred.

getReader

public Reader getReader()
Return the value of this BodyContent as a Reader. Note: this is after evaluation!! There are no scriptlets, etc in this stream.

Specified by:
getReader in class javax.servlet.jsp.tagext.BodyContent
Returns:
the value of this BodyContent as a Reader

getString

public String getString()
Return the value of the BodyContent as a String. Note: this is after evaluation!! There are no scriptlets, etc in this stream.

Specified by:
getString in class javax.servlet.jsp.tagext.BodyContent
Returns:
the value of the BodyContent as a String

writeOut

public void writeOut(Writer out)
              throws IOException
Write the contents of this BodyContent into a Writer. Subclasses are likely to do interesting things with the implementation so some things are extra efficient.

Specified by:
writeOut in class javax.servlet.jsp.tagext.BodyContent
Parameters:
out - The writer into which to place the contents of this body evaluation
Throws:
IOException - Signals that an I/O exception has occurred.

getEnclosingWriter

public javax.servlet.jsp.JspWriter getEnclosingWriter()
Get the enclosing JspWriter.

Overrides:
getEnclosingWriter in class javax.servlet.jsp.tagext.BodyContent
Returns:
the enclosing JspWriter passed at construction time

setEnclosingWriter

protected void setEnclosingWriter(javax.servlet.jsp.JspWriter encl)
Sets the enclosing writer.

Parameters:
encl - the new enclosing writer


Copyright © 2009 SpringSource, Inc. All Rights Reserved.