View Javadoc

1   /*
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd;
5   
6   import net.sourceforge.pmd.ast.JavaCharStream;
7   import net.sourceforge.pmd.ast.JavaParser;
8   import net.sourceforge.pmd.ast.JavaParserTokenManager;
9   
10  import java.io.InputStream;
11  import java.io.Reader;
12  
13  /**
14   * This is an implementation of {@link net.sourceforge.pmd.TargetJDKVersion} for
15   * JDK 1.4.
16   *
17   * @author Tom Copeland
18   */
19  public class TargetJDK1_4 implements TargetJDKVersion {
20  
21      /**
22       * @see net.sourceforge.pmd.TargetJDKVersion#createParser(InputStream)
23       */
24      public JavaParser createParser(InputStream in) {
25          JavaParser jp = new JavaParser(new JavaCharStream(in));
26          jp.setJdkVersion(4);
27          return jp;
28      }
29  
30      /**
31       * @see net.sourceforge.pmd.TargetJDKVersion#createParser(Reader)
32       */
33      public JavaParser createParser(Reader in) {
34          JavaParser jp = new JavaParser(new JavaCharStream(in));
35          jp.setJdkVersion(4);
36          return jp;
37      }
38  
39      /**
40       * Creates a token manager for the parser.
41       *
42       * @param in the reader for which to create a token manager
43       * @return a token manager
44       */
45      public JavaParserTokenManager createJavaParserTokenManager(Reader in) {
46          return new JavaParserTokenManager(new JavaCharStream(in));
47      }
48  
49      public String getVersionString() {
50          return "1.4";
51      }
52  
53  }