com.topcoder.shared.problem
Class ProblemMessage

java.lang.Object
  |
  +--com.topcoder.shared.problem.ProblemMessage
All Implemented Interfaces:
java.lang.Cloneable, com.topcoder.shared.netCommon.CustomSerializable, java.io.Serializable

public class ProblemMessage
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, com.topcoder.shared.netCommon.CustomSerializable

This is a utility class for representing messages generate during problem statement parsing and construction. It provides levels of meaning, a message, and, if possible, the location within the problem statement that the message is related to.

See Also:
Serialized Form

Field Summary
static short ERROR
          Specified that a message's level is 'error'.
static short FATAL_ERROR
          Specified that a message's level is 'fatal error'
static short WARNING
          Specified that a message's level is 'warning'.
 
Constructor Summary
ProblemMessage()
          Empty constructor required by custom serialization.
ProblemMessage(int type, java.lang.String message)
          Constructs a message with an unknown location.
ProblemMessage(int type, java.lang.String message, int line, int column)
          Constructs a message with a known location.
 
Method Summary
 void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
          Custom serialization
 void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
          Custom serialization
 int getColumn()
          Returns the column in the problem statement XML to which the message corresponds (if known).
 int getLine()
          Returns the line in the problem statement XML to which the message corresponds (if known).
 java.lang.String getMessage()
          Returns the content of the message.
 int getType()
          The type of a message is one of WARNING, ERROR, or FATAL_ERROR.
 void log(Category trace)
          Sends the message in an appropriate format to the appropriate log.
 java.lang.String toString()
          Converts the message and all information associated with it to a human-readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WARNING

public static short WARNING
Specified that a message's level is 'warning'.


ERROR

public static short ERROR
Specified that a message's level is 'error'.


FATAL_ERROR

public static short FATAL_ERROR
Specified that a message's level is 'fatal error'

Constructor Detail

ProblemMessage

public ProblemMessage()
Empty constructor required by custom serialization.


ProblemMessage

public ProblemMessage(int type,
                      java.lang.String message,
                      int line,
                      int column)
Constructs a message with a known location.

Parameters:
type - One of WARNING, ERROR, or FATAL_ERROR.
message - The content of the message.
line - The number of the line to which the message corresponds. Lines are counted starting at 1.
column - The number of the column within the line to which the message corresponds. Columns are counted starting at 1.

ProblemMessage

public ProblemMessage(int type,
                      java.lang.String message)
Constructs a message with an unknown location.

Parameters:
type - One of WARNING, ERROR, or FATAL_ERROR.
message - The content of the message.
Method Detail

getType

public int getType()
The type of a message is one of WARNING, ERROR, or FATAL_ERROR.

Returns:
The type of the message.

getLine

public int getLine()
Returns the line in the problem statement XML to which the message corresponds (if known).

Returns:
Either 0 if the line is unknown, or else a value greater than 0.

getColumn

public int getColumn()
Returns the column in the problem statement XML to which the message corresponds (if known).

Returns:
Either 0 if the column is unknown, or else a value greater than 0.

getMessage

public java.lang.String getMessage()
Returns the content of the message.

Returns:
the content of the message.

customWriteObject

public void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
                       throws java.io.IOException
Custom serialization

Specified by:
customWriteObject in interface com.topcoder.shared.netCommon.CustomSerializable
Parameters:
writer - the writer to write to.
Throws:
java.io.IOException - if an I/O error has occurred in the stream that backs the writer.

customReadObject

public void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
                      throws java.io.IOException,
                             java.io.ObjectStreamException
Custom serialization

Specified by:
customReadObject in interface com.topcoder.shared.netCommon.CustomSerializable
Parameters:
reader - the reader to read from.
Throws:
java.io.ObjectStreamException - if the information that is read is inconsistent (stream corrupted or incompatibility between writers and readers)
java.io.IOException - if an I/O error has occurred in the stream that backs the reader.

log

public void log(Category trace)
Sends the message in an appropriate format to the appropriate log.

Parameters:
trace - A log4j.Category (probably should be a Logger instead).

toString

public java.lang.String toString()
Converts the message and all information associated with it to a human-readable string. Formatted like: Line xx: Column xx: message

Line will only be included if greater than 0. Column will only be included if greater than 0.

Overrides:
toString in class java.lang.Object
Returns:
the message and all information associated with it to a human-readable string.