KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.List JavaDoc;
9
10 public class Tokens {
11
12     private List JavaDoc tokens = new ArrayList JavaDoc();
13
14     public void add(TokenEntry tokenEntry) {
15         this.tokens.add(tokenEntry);
16     }
17
18     public Iterator JavaDoc iterator() {
19         return tokens.iterator();
20     }
21
22     private TokenEntry get(int index) {
23         return (TokenEntry) tokens.get(index);
24     }
25
26     public int size() {
27         return tokens.size();
28     }
29
30     public int getLineCount(TokenEntry mark, Match match) {
31         TokenEntry endTok = get(mark.getIndex() + match.getTokenCount() - 1);
32         if (endTok == TokenEntry.EOF) {
33             endTok = get(mark.getIndex() + match.getTokenCount() - 2);
34         }
35         return endTok.getBeginLine() - mark.getBeginLine() + 1;
36     }
37
38     public List JavaDoc getTokens() {
39         return tokens;
40     }
41
42 }
43
Popular Tags