KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > archive > history > UsageHistory


1 /*
2  * Created on Jul 1, 2006
3  */

4 package com.openedit.archive.history;
5
6 import java.util.HashMap JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Map JavaDoc;
9
10 import org.apache.commons.collections.map.ListOrderedMap;
11
12 import com.openedit.store.Product;
13
14 public class UsageHistory
15 {
16     protected String JavaDoc fieldId;
17     protected String JavaDoc fieldName;
18     protected Map JavaDoc fieldRecords;
19     protected Product fieldProduct;
20     protected int fieldCounter;
21     
22     public UsageHistory()
23     {
24         
25     }
26     
27     public String JavaDoc getName()
28     {
29         return fieldName;
30     }
31     public void setName(String JavaDoc inName)
32     {
33         fieldName = inName;
34     }
35     public Map JavaDoc getRecords()
36     {
37         if (fieldRecords == null)
38         {
39             fieldRecords = ListOrderedMap.decorate(new HashMap JavaDoc());
40         }
41         return fieldRecords;
42     }
43     public Iterator JavaDoc getRecordIds()
44     {
45         return getRecords().keySet().iterator();
46     }
47     public Iterator JavaDoc getRecordData()
48     {
49         return getRecords().values().iterator();
50     }
51
52     public void addRecord(HistoryRecord inItem)
53     {
54         getRecords().put(inItem.getId(),inItem);
55     }
56     public void removeRecord(HistoryRecord inFound)
57     {
58         getRecords().remove(inFound);
59     }
60     public void clear()
61     {
62         getRecords().clear();
63     }
64
65     public Product getProduct()
66     {
67         return fieldProduct;
68     }
69
70     public void setProduct(Product inProduct)
71     {
72         fieldProduct = inProduct;
73     }
74
75     public HistoryRecord createNewRecord()
76     {
77         HistoryRecord record = new HistoryRecord();
78         record.setId(String.valueOf(getProduct().getId() + System.currentTimeMillis() + fieldCounter++ ) );
79         return record;
80     }
81 }
82
Popular Tags