1 /*
2 * $HeadURL: $
3 * $Date: $
4 * $Revision: $
5 * $Author: $
6 *
7 * Copyright (c) 2005 MindTree Consulting Ltd.
8 *
9 * This file is part of Insight.
10 *
11 * Insight is free software: you can redistribute it and/or modify it under the
12 * terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version.
15 *
16 * Insight is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * Insight. If not, see <http://www.gnu.org/licenses/>.
23 */
24 package com.mindtree.techworks.insight.pagination;
25
26 import java.io.Serializable;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import com.mindtree.techworks.insight.preferences.util.PreferenceInterpreter;
31 import com.mindtree.techworks.insight.spi.LogEvent;
32
33
34 /**
35 * The <code>PageImpl</code> class is an abstract class that implements IPage interface.
36 * This class provides default implementation for adding and retrieving LogEvents.
37 * @author antonypulicken
38 *
39 * @version 1.0, 05/02/02
40 * @see com.mindtree.techworks.insight.spi.LogEvent
41 * @see com.mindtree.techworks.insight.pagination.IPage
42 */
43 public abstract class PageImpl implements IPage, Serializable{
44
45 /**
46 * Used for object serialization
47 */
48 private static final long serialVersionUID = -4327725831329417826L;
49
50 /**
51 * List that stores the LogEvents
52 */
53 private List logEventList;
54
55 /**
56 * Unique Name that identifies the page
57 */
58 private String pageSetNamespace;
59
60 /**
61 * Unique Name that identifies the page
62 */
63 private String pageNamespace;
64
65 /**
66 * PageSet instance
67 */
68 private PageSet pageSet;
69
70
71 /**
72 * Returns the LogEventList
73 *
74 * @return logEventList the LogEventList
75 *
76 */
77 public List getLogEventList(){
78 return this.logEventList;
79 }
80
81 /**
82 * Adds the logEvent to the list
83 * @param logEvent LogEvent
84 *
85 */
86 public void addLogEvent(LogEvent logEvent){
87 logEventList.add(logEvent);
88 if(logEventList.size() == PreferenceInterpreter.getCachePageSize()){
89 pageSet.thresholdReached();
90 //clear();
91 }
92 }
93
94 /**
95 * Initialize the class
96 * @param set PageSet instance for callback
97 */
98 public void init(PageSet set){
99 this.pageSet = set;
100 this.pageSetNamespace = pageSet.getNamespace();
101 this.pageNamespace = String.valueOf(pageSet.getPageCnt());
102 this.logEventList = new ArrayList();
103 }
104
105 /**
106 * Method that stores the Page
107 *
108 */
109 protected abstract void store();
110
111 /**
112 * Method that loads the Page
113 *
114 */
115 protected abstract void load();
116
117 /**
118 * Method that loads the Page
119 *
120 */
121 protected abstract void delete();
122
123 /**
124 * @return
125 */
126 public String getPageNamespace() {
127 return this.pageNamespace;
128 }
129
130 /**
131 * @return
132 */
133 public String getPageSetNamespace() {
134 return this.pageSetNamespace;
135 }
136
137 /**
138 * @param string
139 */
140 public void setPageNamespace(String string) {
141 this.pageNamespace = string;
142 }
143
144 /**
145 * @param string
146 */
147 public void setPageSetNamespace(String string) {
148 this.pageSetNamespace = string;
149 }
150
151 /**
152 * Sets the LogEventList
153 * @param eventList The logEventList to set.
154 */
155 protected void setLogEventList(List eventList) {
156 this.logEventList = eventList;
157 }
158
159 /**
160 * Clears the LogEvent list
161 *
162 */
163 public void clear(){
164 logEventList.clear();
165 logEventList = null;
166 }
167 }