org.apache.struts.util
Class ServletContextWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by org.apache.struts.util.ServletContextWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

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: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) $

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.
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
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(boolean b)
          Print a boolean value.
 void print(char c)
          Print a character value.
 void print(char[] c)
          Print a character array.
 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 print(Object o)
          Print an object.
 void print(String s)
          Print a String value.
 void println()
          Terminate the current line and flush the buffer.
 void println(boolean b)
          Print a boolean value and terminate the line.
 void println(char c)
          Print a character value and terminate the line.
 void println(char[] c)
          Print a character array 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 println(Object o)
          Print an object and terminate the line.
 void println(String s)
          Print a String value and terminate the line.
 void setError()
          Set the error state for this stream.
 void write(char c)
          Write a single character to this stream.
 void write(char[] buf)
          Write an array of charaters to this stream.
 void write(char[] buf, int off, int len)
          Write the specified subset of an array of characters to this stream.
 void write(int c)
          Write a single character to 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.
 
Methods inherited from class java.io.PrintWriter
append, append, append, clearError, format, format, printf, printf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

Overrides:
checkError in class PrintWriter

close

public void close()
Close the stream.

Specified by:
close in interface Closeable
Overrides:
close in class PrintWriter

flush

public void flush()
Flush the stream.

Specified by:
flush in interface Flushable
Overrides:
flush in class PrintWriter

print

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

Overrides:
print in class PrintWriter
Parameters:
b - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
c - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
c - The character array to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
d - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
f - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
i - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
l - The value to be printed

print

public void print(Object o)
Print an object.

Overrides:
print in class PrintWriter
Parameters:
o - The value to be printed

print

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

Overrides:
print in class PrintWriter
Parameters:
s - The value to be printed

println

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

Overrides:
println in class PrintWriter

println

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

Overrides:
println in class PrintWriter
Parameters:
b - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
c - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
c - The character array to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
d - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
f - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
i - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
l - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
o - The value to be printed

println

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

Overrides:
println in class PrintWriter
Parameters:
s - The value to be printed

setError

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

Overrides:
setError in class PrintWriter

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.

Overrides:
write in class PrintWriter
Parameters:
c - The character to be written

write

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

Overrides:
write in class PrintWriter
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.

Overrides:
write in class PrintWriter
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.

Overrides:
write in class PrintWriter
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.

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


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