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;
7 import java.util.Iterator;
8 import java.util.List;
9
10 public class Tokens {
11
12 private List tokens = new ArrayList();
13
14 public void add(TokenEntry tokenEntry) {
15 this.tokens.add(tokenEntry);
16 }
17
18 public Iterator 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(Mark mark, Match match) {
31 TokenEntry endTok = get(mark.getIndexIntoTokenArray() + match.getTokenCount());
32 if (endTok.equals(TokenEntry.EOF)) {
33 endTok = get(mark.getIndexIntoTokenArray() + match.getTokenCount() - 1);
34 }
35 return endTok.getBeginLine() - mark.getBeginLine() - 1;
36 }
37 }
This page was automatically generated by Maven