rwth.i2.ltlrv.afastate.interfaze
Interface IIfClosure


public interface IIfClosure

IIfClosure - Interface for if-closures which are to be evaluated at runtime. An if-closure evaluates a boolean expression under some given bindings. This is used in order to evaluate if-pointcuts in the right context. A typical example may be:

   new IIfClosure() {
                        public boolean satisfiedUnderBindings(
                                WeakValuesMap currentBindings) {
                            try {
                                final Integer j = (Integer) currentBindings
                                        .get("j");
                                final Integer i = (Integer) currentBindings
                                        .get("i");
                                try {
                                    return j != i;
                                } catch (java.lang.Exception ex) {
                                    throw new IIfClosure.UserCausedException(
                                            ex, "j != i");
                                }
                            } catch (java.lang.NullPointerException ex) {
                                return false;
                            } catch (java.lang.ClassCastException ex) {
                                return false;
                            }
                        }

                        public java.lang.String[] variableNames() {
                            return new java.lang.String[] { "j", "i" };
                        }

                        public java.lang.String toString() {
                            return "j != i";
                        }
                    }
   }
   

Author:
Eric Bodden

Nested Class Summary
static class IIfClosure.UserCausedException
          UserCausedException - An exception that wraps exceptions caused by the evaluation of an IfClosure.
 
Method Summary
 boolean satisfiedUnderBindings(WeakValuesMap<String,Object> currentBinding)
          Evaluates the given booelan expression under the given bindings.
 String toString()
          Clients should implement this for debugging purposes.
 String[] variableNames()
          Returns all variables required to evaluate this closure.
 

Method Detail

satisfiedUnderBindings

boolean satisfiedUnderBindings(WeakValuesMap<String,Object> currentBinding)
                               throws IIfClosure.UserCausedException
Evaluates the given booelan expression under the given bindings.

Parameters:
currentBinding - the binding to evaluate under
Returns:
true if the expression is satisfied, false otherwise
Throws:
IIfClosure.UserCausedException - thrown if the boolean expression caused an exception; the originally exception is wrapped in the IIfClosure.UserCausedException and can be extracted using Throwable.getCause(). The expression that caused the exception can be retrieved by IIfClosure.UserCausedException.getIfExpression() in String form.

variableNames

String[] variableNames()
Returns all variables required to evaluate this closure.

Returns:
all variables required to evaluate this closure

toString

String toString()
Clients should implement this for debugging purposes.

Overrides:
toString in class Object
See Also:
Object.toString()