KickJava   Java API By Example, From Geeks To Geeks.

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


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

18 package org.apache.activemq.kaha;
19
20 import java.util.Collection JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Set JavaDoc;
23
24 /**
25  *Represents a container of persistent objects in the store
26  *Acts as a map, but values can be retrieved in insertion order
27  *
28  * @version $Revision: 1.2 $
29  */

30 public interface MapContainer<K, V> extends Map JavaDoc<K, V>{
31     
32     
33     /**
34      * The container is created or retrieved in
35      * an unloaded state.
36      * load populates the container will all the indexes used etc
37      * and should be called before any operations on the container
38      */

39     public void load();
40     
41     /**
42      * unload indexes from the container
43      *
44      */

45     public void unload();
46     
47     /**
48      * @return true if the indexes are loaded
49      */

50     public boolean isLoaded();
51     
52     /**
53      * For homogenous containers can set a custom marshaller for loading keys
54      * The default uses Object serialization
55      * @param keyMarshaller
56      */

57     public void setKeyMarshaller(Marshaller<K> keyMarshaller);
58     
59     /**
60      * For homogenous containers can set a custom marshaller for loading values
61      * The default uses Object serialization
62      * @param valueMarshaller
63    
64      */

65     public void setValueMarshaller(Marshaller<V> valueMarshaller);
66     /**
67      * @return the id the MapContainer was create with
68      */

69     public Object JavaDoc getId();
70
71     /**
72      * @return the number of values in the container
73      */

74     public int size();
75
76     /**
77      * @return true if there are no values stored in the container
78      */

79     public boolean isEmpty();
80
81     /**
82      * @param key
83      * @return true if the container contains the key
84      */

85     public boolean containsKey(K key);
86
87     /**
88      * Get the value associated with the key
89      * @param key
90      * @return the value associated with the key from the store
91      */

92     public V get(K key);
93
94     
95     /**
96      * @param o
97      * @return true if the MapContainer contains the value o
98      */

99     public boolean containsValue(K o);
100
101     /**
102      * Add add entries in the supplied Map
103      * @param map
104      */

105     public void putAll(Map JavaDoc<K,V> map);
106
107     /**
108      * @return a Set of all the keys
109      */

110     public Set JavaDoc<K> keySet();
111
112     /**
113      * @return a collection of all the values - the values will be lazily pulled out of the
114      * store if iterated etc.
115      */

116     public Collection JavaDoc<V> values();
117
118     /**
119      * @return a Set of all the Map.Entry instances - the values will be lazily pulled out of the
120      * store if iterated etc.
121      */

122     public Set JavaDoc<Map.Entry JavaDoc<K,V>> entrySet();
123
124    
125     /**
126      * Add an entry
127      * @param key
128      * @param value
129      * @return the old value for the key
130      */

131     public V put(K key,V value);
132
133
134     /**
135      * remove an entry associated with the key
136      * @param key
137      * @return the old value assocaited with the key or null
138      */

139     public V remove(K key);
140
141     /**
142      * empty the container
143      */

144     public void clear();
145     
146     /**
147      * Add an entry to the Store Map
148      * @param key
149      * @param Value
150      * @return the StoreEntry associated with the entry
151      */

152     public StoreEntry place(K key, V Value);
153     
154     /**
155      * Remove an Entry from ther Map
156      * @param entry
157      */

158     public void remove(StoreEntry entry);
159     
160     /**
161      * Get the Key object from it's location
162      * @param keyLocation
163      * @return the key for the entry
164      */

165     public K getKey(StoreEntry keyLocation);
166     
167     /**
168      * Get the value from it's location
169      * @param Valuelocation
170      * @return the Object
171      */

172     public V getValue(StoreEntry Valuelocation);
173     
174     /** Get the StoreEntry for the first value in the Map
175     *
176     * @return the first StoreEntry or null if the map is empty
177     */

178    public StoreEntry getFirst();
179
180    /**
181     * Get the StoreEntry for the last value item of the Map
182     *
183     * @return the last StoreEntry or null if the list is empty
184     */

185    public StoreEntry getLast();
186
187    /**
188     * Get the next StoreEntry value from the map
189     *
190     * @param entry
191     * @return the next StoreEntry or null
192     */

193    public StoreEntry getNext(StoreEntry entry);
194
195    /**
196     * Get the previous StoreEntry from the map
197     *
198     * @param entry
199     * @return the previous store entry or null
200     */

201    public StoreEntry getPrevious(StoreEntry entry);
202
203    
204    /**
205     * It's possible that a StoreEntry could be come stale
206     * this will return an upto date entry for the StoreEntry position
207     * @param entry old entry
208     * @return a refreshed StoreEntry
209     */

210    public StoreEntry refresh(StoreEntry entry);
211    
212    /**
213     * Get the StoreEntry associated with the key
214     * @param key
215     * @return the StoreEntry
216     */

217    public StoreEntry getEntry(K key);
218 }
219
Popular Tags