KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > hittracker > ListHitTracker


1 /*
2  * Created on May 2, 2004
3  */

4 package com.openedit.hittracker;
5
6 import java.io.IOException JavaDoc;
7 import java.util.ArrayList JavaDoc;
8 import java.util.Collection JavaDoc;
9 import java.util.Iterator JavaDoc;
10 import java.util.List JavaDoc;
11
12
13 /**
14  * @author cburkey
15  *
16  */

17 public class ListHitTracker extends HitTracker
18 {
19     protected List JavaDoc fieldHits;
20     
21     public ListHitTracker()
22     {
23         
24     }
25     
26     public ListHitTracker(List JavaDoc inHits)
27     {
28         setHits(inHits);
29     }
30     
31     public List JavaDoc getHits()
32     {
33         if (fieldHits == null)
34         {
35             fieldHits = new ArrayList JavaDoc();
36         }
37         return fieldHits;
38     }
39     
40     public void setHits(List JavaDoc inObjects)
41     {
42         fieldHits = inObjects;
43     }
44     
45     public void addHit(Object JavaDoc inObject)
46     {
47         getHits().add(inObject);
48     }
49     
50     public void addAll(Collection JavaDoc inCollection)
51     {
52         getHits().addAll(inCollection);
53     }
54     
55     public int getTotal()
56     {
57         if ( getHits() == null )
58         {
59             return 0;
60         }
61         else
62         {
63             return getHits().size();
64         }
65     }
66     
67     public Object JavaDoc get(int count) throws IOException JavaDoc
68     {
69         return getHits().get(count);
70     }
71     
72     public Iterator JavaDoc getAllHits()
73     {
74         return getHits().iterator();
75     }
76
77     public boolean contains(Object JavaDoc inHit)
78     {
79         return getHits().contains(inHit);
80     }
81 }
82
Popular Tags