org.apache.jasper.runtime

Class BodyContentImpl

public class BodyContentImpl extends BodyContent

Write text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings. Provide support for discarding for the output that has been buffered.

Author: Rajiv Mordani Jan Luehe

Constructor Summary
BodyContentImpl(JspWriter enclosingWriter)
Constructor.
Method Summary
voidclear()
Clear the contents of the buffer.
voidclearBuffer()
Clears the current contents of the buffer.
voidclose()
Close the stream, flushing it first.
intgetBufferSize()
This method returns the size of the buffer used by the JspWriter.
ReadergetReader()
Return the value of this BodyJspWriter as a Reader.
intgetRemaining()
StringgetString()
Return the value of the BodyJspWriter as a String.
voidnewLine()
Write a line separator.
voidprint(boolean b)
Print a boolean value.
voidprint(char c)
Print a character.
voidprint(int i)
Print an integer.
voidprint(long l)
Print a long integer.
voidprint(float f)
Print a floating-point number.
voidprint(double d)
Print a double-precision floating-point number.
voidprint(char[] s)
Print an array of characters.
voidprint(String s)
Print a string.
voidprint(Object obj)
Print an object.
voidprintln()
Terminate the current line by writing the line separator string.
voidprintln(boolean x)
Print a boolean value and then terminate the line.
voidprintln(char x)
Print a character and then terminate the line.
voidprintln(int x)
Print an integer and then terminate the line.
voidprintln(long x)
Print a long integer and then terminate the line.
voidprintln(float x)
Print a floating-point number and then terminate the line.
voidprintln(double x)
Print a double-precision floating-point number and then terminate the line.
voidprintln(char[] x)
Print an array of characters and then terminate the line.
voidprintln(String x)
Print a String and then terminate the line.
voidprintln(Object x)
Print an Object and then terminate the line.
voidwrite(int c)
Write a single character.
voidwrite(char[] cbuf, int off, int len)
Write a portion of an array of characters.
voidwrite(char[] buf)
Write an array of characters.
voidwrite(String s, int off, int len)
Write a portion of a String.
voidwrite(String s)
Write a string.
voidwriteOut(Writer out)
Write the contents of this BodyJspWriter into a Writer.

Constructor Detail

BodyContentImpl

public BodyContentImpl(JspWriter enclosingWriter)
Constructor.

Method Detail

clear

public void clear()
Clear the contents of the buffer. If the buffer has been already been flushed then the clear operation shall throw an IOException to signal the fact that some data has already been irrevocably written to the client response stream.

Throws: IOException If an I/O error occurs

clearBuffer

public void clearBuffer()
Clears the current contents of the buffer. Unlike clear(), this mehtod will not throw an IOException if the buffer has already been flushed. It merely clears the current content of the buffer and returns.

Throws: IOException If an I/O error occurs

close

public void close()
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.

Throws: IOException If an I/O error occurs

getBufferSize

public int getBufferSize()
This method returns the size of the buffer used by the JspWriter.

Returns: the size of the buffer in bytes, or 0 is unbuffered.

getReader

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

Returns: the value of this BodyJspWriter as a Reader

getRemaining

public int getRemaining()

Returns: the number of bytes unused in the buffer

getString

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

Returns: the value of the BodyJspWriter as a String

newLine

public void newLine()
Write a line separator. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.

Throws: IOException If an I/O error occurs

print

public void print(boolean b)
Print a boolean value. The string produced by java.lang.String#valueOf(boolean) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: b The boolean to be printed

Throws: IOException

print

public void print(char c)
Print a character. The character is translated into one or more bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: c The char to be printed

Throws: IOException

print

public void print(int i)
Print an integer. The string produced by java.lang.String#valueOf(int) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: i The int to be printed

Throws: IOException

print

public void print(long l)
Print a long integer. The string produced by java.lang.String#valueOf(long) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: l The long to be printed

Throws: IOException

print

public void print(float f)
Print a floating-point number. The string produced by java.lang.String#valueOf(float) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: f The float to be printed

Throws: IOException

print

public void print(double d)
Print a double-precision floating-point number. The string produced by java.lang.String#valueOf(double) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: d The double to be printed

Throws: IOException

print

public void print(char[] s)
Print an array of characters. The characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: s The array of chars to be printed

Throws: NullPointerException If s is null IOException

print

public void print(String s)
Print a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: s The String to be printed

Throws: IOException

print

public void print(Object obj)
Print an object. The string produced by the java.lang.String#valueOf(Object) method is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the BodyContentImpl method.

Parameters: obj The Object to be printed

Throws: IOException

println

public void println()
Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').

Throws: IOException

println

public void println(boolean x)
Print a boolean value and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(char x)
Print a character and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(int x)
Print an integer and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(long x)
Print a long integer and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(float x)
Print a floating-point number and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(double x)
Print a double-precision floating-point number and then terminate the line. This method behaves as though it invokes BodyContentImpl and then println.

Throws: IOException

println

public void println(char[] x)
Print an array of characters and then terminate the line. This method behaves as though it invokes (char[]) and then println.

Throws: IOException

println

public void println(String x)
Print a String and then terminate the line. This method behaves as though it invokes print and then println.

Throws: IOException

println

public void println(Object x)
Print an Object and then terminate the line. This method behaves as though it invokes print and then println.

Throws: IOException

write

public void write(int c)
Write a single character.

write

public void write(char[] cbuf, int off, int len)
Write a portion of an array of characters.

Ordinarily this method stores characters from the given array into this stream's buffer, flushing the buffer to the underlying stream as needed. If the requested length is at least as large as the buffer, however, then this method will flush the buffer and write the characters directly to the underlying stream. Thus redundant DiscardableBufferedWriters will not copy data unnecessarily.

Parameters: cbuf A character array off Offset from which to start reading characters len Number of characters to write

write

public void write(char[] buf)
Write an array of characters. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

write

public void write(String s, int off, int len)
Write a portion of a String.

Parameters: s String to be written off Offset from which to start reading characters len Number of characters to be written

write

public void write(String s)
Write a string. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

writeOut

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

Parameters: out The writer into which to place the contents of this body evaluation

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.