Package org.apache.joran

Examples of org.apache.joran.Interpreter


    // Associate "hello-world" pattern with  HelloWorldAction
    ruleStore.addRule(new Pattern("hello-world"), new HelloWorldAction());

    // Create a new Joran Interpreter and hand it our simple rule store.
    Interpreter ji = new Interpreter(ruleStore);

    // Create a SAX parser
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser saxParser = spf.newSAXParser();
View Full Code Here


    ruleStore.addRule(new Pattern("/computation/literal"), new LiteralAction());
    ruleStore.addRule(new Pattern("/computation/add"), new AddAction());
    ruleStore.addRule(new Pattern("/computation/multiply"), new MultiplyAction());
   
    // Create a new Joran Interpreter and hand it our simple rule store.
    Interpreter ji = new Interpreter(ruleStore);

    // Create a SAX parser
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser saxParser = spf.newSAXParser();

    // Parse the file given as the application's first argument and
    // set the SAX ContentHandler to the Joran Interpreter we just created.
    saxParser.parse(args[0], ji);

    // The file has been parsed and interpreted. We now print any errors that
    // might have occured.
    List errorList = ji.getExecutionContext().getErrorList();
    if(errorList.size() > 0) {
      System.out.println("The following errors occured:");
      for(int i = 0; i < errorList.size(); i++) {
        System.out.println("\t"+errorList.get(i));
      }
View Full Code Here

    // we start with the rule for the top-most (root) element
    ruleStore.addRule(new Pattern("*/foo"), new NOPAction());


    // Create a new Joran Interpreter and hand it our simple rule store.
    Interpreter ji = new Interpreter(ruleStore);

    // --------------------------+
    // Add an implicit action.   |
    // --------------------------+
    ji.addImplcitAction(new PrintMeImplicitAction());
   
    // Create a SAX parser
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser saxParser = spf.newSAXParser();

    // Parse the file given as the application's first argument and
    // set the SAX ContentHandler to the Joran Interpreter we just created.
    saxParser.parse(args[0], ji);

    // The file has been parsed and interpreted. We now print any errors that
    // might have occured.
    List errorList = ji.getExecutionContext().getErrorList();

    if (errorList.size() > 0) {
      System.out.println("The following errors occured:");

      for (int i = 0; i < errorList.size(); i++) {
View Full Code Here

    ruleStore.addRule(new Pattern("*/computation/literal"), new LiteralAction());
    ruleStore.addRule(new Pattern("*/computation/add"), new AddAction());
    ruleStore.addRule(new Pattern("*/computation/multiply"), new MultiplyAction());
   
    // Create a new Joran Interpreter and hand it our simple rule store.
    Interpreter ji = new Interpreter(ruleStore);

    // Create a SAX parser
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser saxParser = spf.newSAXParser();

    // Parse the file given as the application's first argument and
    // set the SAX ContentHandler to the Joran Interpreter we just created.
    saxParser.parse(args[0], ji);
   
    // The file has been parsed and interpreted. We now print any errors that
    // might have occured.
    List errorList = ji.getExecutionContext().getErrorList();
    if(errorList.size() > 0) {
      System.out.println("The following errors occured:");
      for(int i = 0; i < errorList.size(); i++) {
        System.out.println("\t"+errorList.get(i));
      }
View Full Code Here

    // We will let the XML file to teach the Joran interpreter about new rules
    ruleStore.addRule(
      new Pattern("/computation/new-rule"), new NewRuleAction());

    // Create a new Joran Interpreter and hand it our simple rule store.
    Interpreter ji = new Interpreter(ruleStore);

    // Create a SAX parser
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser saxParser = spf.newSAXParser();

    // Parse the file given as the application's first argument and
    // set the SAX ContentHandler to the Joran Interpreter we just created.
    saxParser.parse(args[0], ji);


    // The file has been parsed and interpreted. We now print any errors that
    // might have occured.
    List errorList = ji.getExecutionContext().getErrorList();

    if (errorList.size() > 0) {
      System.out.println("The following errors occured:");

      for (int i = 0; i < errorList.size(); i++) {
View Full Code Here

      new ConversionRuleAction());
    rs.addRule(
      new Pattern("log4j:configuration/newRule"), new NewRuleAction());
    rs.addRule(new Pattern("*/param"), new ParamAction());

    joranInterpreter = new Interpreter(rs);

    // We need to bother with an entity resolver in order to be compatible
    // with config files written for DOMConfigurator containing the following:
    // <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    joranInterpreter.setEntityResolver(new Log4jEntityResolver());
View Full Code Here

  public String toString() {
    return this.getClass().getName();
  }

  protected int getColumnNumber(ExecutionContext ec) {
    Interpreter jp = ec.getJoranInterpreter();
    Locator locator = jp.getLocator();
    if (locator != null) {
      return locator.getColumnNumber();
    }
    return -1;
  }
View Full Code Here

    }
    return -1;
  }

  protected int getLineNumber(ExecutionContext ec) {
    Interpreter jp = ec.getJoranInterpreter();
    Locator locator = jp.getLocator();
    if (locator != null) {
      return locator.getLineNumber();
    }
    return -1;
  }
View Full Code Here

TOP

Related Classes of org.apache.joran.Interpreter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.