Package org.apache.struts.util
Class ServletContextWriter
java.lang.Object
java.io.Writer
java.io.PrintWriter
org.apache.struts.util.ServletContextWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
A PrintWriter implementation that uses the logging facilities of a
jakarta.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$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBufferThe buffer into which we accumulate lines to be logged.protected ServletContextThe servlet context with which we are associated.protected booleanThe error state for this stream.Fields inherited from class java.io.PrintWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionServletContextWriter(ServletContext context) Construct a ServletContextWriter associated with the specified ServletContext instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanFlush 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 an object.voidPrint 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.voidPrint an object and terminate the line.voidPrint 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(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(int c) Write a single character to this stream.voidWrite a String to this stream.voidWrite the specified portion of a String to this stream.Methods inherited from class java.io.PrintWriter
append, append, append, clearError, format, format, printf, printfMethods inherited from class java.io.Writer
nullWriter
-
Field Details
-
buffer
The buffer into which we accumulate lines to be logged. -
context
The servlet context with which we are associated. -
error
protected boolean errorThe error state for this stream.
-
-
Constructor Details
-
ServletContextWriter
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 returntrueis ifsetError()is called.- Overrides:
checkErrorin classPrintWriter
-
close
public void close()Close the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classPrintWriter
-
flush
public void flush()Flush the stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classPrintWriter
-
print
public void print(boolean b) Print a boolean value.- Overrides:
printin classPrintWriter- Parameters:
b- The value to be printed
-
print
public void print(char c) Print a character value.- Overrides:
printin classPrintWriter- Parameters:
c- The value to be printed
-
print
public void print(char[] c) Print a character array.- Overrides:
printin classPrintWriter- Parameters:
c- The character array to be printed
-
print
public void print(double d) Print a double value.- Overrides:
printin classPrintWriter- Parameters:
d- The value to be printed
-
print
public void print(float f) Print a float value.- Overrides:
printin classPrintWriter- Parameters:
f- The value to be printed
-
print
public void print(int i) Print an integer value.- Overrides:
printin classPrintWriter- Parameters:
i- The value to be printed
-
print
public void print(long l) Print a long value.- Overrides:
printin classPrintWriter- Parameters:
l- The value to be printed
-
print
Print an object.- Overrides:
printin classPrintWriter- Parameters:
o- The value to be printed
-
print
Print a String value.- Overrides:
printin classPrintWriter- Parameters:
s- The value to be printed
-
println
public void println()Terminate the current line and flush the buffer.- Overrides:
printlnin classPrintWriter
-
println
public void println(boolean b) Print a boolean value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
b- The value to be printed
-
println
public void println(char c) Print a character value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
c- The value to be printed
-
println
public void println(char[] c) Print a character array and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
c- The character array to be printed
-
println
public void println(double d) Print a double value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
d- The value to be printed
-
println
public void println(float f) Print a float value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
f- The value to be printed
-
println
public void println(int i) Print an integer value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
i- The value to be printed
-
println
public void println(long l) Print a long value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
l- The value to be printed
-
println
Print an object and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
o- The value to be printed
-
println
Print a String value and terminate the line.- Overrides:
printlnin classPrintWriter- Parameters:
s- The value to be printed
-
setError
public void setError()Set the error state for this stream.- Overrides:
setErrorin classPrintWriter
-
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:
writein classPrintWriter- Parameters:
c- The character to be written
-
write
public void write(char[] buf) Write an array of charaters to this stream.- Overrides:
writein classPrintWriter- 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:
writein classPrintWriter- Parameters:
buf- The character array from which to writeoff- The zero-relative starting offset to writelen- The number of characters to write
-
write
Write a String to this stream.- Overrides:
writein classPrintWriter- Parameters:
s- The string to be written
-
write
Write the specified portion of a String to this stream.- Overrides:
writein classPrintWriter- Parameters:
s- The String from which to writeoff- The zero-relative starting offset to writelen- The number of characters to write
-