KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > ListContainer


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.kaha;
16
17 import java.util.List JavaDoc;
18 import java.util.NoSuchElementException JavaDoc;
19
20 /**
21  * Represents a container of persistent objects in the store Acts as a map, but values can be retrieved in insertion
22  * order
23  *
24  * @version $Revision: 1.2 $
25  */

26 public interface ListContainer<V> extends List JavaDoc<V>{
27
28     /**
29      * The container is created or retrieved in an unloaded state. load populates the container will all the indexes
30      * used etc and should be called before any operations on the container
31      */

32     public void load();
33
34     /**
35      * unload indexes from the container
36      *
37      */

38     public void unload();
39
40     /**
41      * @return true if the indexes are loaded
42      */

43     public boolean isLoaded();
44
45     /**
46      * For homogenous containers can set a custom marshaller for loading values The default uses Object serialization
47      *
48      * @param marshaller
49      */

50     public void setMarshaller(Marshaller marshaller);
51
52     /**
53      * @return the id the MapContainer was create with
54      */

55     public Object JavaDoc getId();
56
57     /**
58      * @return the number of values in the container
59      */

60     public int size();
61
62     /**
63      * Inserts the given element at the beginning of this list.
64      *
65      * @param o the element to be inserted at the beginning of this list.
66      */

67     public void addFirst(V o);
68
69     /**
70      * Appends the given element to the end of this list. (Identical in function to the <tt>add</tt> method; included
71      * only for consistency.)
72      *
73      * @param o the element to be inserted at the end of this list.
74      */

75     public void addLast(V o);
76
77     /**
78      * Removes and returns the first element from this list.
79      *
80      * @return the first element from this list.
81      * @throws NoSuchElementException if this list is empty.
82      */

83     public V removeFirst();
84
85     /**
86      * Removes and returns the last element from this list.
87      *
88      * @return the last element from this list.
89      * @throws NoSuchElementException if this list is empty.
90      */

91     public V removeLast();
92
93     /**
94      * remove an objecr from the list without retrieving the old value from the store
95      *
96      * @param position
97      * @return true if successful
98      */

99     public boolean doRemove(int position);
100
101     /**
102      * add an Object to the list but get a StoreEntry of its position
103      *
104      * @param object
105      * @return the entry in the Store
106      */

107     public StoreEntry placeLast(V object);
108
109     /**
110      * insert an Object in first position int the list but get a StoreEntry of its position
111      *
112      * @param object
113      * @return the location in the Store
114      */

115     public StoreEntry placeFirst(V object);
116
117     /**
118      * Advanced feature = must ensure the object written doesn't overwrite other objects in the container
119      *
120      * @param entry
121      * @param object
122      */

123     public void update(StoreEntry entry,V object);
124
125     /**
126      * Retrieve an Object from the Store by its location
127      *
128      * @param entry
129      * @return the Object at that entry
130      */

131     public V get(StoreEntry entry);
132
133     /**
134      * Get the StoreEntry for the first item of the list
135      *
136      * @return the first StoreEntry or null if the list is empty
137      */

138     public StoreEntry getFirst();
139
140     /**
141      * Get the StoreEntry for the last item of the list
142      *
143      * @return the last StoreEntry or null if the list is empty
144      */

145     public StoreEntry getLast();
146
147     /**
148      * Get the next StoreEntry from the list
149      *
150      * @param entry
151      * @return the next StoreEntry or null
152      */

153     public StoreEntry getNext(StoreEntry entry);
154
155     /**
156      * Get the previous StoreEntry from the list
157      *
158      * @param entry
159      * @return the previous store entry or null
160      */

161     public StoreEntry getPrevious(StoreEntry entry);
162
163     /**
164      * remove the Object at the StoreEntry
165      *
166      * @param entry
167      * @return true if successful
168      */

169     public boolean remove(StoreEntry entry);
170     
171     /**
172      * It's possible that a StoreEntry could be come stale
173      * this will return an upto date entry for the StoreEntry position
174      * @param entry old entry
175      * @return a refreshed StoreEntry
176      */

177     public StoreEntry refresh(StoreEntry entry);
178 }
179
Popular Tags