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 StringBuffer
buffer
The buffer into which we accumulate lines to be logged.
protected ServletContext
context
The servlet context with which we are associated.
protected boolean
error
The error state for this stream.

Constructor Summary

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

Method Summary

boolean
checkError()
Flush the stream and check for its error state.
void
close()
Close the stream.
void
flush()
Flush the stream.
void
print(Object o)
Print an object.
void
print(String s)
Print a String value.
void
print(boolean b)
Print a boolean value.
void
print(c[] )
Print a character array.
void
print(char c)
Print a character value.
void
print(double d)
Print a double value.
void
print(float f)
Print a float value.
void
print(int i)
Print an integer value.
void
print(long l)
Print a long value.
void
println()
Terminate the current line and flush the buffer.
void
println(Object o)
Print an object and terminate the line.
void
println(String s)
Print a String value and terminate the line.
void
println(boolean b)
Print a boolean value and terminate the line.
void
println(c[] )
Print a character array and terminate the line.
void
println(char c)
Print a character value and terminate the line.
void
println(double d)
Print a double value and terminate the line.
void
println(float f)
Print a float value and terminate the line.
void
println(int i)
Print an integer value and terminate the line.
void
println(long l)
Print a long value and terminate the line.
void
setError()
Set the error state for this stream.
void
write(String s)
Write a String to this stream.
void
write(String s, int off, int len)
Write the specified portion of a String to this stream.
void
write(buf[] )
Write an array of charaters to this stream.
void
write(buf[] , int off, int len)
Write the specified subset of an array of characters to this stream.
void
write(char c)
Write a single character to this stream.
void
write(int c)
Write a single character to this stream.

Field Details

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 Details

ServletContextWriter

public ServletContextWriter(ServletContext context)
Construct a ServletContextWriter associated with the specified ServletContext instance.
Parameters:
context - The associated servlet context

Method Details

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(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

print

public void print(boolean b)
Print a boolean value.
Parameters:
b - The value to be printed

print

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

print

public void print(char c)
Print a character value.
Parameters:
c - The value 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

println

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

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

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(c[] )
Print a character array and terminate the line.
Parameters:

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(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

setError

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

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

write

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

write

public void write(buf[] ,
                  int off,
                  int len)
Write the specified subset of an array of characters to this stream.
Parameters:
off - The zero-relative starting offset to write
len - The number of characters to write

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

Copyright B) 2000-2007 - The Apache Software Foundation