/** Constructor. */
 protected XMLContentHandler(String eventFile, String agentFile) {
   myEngine = EventEngine.theStack;
   agentTable = new Hashtable();
   try {
     XMLReader saxParser =
         (XMLReader) Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
     saxParser.setContentHandler(this);
     saxParser.setFeature("http://xml.org/sax/features/validation", true);
     // parse the xml specification for the event tags.
     saxParser.parse(agentFile);
     saxParser.parse(eventFile);
   } catch (SAXParseException spe) {
     // Error generated by the parser
     System.out.println(
         "\n** Parsing error" + ", line " + spe.getLineNumber() + ", uri " + spe.getSystemId());
     System.out.println("   " + spe.getMessage());
     // Use the contained exception, if any
     Exception x = spe;
     if (spe.getException() != null) x = spe.getException();
     x.printStackTrace();
     System.exit(0);
   } catch (SAXException sxe) {
     // Error generated by this application
     // (or a parser-initialization error)
     Exception x = sxe;
     if (sxe.getException() != null) x = sxe.getException();
     x.printStackTrace();
     System.exit(0);
   } catch (IOException ioe) {
     // I/O error
     ioe.printStackTrace();
     System.exit(0);
   } catch (Exception pce) {
     // Parser with specified options can't be built
     pce.printStackTrace();
     System.exit(0);
   }
 }
예제 #2
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;
   }
 }
예제 #3
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;
 }