コード例 #1
0
 protected synchronized void runMethod(String method) {
   try {
     this.exec(method + "()");
   } catch (PyException ex) {
     ex.printStackTrace();
     System.out.println("Error in filter spec " + ex.getMessage());
   }
 }
コード例 #2
0
 /** Called by the sax parser when the end of an element is encountered. */
 public void endElement(String namespaceURI, String local, String name) throws SAXException {
   if (name.equals(TagNames.CALLFLOW)) {
     //  Do an integrity check.
     // For every Expect node, there must be
     // a valid event template.
     try {
       callFlow.checkIntegrity();
     } catch (Exception ex) {
       System.out.println(ex.getMessage());
       ex.printStackTrace();
       throw new SAXException(ex.getMessage());
     }
   } else if (name.equals(TagNames.JYTHON_CODE)) {
     if (this.jythonCode != null) {
       JythonInterp jythonInterp = callFlow.getJythonInterp();
       try {
         jythonInterp.exec(this.jythonCode);
       } catch (PyException ex) {
         throw new SAXException(
             "error in evalScript \n" + this.jythonCode + "\n" + ex.getMessage());
       }
       this.jythonCode = null;
     }
   } else if (name.equals(TagNames.EXPECT)) {
     if (this.jythonCode != null) currentExpectNode.setJythonCode(this.jythonCode);
     this.jythonCode = null;
     callFlow.addExpectNode(currentExpectNode);
     currentExpectNode = null;
   } else if (name.equals(TagNames.SIP_REQUEST)) {
     if (this.messageTemplateContext) {
       MessageTemplate msgTemplate = new MessageTemplate(messageTemplate, id, this.jythonCode);
       callFlow.addMessageTemplate(msgTemplate);
       messageTemplate = null;
       this.jythonCode = null;
     }
   } else if (name.equals(TagNames.SIP_RESPONSE)) {
     if (this.messageTemplateContext) {
       MessageTemplate msgTemplate =
           new MessageTemplate(this.messageTemplate, this.id, this.jythonCode);
       callFlow.addMessageTemplate(msgTemplate);
       messageTemplate = null;
       this.jythonCode = null;
     }
   } else if (name.equals(TagNames.GENERATE)) {
     generateContext = false;
     if (generatedMessage.messageType.equals(Attr.SipRequest) && generatedMessage.method == null) {
       System.out.println("Current message node = " + generatedMessage.messageId);
       throw new SAXException("Missing method");
     }
   } else if (name.equals(TagNames.MESSAGE_TEMPLATES)) {
     messageTemplateContext = false;
   }
 }
コード例 #3
0
 /** Evaluate a boolean expression. */
 protected synchronized boolean evalBoolean(String expression) {
   try {
     this.exec("retval = " + expression);
     PyObject pyObj = this.get("retval");
     String retString = pyObj.toString();
     Debug.println("retString = " + retString);
     if (retString.equals("1")) return true;
     else return false;
   } catch (PyException ex) {
     ex.printStackTrace();
     System.exit(0);
     return false;
   }
 }
コード例 #4
0
 /**
  * Run this filter on the given SIP message (represented as an array canonical headers) and return
  * true or false.
  */
 protected synchronized boolean match(SIPMessage sipMsg) {
   this.set("sipMessage", sipMsg);
   try {
     this.exec("retval = match(sipMessage)");
     PyObject pyObj = this.get("retval");
     String retString = pyObj.toString();
     if (retString.equals("1")) return true;
     else return false;
   } catch (PyException ex) {
     ex.printStackTrace();
     System.out.println("Error in filter spec. " + ex.getMessage());
     System.exit(0);
   }
   return false;
 }