1 package org.jacorb.notification.filter.etcl; 2 3 23 24 import org.jacorb.notification.filter.EvaluationContext; 25 import org.jacorb.notification.filter.EvaluationException; 26 import org.jacorb.notification.filter.EvaluationResult; 27 import org.jacorb.notification.filter.FilterConstraint; 28 import org.jacorb.notification.filter.ParseException; 29 import org.jacorb.notification.interfaces.Message; 30 import org.omg.CosNotifyFilter.ConstraintExp; 31 import org.omg.CosNotifyFilter.InvalidConstraint; 32 33 42 43 public class ETCLFilterConstraint implements FilterConstraint 44 { 45 48 private AbstractTCLNode rootNode_; 49 50 52 public ETCLFilterConstraint( AbstractTCLNode root ) 53 { 54 rootNode_ = root; 55 } 56 57 58 public ETCLFilterConstraint( ConstraintExp constraintExp ) 59 throws InvalidConstraint 60 { 61 try 62 { 63 rootNode_ = TCLParser.parse( constraintExp.constraint_expr ); 64 65 if (rootNode_ != null) { 66 TCLCleanUp _cleanUp = new TCLCleanUp(); 67 _cleanUp.fix( rootNode_ ); 68 69 StaticTypeChecker _checker = new StaticTypeChecker(); 70 _checker.check( rootNode_ ); 71 } 72 return; 73 } 74 catch ( StaticTypeException e ) 75 { 76 throw new InvalidConstraint( e.getMessage(), constraintExp ); 77 } 78 catch ( ParseException e ) 79 { 80 throw new InvalidConstraint( e.getMessage(), constraintExp ); 81 } 82 } 83 84 86 public EvaluationResult evaluate( EvaluationContext evaluationContext, 87 Message event ) 88 throws EvaluationException 89 { 90 if (rootNode_ == null) { 91 return EvaluationResult.BOOL_TRUE; 92 } 93 94 evaluationContext.setCurrentMessage( event ); 95 96 EvaluationResult _res = rootNode_.evaluate( evaluationContext ); 97 98 return _res; 99 } 100 101 102 public String toString() 103 { 104 StringBuffer _buffer = new StringBuffer ("<FilterConstraint: "); 105 106 rootNode_.printToStringBuffer(_buffer); 107 _buffer.append(" >"); 108 109 return _buffer.toString(); 110 } 111 } 112 | Popular Tags |