fr.umlv.tatoo.cc.common.log
Class Info

java.lang.Object
  extended by fr.umlv.tatoo.cc.common.log.Info

public final class Info
extends Object

Info is an inmutable/mutable class that gathers different informations in order to report them using a Reporter. Objects of this class are by default mutable but they can be sealed using seal() in order to make it not mutable. If an objet is sealed all mutable method will clone() the object before change it. This class act as a builder so method can be chained.

Author:
Remi

Constructor Summary
Info()
           
 
Method Summary
 Throwable cause()
          Returns the cause of the current info.
 Info cause(Throwable cause)
          Changes the cause of the current info.
 Info clone()
           
 int column()
          Returns the column number of the file associated with the current info.
 Info column(int column)
          Sets the column number of the file associated with the current info.
 Object[] data()
          Returns an array of datas used to format the message() of the current info.
 Info data(Object... data)
          Replaces or set the datas used to format the message().
static Info derive(Level level, Object... data)
          Creates a new info derived from the default info of the thread local reporter.
static Info derive(Level level, String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter.
static Info error(String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter with the level() Level.ERROR.
static Info fatalError(String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter with the level() Level.FATAL_ERROR.
 Object file()
          Returns the file associated with the current info.
 Info file(Object file)
          Changes the file associated with the current info.
static Info fine(String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter with the level() Level.INFO.
static Info info(String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter with the level() Level.FINE.
 boolean isSealed()
          Returns if the current object is sealed or not.
 Level level()
          Returns the level of the current info.
 Info level(Level level)
          Changes the level of the info.
 int line()
          Returns the line number of the file associated with the current info.
 Info line(int line)
          Sets the line number of the file associated with the current info.
 String message()
          Returns the message or the message of the cause of the current info.
 Info message(String message)
          Changes the message of the current info, this message can contains '%' that are resolved using String.format(String, Object[]).
 void report()
          Reports the current info using the thread local reporter.
 void seal()
          Seals the current Info.
 String toString()
           
static Info warning(String message, Object... data)
          Creates a new info derived from the default info of the thread local reporter with the level() Level.WARNING.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Info

public Info()
Method Detail

clone

public Info clone()
Overrides:
clone in class Object

level

public Level level()
Returns the level of the current info.

Returns:
the level of the current info.

level

public Info level(Level level)
Changes the level of the info. If the current info is sealed, a clone of the current object is returned.

Parameters:
level - the new level.
Returns:
an info with a new level.

data

public Object[] data()
Returns an array of datas used to format the message() of the current info.

Returns:
the data associated with the message of the current info.

data

public Info data(Object... data)
Replaces or set the datas used to format the message(). If the current info is sealed, a clone of the current object is returned.

Parameters:
data - the new data
Returns:
an info with the new data.

message

public String message()
Returns the message or the message of the cause of the current info.

Returns:
a message or the message of the cause if the message is null.

message

public Info message(String message)
Changes the message of the current info, this message can contains '%' that are resolved using String.format(String, Object[]). If the current info is sealed, a clone of the current object is returned.

Parameters:
message - the new message
Returns:
an info with the new message.

cause

public Throwable cause()
Returns the cause of the current info.

Returns:
the ciause the current info or null if the cause is not defined.

cause

public Info cause(Throwable cause)
Changes the cause of the current info. If the current info is sealed, a clone of the current object is returned.

Parameters:
cause - the cause of the info.
Returns:
an info with the cause defined.

file

public Object file()
Returns the file associated with the current info.

Returns:
the file or null if the file is not defined.

file

public Info file(Object file)
Changes the file associated with the current info. If the current info is sealed, a clone of the current object is returned.

Parameters:
file - the file.
Returns:
an info with the associated file
See Also:
line(), column()

line

public int line()
Returns the line number of the file associated with the current info.

Returns:
the line number or -1 if the line number if not defined.
See Also:
file()

line

public Info line(int line)
Sets the line number of the file associated with the current info. If the current info is sealed, a clone of the current object will be returned.

Parameters:
line - the line number or -1.
Returns:
an info with the new line number.

column

public int column()
Returns the column number of the file associated with the current info.

Returns:
the column number or -1 if the column number is not defined.

column

public Info column(int column)
Sets the column number of the file associated with the current info. If the current info is sealed, a clone of the current object will be returned.

Parameters:
column - the column number or -1.
Returns:
an info with the column number.

report

public void report()
Reports the current info using the thread local reporter.

See Also:
ReporterFactory

seal

public void seal()
Seals the current Info. After this call, the current object can't be mutated.


isSealed

public boolean isSealed()
Returns if the current object is sealed or not. If the current info is sealed any mutation will not change the current object but change a clone of it.

Returns:
if the current object is sealed or not.
See Also:
seal()

toString

public String toString()
Overrides:
toString in class Object

derive

public static Info derive(Level level,
                          Object... data)
Creates a new info derived from the default info of the thread local reporter.

Parameters:
level - set the level of the information.
data - the data associated with the info.
Returns:
a new info.
See Also:
derive(Level, String, Object[]), ReporterFactory.getDefaultInfo()

derive

public static Info derive(Level level,
                          String message,
                          Object... data)
Creates a new info derived from the default info of the thread local reporter.

Parameters:
level - set the level of the information.
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
fine(String, Object[]), info(String, Object[]), warning(String, Object[]), error(String, Object[]), fatalError(String, Object[])

fine

public static Info fine(String message,
                        Object... data)
Creates a new info derived from the default info of the thread local reporter with the level() Level.INFO.

Parameters:
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
derive(Level, String, Object[])

info

public static Info info(String message,
                        Object... data)
Creates a new info derived from the default info of the thread local reporter with the level() Level.FINE.

Parameters:
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
derive(Level, String, Object[])

warning

public static Info warning(String message,
                           Object... data)
Creates a new info derived from the default info of the thread local reporter with the level() Level.WARNING.

Parameters:
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
derive(Level, String, Object[])

error

public static Info error(String message,
                         Object... data)
Creates a new info derived from the default info of the thread local reporter with the level() Level.ERROR.

Parameters:
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
derive(Level, String, Object[])

fatalError

public static Info fatalError(String message,
                              Object... data)
Creates a new info derived from the default info of the thread local reporter with the level() Level.FATAL_ERROR.

Parameters:
data - the data associated with the info.
message - the message of the info. It can contains '%' that are interpreted using String.format(String, Object[]).
Returns:
a new info.
See Also:
derive(Level, String, Object[])