View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.jsp;
5   
6   import java.io.Writer;
7   
8   import net.sf.saxon.sxpath.IndependentContext;
9   import net.sourceforge.pmd.lang.AbstractLanguageVersionHandler;
10  import net.sourceforge.pmd.lang.Parser;
11  import net.sourceforge.pmd.lang.ParserOptions;
12  import net.sourceforge.pmd.lang.VisitorStarter;
13  import net.sourceforge.pmd.lang.XPathHandler;
14  import net.sourceforge.pmd.lang.ast.Node;
15  import net.sourceforge.pmd.lang.ast.xpath.AbstractASTXPathHandler;
16  import net.sourceforge.pmd.lang.jsp.ast.DumpFacade;
17  import net.sourceforge.pmd.lang.jsp.ast.JspNode;
18  import net.sourceforge.pmd.lang.jsp.rule.JspRuleViolationFactory;
19  import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
20  
21  /**
22   * Implementation of LanguageVersionHandler for the JSP parser.
23   * 
24   * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
25   */
26  public class JspHandler extends AbstractLanguageVersionHandler {
27  
28      @Override
29      public XPathHandler getXPathHandler() {
30          return new AbstractASTXPathHandler() {
31              public void initialize() {
32              }
33  
34              public void initialize(IndependentContext context) {
35              }
36          };
37      }
38  
39      public RuleViolationFactory getRuleViolationFactory() {
40          return JspRuleViolationFactory.INSTANCE;
41      }
42  
43      public Parser getParser(ParserOptions parserOptions) {
44          return new JspParser(parserOptions);
45      }
46  
47      @Override
48      public VisitorStarter getDumpFacade(final Writer writer, final String prefix, final boolean recurse) {
49          return new VisitorStarter() {
50              public void start(Node rootNode) {
51                  new DumpFacade().initializeWith(writer, prefix, recurse, (JspNode) rootNode);
52              }
53          };
54      }
55  }