KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > cpd > JSPTokenizer


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd.cpd;
5
6 import net.sourceforge.pmd.jsp.ast.JspCharStream;
7 import net.sourceforge.pmd.jsp.ast.JspParserTokenManager;
8 import net.sourceforge.pmd.jsp.ast.Token;
9
10 import java.io.StringReader JavaDoc;
11
12 public class JSPTokenizer implements Tokenizer {
13
14     public void tokenize(SourceCode tokens, Tokens tokenEntries) {
15         StringBuffer JavaDoc buffer = tokens.getCodeBuffer();
16         JspParserTokenManager tokenMgr = new JspParserTokenManager(new JspCharStream(new StringReader JavaDoc(buffer.toString())));
17         Token currentToken = tokenMgr.getNextToken();
18         while (currentToken.image.length() > 0) {
19             tokenEntries.add(new TokenEntry(String.valueOf(currentToken.kind), tokens.getFileName(), currentToken.beginLine));
20             currentToken = tokenMgr.getNextToken();
21         }
22         tokenEntries.add(TokenEntry.getEOF());
23     }
24 }
25
26
Popular Tags