mars
Class ErrorMessage

java.lang.Object
  extended by mars.ErrorMessage

public class ErrorMessage
extends Object

Represents occurrance of an error detected during tokenizing, assembly or simulation.

Author:
Pete Sanderson

Field Summary
static boolean ERROR
          Constant to indicate this message is error not warning
static boolean WARNING
          Constant to indicate this message is warning not error
 
Constructor Summary
ErrorMessage(boolean isWarning, MIPSprogram sourceMIPSprogram, int line, int position, String message)
          Constructor for ErrorMessage.
ErrorMessage(boolean isWarning, String filename, int line, int position, String message)
          Constructor for ErrorMessage.
ErrorMessage(MIPSprogram sourceMIPSprogram, int line, int position, String message)
          Constructor for ErrorMessage.
ErrorMessage(String filename, int line, int position, String message)
          Constructor for ErrorMessage.
 
Method Summary
 String getFilename()
          Produce name of file containing error.
 int getLine()
          Produce line number of error.
 String getMessage()
          Produce error message.
 int getPosition()
          Produce position within erroneous line.
 boolean isWarning()
          Determine whether this message represents error or warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARNING

public static final boolean WARNING
Constant to indicate this message is warning not error

See Also:
Constant Field Values

ERROR

public static final boolean ERROR
Constant to indicate this message is error not warning

See Also:
Constant Field Values
Constructor Detail

ErrorMessage

public ErrorMessage(String filename,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage.

Parameters:
filename - String containing name of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

public ErrorMessage(boolean isWarning,
                    String filename,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage.

Parameters:
isWarning - set to WARNING if message is a warning not error, else set to ERROR or omit.
filename - String containing name of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

public ErrorMessage(MIPSprogram sourceMIPSprogram,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage.

Parameters:
sourceMIPSprogram - MIPSprogram object of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

public ErrorMessage(boolean isWarning,
                    MIPSprogram sourceMIPSprogram,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage.

Parameters:
isWarning - set to WARNING if message is a warning not error, else set to ERROR or omit.
sourceMIPSprogram - MIPSprogram object of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.
Method Detail

getFilename

public String getFilename()
Produce name of file containing error.

Returns:
Returns String containing name of source file containing the error.

getLine

public int getLine()
Produce line number of error.

Returns:
Returns line number in source program where error occurred.

getPosition

public int getPosition()
Produce position within erroneous line.

Returns:
Returns position within line of source program where error occurred.

getMessage

public String getMessage()
Produce error message.

Returns:
Returns String containing textual error message.

isWarning

public boolean isWarning()
Determine whether this message represents error or warning.

Returns:
Returns true if this message reflects warning, false if error.