org.millscript.commons.alert
Class Alert

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.millscript.commons.alert.Alert
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ClassCastAlert, ClassNotFoundAlert, Fault, IllegalAccessAlert, IllegalArgumentAlert, InstantiationAlert, IOAlert

public class Alert
extends java.lang.RuntimeException

This class represents an alert and is used in combination with a normal exception to indicate a abnormal condition in the system.

See Also:
Serialized Form

Constructor Summary
Alert(java.lang.String comp)
          Constructs a new alert with the specified complaint.
Alert(java.lang.String comp, Alert pa)
          Constructs a new alert with the specified complaint and alert cause.
Alert(java.lang.String comp, java.lang.String exp)
          Constructs a new alert with the specified complaint and explanation.
Alert(java.lang.String comp, java.lang.Throwable pt)
          Constructs a new alert with the specified complaint and throwable cause.
 
Method Summary
 Alert culprit(java.lang.String type, boolean value)
          Attach a new culprit to this alert, with a boolean as the culprit.
 Alert culprit(java.lang.String type, byte value)
          Attach a new culprit to this alert, with a byte as the culprit.
 Alert culprit(java.lang.String type, char value)
          Attach a new culprit to this alert, with a char as the culprit.
 Alert culprit(java.lang.String type, double value)
          Attach a new culprit to this alert, with a double as the culprit.
 Alert culprit(java.lang.String type, float value)
          Attach a new culprit to this alert, with a float as the culprit.
 Alert culprit(java.lang.String type, int value)
          Attach a new culprit to this alert, with an int as the culprit.
 Alert culprit(java.lang.String type, long value)
          Attach a new culprit to this alert, with a long as the culprit.
 Alert culprit(java.lang.String type, java.lang.Object value)
          Attach a new culprit to this alert, with a general object as the culprit.
 Alert decorate(AlertDecorator decorator)
          Decorates this alert with the information from the supplied decorator.
 Alert decorate(java.lang.Object o)
          Decorates this alert with information from the supplied object.
 EscapeException escape()
          Reports this alert as an escape, by throwing it wrapped in an escape exception.
 java.lang.String getComplaint()
          Returns this alerts complaint.
 java.util.LinkedList<Culprit> getCulprits()
          Returns this alerts culprits.
 java.lang.String getMessage()
           
 Alert getParentAlert()
          Returns the Alert that caused this Alert to be generated.
 java.lang.Throwable getParentThrowable()
          Returns the Throwable that caused this Alert to be generated.
 Phase getPhase()
          Returns the phase this Alert occured in.
 java.lang.String getReason()
          Returns the reason for this Alerts complaint
 boolean isMishap()
          Returns the mishap indicator flag, true if this Alert is a mishap and false otherwise.
 Alert mishap()
          Marks this alert as a mishap and throws itself.
 Alert origin(AlertOrigin origin)
          Decorates this alert with origin information from the supplied alert origin.
 Alert remishap()
          Reports this alert as a mishap, by throwing it as an exception.
 void report(AlertReporter reporter)
          Reports this alert to the specified reporter as a mishap.
 Alert setParentAlert(Alert alert)
          Sets the parent alert for this alert.
 Alert setParentThrowable(java.lang.Throwable throwable)
          Sets the parent throwable for this alert.
 Alert setPhase(Phase p)
          Sets the phase this alert occured in.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alert

public Alert(java.lang.String comp)
Constructs a new alert with the specified complaint.

Parameters:
comp - the complaint

Alert

public Alert(java.lang.String comp,
             java.lang.String exp)
Constructs a new alert with the specified complaint and explanation.

Parameters:
comp - the complaint
exp - the complaints explanation

Alert

public Alert(java.lang.String comp,
             Alert pa)
Constructs a new alert with the specified complaint and alert cause.

Parameters:
comp - the complaint
pa - the alert that caused this alert to be constructed

Alert

public Alert(java.lang.String comp,
             java.lang.Throwable pt)
Constructs a new alert with the specified complaint and throwable cause.

Parameters:
comp - the complaint
pt - the throwable that caused this alert to be constructed
Method Detail

culprit

public Alert culprit(java.lang.String type,
                     boolean value)
Attach a new culprit to this alert, with a boolean as the culprit.

Parameters:
type - the type of culprit
value - the boolean culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     byte value)
Attach a new culprit to this alert, with a byte as the culprit.

