View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang;
5   
6   import java.io.Reader;
7   
8   /**
9    * This is a generic implementation of the Parser interface.
10   * 
11   * @see Parser
12   */
13  public abstract class AbstractParser implements Parser {
14      protected final ParserOptions parserOptions;
15      
16      public AbstractParser(ParserOptions parserOptions) {
17  	this.parserOptions = parserOptions;
18      }
19  
20      public ParserOptions getParserOptions() {
21  	return parserOptions;
22      }
23  
24      public TokenManager getTokenManager(String fileName, Reader source) {
25  	TokenManager tokenManager = createTokenManager(source);
26  	tokenManager.setFileName(fileName);
27  	return tokenManager;
28      }
29  
30      protected abstract TokenManager createTokenManager(Reader source);
31  }