org.objectweb.util.monolog.wrapper.printwriter

Class PrintStreamImpl

Implemented Interfaces:
Loggable

public class PrintStreamImpl
extends PrintStream
implements Loggable

This class is a PrintStream wrapper. It exports the Printstream methods but fowards the message to a Logger. This implementation bufferizes the data when a print method is used. The buffer and the data are always written when a println method is used. No end of line are inserted by the println methods. A line is equals to a monolog message.

Author:
S.Chassande-Barrioz

Field Summary

protected String
currentLine
This field is the buffer which represents the current line.
protected int
level
protected Logger
logger
protected LoggerFactory
loggerFactory

Constructor Summary

PrintStreamImpl(Logger l)
It builds a PrintWriterImpl instance.
PrintStreamImpl(Logger l, int level)
It builds a PrintWriterImpl instance.

Method Summary

boolean
checkError()
Always retrieves 'false'
protected Object
clone()
Always throws a CloneNotSupportedException
void
close()
Do nothing
boolean
equals(Object o)
Compare the inner loggers
void
flush()
Do nothing
int
getLevel()
Retrieves the level of the messages
Logger
getLogger()
Retrieves the logger instance used
LoggerFactory
getLoggerFactory()
Retrieves the logger factory instance used
void
print(Object o)
Writes the Object value as a String in the buffer
void
print(String s)
Writes the String value in the buffer
void
print(boolean b)
Writes the boolean value in the buffer
void
print(char c)
Writes the char value in the buffer
void
print(char[] chars)
Writes the char[] value as a String in the buffer
void
print(double v)
Writes the double value in the buffer
void
print(float v)
Writes the float value in the buffer
void
print(int i)
Writes the int value in the buffer
void
print(long l)
Writes the long value in the buffer
void
println()
log the buffer
void
println(Object o)
1/ Write a object value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(String s)
1/ Write a String value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(boolean b)
1/ Write a boolean value in the buffer.
void
println(char c)
1/ Write a char value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(char[] chars)
1/ Write a char[] value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(double v)
1/ Write a double value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(float v)
1/ Write a float value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(int i)
1/ Write an int value in the buffer 2/ Log the buffer 3/ Clear the buffer
void
println(long l)
1/ Write a long value in the buffer 2/ Log the buffer 3/ Clear the buffer
protected void
setError()
Do nothing
void
setLevel(int level)
Changes the level of the messages
void
setLogger(Logger logger)
Assigns the logger instance to use
void
setLoggerFactory(LoggerFactory lf)
Assigns the logger factory instance to use
String
toString()
Call the toString() method over the inner logger
void
write(byte[] bytes)
Writes the byte[] as a string in the buffer
void
write(byte[] bytes, int i, int i1)
Writes the byte[] as a string in the buffer
void
write(int i)
Writes the int value in the buffer

Field Details

currentLine

protected String currentLine
This field is the buffer which represents the current line.


level

protected int level


logger

protected Logger logger


loggerFactory

protected LoggerFactory loggerFactory

Constructor Details

PrintStreamImpl

public PrintStreamImpl(Logger l)
            throws NullPointerException
It builds a PrintWriterImpl instance. The default level is DEBUG

Parameters:
l - is the logger toward which the message must be send


PrintStreamImpl

public PrintStreamImpl(Logger l,
                       int level)
            throws NullPointerException
It builds a PrintWriterImpl instance. The default level is DEBUG

Parameters:
l - is the logger toward which the message must be send
level - is the level used to log message.

Method Details

checkError

public boolean checkError()
Always retrieves 'false'

Returns:


clone

protected Object clone()
            throws CloneNotSupportedException
Always throws a CloneNotSupportedException


close

public void close()
Do nothing


equals

public boolean equals(Object o)
Compare the inner loggers


flush

public void flush()
Do nothing


getLevel

public int getLevel()
Retrieves the level of the messages

Returns:
an int value representing the message priority (BasicLevel.XXXX)


getLogger

public Logger getLogger()
Retrieves the logger instance used
Specified by:
getLogger in interface Loggable


getLoggerFactory

public LoggerFactory getLoggerFactory()
Retrieves the logger factory instance used
Specified by:
getLoggerFactory in interface Loggable


print

public void print(Object o)
Writes the Object value as a String in the buffer


print

public void print(String s)
Writes the String value in the buffer


print

public void print(boolean b)
Writes the boolean value in the buffer


print

public void print(char c)
Writes the char value in the buffer


print

public void print(char[] chars)
Writes the char[] value as a String in the buffer


print

public void print(double v)
Writes the double value in the buffer


print

public void print(float v)
Writes the float value in the buffer


print

public void print(int i)
Writes the int value in the buffer


print

public void print(long l)
Writes the long value in the buffer


println

public void println()
log the buffer


println

public void println(Object o)
1/ Write a object value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(String s)
1/ Write a String value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(boolean b)
1/ Write a boolean value in the buffer. 2/ Log the buffer. 3/ Clear the buffer.


println

public void println(char c)
1/ Write a char value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(char[] chars)
1/ Write a char[] value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(double v)
1/ Write a double value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(float v)
1/ Write a float value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(int i)
1/ Write an int value in the buffer 2/ Log the buffer 3/ Clear the buffer


println

public void println(long l)
1/ Write a long value in the buffer 2/ Log the buffer 3/ Clear the buffer


setError

protected void setError()
Do nothing


setLevel

public void setLevel(int level)
Changes the level of the messages

Parameters:
level - is the new level


setLogger

public void setLogger(Logger logger)
Assigns the logger instance to use
Specified by:
setLogger in interface Loggable


setLoggerFactory

public void setLoggerFactory(LoggerFactory lf)
Assigns the logger factory instance to use
Specified by:
setLoggerFactory in interface Loggable


toString

public String toString()
Call the toString() method over the inner logger


write

public void write(byte[] bytes)
Writes the byte[] as a string in the buffer


write

public void write(byte[] bytes,
                  int i,
                  int i1)
Writes the byte[] as a string in the buffer


write

public void write(int i)
Writes the int value in the buffer