org.apache.struts.util

Class ServletContextWriter

public class ServletContextWriter extends PrintWriter

A PrintWriter implementation that uses the logging facilities of a javax.servlet.ServletContext to output its results. Output will be buffered until a newline character is output, flush() is called, or until one of the println() methods is called. Along the way, carriage return characters are skipped.

Version: $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $

Field Summary
protected StringBufferbuffer
The buffer into which we accumulate lines to be logged.
protected ServletContextcontext
The servlet context with which we are associated.
protected booleanerror
The error state for this stream.
Constructor Summary
ServletContextWriter(ServletContext context)
Construct a ServletContextWriter associated with the specified ServletContext instance.
Method Summary
booleancheckError()
Flush the stream and check for its error state.
voidclose()
Close the stream.
voidflush()
Flush the stream.
voidprint(boolean b)
Print a boolean value.
voidprint(char c)
Print a character value.
voidprint(char[] c)
Print a character array.
voidprint(double d)
Print a double value.
voidprint(float f)
Print a float value.
voidprint(int i)
Print an integer value.
voidprint(long l)
Print a long value.
voidprint(Object o)
Print an object.
voidprint(String s)
Print a String value.
voidprintln()
Terminate the current line and flush the buffer.
voidprintln(boolean b)
Print a boolean value and terminate the line.
voidprintln(char c)
Print a character value and terminate the line.
voidprintln(char[] c)
Print a character array and terminate the line.
voidprintln(double d)
Print a double value and terminate the line.
voidprintln(float f)
Print a float value and terminate the line.
voidprintln(int i)
Print an integer value and terminate the line.
voidprintln(long l)
Print a long value and terminate the line.
voidprintln(Object o)
Print an object and terminate the line.
voidprintln(String s)
Print a String value and terminate the line.
voidsetError()
Set the error state for this stream.
voidwrite(char c)
Write a single character to this stream.
voidwrite(int c)
Write a single character to this stream.
voidwrite(char[] buf)
Write an array of charaters to this stream.
voidwrite(char[] buf, int off, int len)
Write the specified subset of an array of characters to this stream.
voidwrite(String s)
Write a String to this stream.
voidwrite(String s, int off, int len)
Write the specified portion of a String to this stream.

Field Detail

buffer

protected StringBuffer buffer
The buffer into which we accumulate lines to be logged.

context

protected ServletContext context
The servlet context with which we are associated.

error

protected boolean error
The error state for this stream.

Constructor Detail

ServletContextWriter

public ServletContextWriter(ServletContext context)
Construct a ServletContextWriter associated with the specified ServletContext instance.

Parameters: context The associated servlet context

Method Detail

checkError

public boolean checkError()
Flush the stream and check for its error state. IMPLEMENTATION NOTE - our associated servlet context gives no indication of problems with logging, so the only way this method will return true is if setError() is called.

close

public void close()
Close the stream.

flush

public void flush()
Flush the stream.

print

public void print(boolean b)
Print a boolean value.

Parameters: b The value to be printed

print

public void print(char c)
Print a character value.

Parameters: c The value to be printed

print

public void print(char[] c)
Print a character array.

Parameters: c The character array to be printed

print

public void print(double d)
Print a double value.

Parameters: d The value to be printed

print

public void print(float f)
Print a float value.

Parameters: f The value to be printed

print

public void print(int i)
Print an integer value.

Parameters: i The value to be printed

print

public void print(long l)
Print a long value.

Parameters: l The value to be printed

print

public void print(Object o)
Print an object.

Parameters: o The value to be printed

print

public void print(String s)
Print a String value.

Parameters: s The value to be printed

println

public void println()
Terminate the current line and flush the buffer.

println

public void println(boolean b)
Print a boolean value and terminate the line.

Parameters: b The value to be printed

println

public void println(char c)
Print a character value and terminate the line.

Parameters: c The value to be printed

println

public void println(char[] c)
Print a character array and terminate the line.

Parameters: c The character array to be printed

println

public void println(double d)
Print a double value and terminate the line.

Parameters: d The value to be printed

println

public void println(float f)
Print a float value and terminate the line.

Parameters: f The value to be printed

println

public void println(int i)
Print an integer value and terminate the line.

Parameters: i The value to be printed

println

public void println(long l)
Print a long value and terminate the line.

Parameters: l The value to be printed

println

public void println(Object o)
Print an object and terminate the line.

Parameters: o The value to be printed

println

public void println(String s)
Print a String value and terminate the line.

Parameters: s The value to be printed

setError

public void setError()
Set the error state for this stream.

write

public void write(char c)
Write a single character to this stream.

Parameters: c The character to be written

write

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

Parameters: c The character to be written

write

public void write(char[] buf)
Write an array of charaters to this stream.

Parameters: buf The character array to be written

write

public void write(char[] buf, int off, int len)
Write the specified subset of an array of characters to this stream.

Parameters: buf The character array from which to write off The zero-relative starting offset to write len The number of characters to write

write

public void write(String s)
Write a String to this stream.

Parameters: s The string to be written

write

public void write(String s, int off, int len)
Write the specified portion of a String to this stream.

Parameters: s The String from which to write off The zero-relative starting offset to write len The number of characters to write

Copyright B) 2000-2008 - The Apache Software Foundation