01: package org.acm.seguin.pmd.cpd;
02:
03: import java.util.ArrayList;
04: import java.util.Iterator;
05: import java.util.List;
06:
07: public class Tokens {
08:
09: private List tokens = new ArrayList();
10:
11: public void add(TokenEntry tokenEntry) {
12: this .tokens.add(tokenEntry);
13: }
14:
15: public Iterator iterator() {
16: return tokens.iterator();
17: }
18:
19: private TokenEntry get(int index) {
20: return (TokenEntry) tokens.get(index);
21: }
22:
23: public int size() {
24: return tokens.size();
25: }
26:
27: public int getLineCount(Mark mark, Match match) {
28: TokenEntry endTok = get(mark.getIndexIntoTokenArray()
29: + match.getTokenCount());
30: if (endTok.equals(TokenEntry.EOF)) {
31: endTok = get(mark.getIndexIntoTokenArray()
32: + match.getTokenCount() - 1);
33: }
34: return endTok.getBeginLine() - mark.getBeginLine() - 1;
35: }
36: }
|