Parameters:
type - the type of culprit
value - the byte culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     char value)
Attach a new culprit to this alert, with a char as the culprit.

Parameters:
type - the type of culprit
value - the char culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     double value)
Attach a new culprit to this alert, with a double as the culprit.

Parameters:
type - the type of culprit
value - the double culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     float value)
Attach a new culprit to this alert, with a float as the culprit.

Parameters:
type - the type of culprit
value - the float culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     int value)
Attach a new culprit to this alert, with an int as the culprit.

Parameters:
type - the type of culprit
value - the int culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     long value)
Attach a new culprit to this alert, with a long as the culprit.

Parameters:
type - the type of culprit
value - the long culprit
Returns:
a reference to this alert.

culprit

public Alert culprit(java.lang.String type,
                     java.lang.Object value)
Attach a new culprit to this alert, with a general object as the culprit.

Parameters:
type - the type of culprit
value - the object culprit
Returns:
a reference to this alert.

decorate

public Alert decorate(AlertDecorator decorator)
Decorates this alert with the information from the supplied decorator. A given decorator will only decorate an alert once, on the first call to this method, regardless of how many times you might subsequently try. This behaviour is to protect you from repeating yourself in the alert detail message.

Parameters:
decorator - the decorator to get information from
Returns:
this alert after decorating it

decorate

public Alert decorate(java.lang.Object o)
Decorates this alert with information from the supplied object. If the object is an instance of an AlertDecorator, it's AlertDecorator.decorate(Alert) method will be called otherwise a generic culprit message will be added to the alert.

The method allows you to hide implementations of AlertDecorator behind interfaces and such, so you can use alerts without have to include the AlertDecorator interface in general API's.

Parameters:
o - the object to decorate this alert with
Returns:
this alert after decorating it

escape

public EscapeException escape()
Reports this alert as an escape, by throwing it wrapped in an escape exception. This is intended to be used as a by-pass for your normal alert handling code.

Returns:
a new escape exception wrapping this alert

getComplaint

public java.lang.String getComplaint()
Returns this alerts complaint.

Returns:
a String with this alerts complaint

getCulprits

public java.util.LinkedList<Culprit> getCulprits()
Returns this alerts culprits.

Returns:
a LinkedList of this alerts culprits.

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable
See Also:
Throwable.getMessage()

getParentAlert

public Alert getParentAlert()
Returns the Alert that caused this Alert to be generated.

Returns:
the Alert that caused this Alert to be generated

getParentThrowable

public java.lang.Throwable getParentThrowable()
Returns the Throwable that caused this Alert to be generated.

Returns:
the Throwable that caused this Alert to be generated

getPhase

public Phase getPhase()
Returns the phase this Alert occured in.

Returns:
the Phase this Alert occured in

getReason

public java.lang.String getReason()
Returns the reason for this Alerts complaint

Returns:
the reason for this Alerts complaint

isMishap

public boolean isMishap()
Returns the mishap indicator flag, true if this Alert is a mishap and false otherwise.

Returns:
true if this Alert is a mishap and false otherwise

mishap

public Alert mishap()
Marks this alert as a mishap and throws itself.

Returns:
this Alert

origin

public Alert origin(AlertOrigin origin)
Decorates this alert with origin information from the supplied alert origin. An alert can only have one set of origin information, so once set it cannot be set again.

Parameters:
origin - the decorator to get information from
Returns:
this alert after decorating it

remishap

public Alert remishap()
Reports this alert as a mishap, by throwing it as an exception. This is intended to be used when this alert needs to be re-thrown after being caught but not then chained.

Returns:
an AlertException for this alert

report

public void report(AlertReporter reporter)
Reports this alert to the specified reporter as a mishap.

Parameters:
reporter - the AlertReporter to report this mishap Alert to

setParentAlert

public Alert setParentAlert(Alert alert)
Sets the parent alert for this alert.

Parameters:
alert - the parent alert
Returns:
this alert

setParentThrowable

public Alert setParentThrowable(java.lang.Throwable throwable)
Sets the parent throwable for this alert.

Parameters:
throwable - the throwable that caused this alert
Returns:
this alert

setPhase

public Alert setPhase(Phase p)
Sets the phase this alert occured in.

Parameters:
p - the phase for this alert

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable
See Also:
Object.toString()


Copyright © 2005-2007 Open World Ltd. All Rights Reserved.