KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > mdr > persistence > SinglevaluedIndex


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.mdr.persistence;
20
21 /** Representation index where exactly one value is
22  * associated with each key.
23  * @author Pavel Buzek
24  * @version
25  */

26
27 public interface SinglevaluedIndex extends Index {
28
29     /** Associates the specified value with the specified key in this index.
30      * @return true if there was an item in this index that was associated with the key
31      * prior to this call
32      * @param key
33      * @param value
34      * @throws StorageException
35      */

36     public boolean put(Object JavaDoc key,Object JavaDoc value) throws StorageException;
37     
38     /** Replaces the original value associated with the specified key in this index
39      * with new value. If no value was associated with this key prior to this call
40      * StorageBadRequestException is thrown.
41      * @param key
42      * @param value
43      * @throws StorageException
44      * @throws StorageBadRequestException
45      */

46     public void replace(Object JavaDoc key, Object JavaDoc value) throws StorageException, StorageBadRequestException;
47     
48     /** Returns the value to which this index maps the specified key.
49      * StorageBadRequestException is thrown if there is no value for the key.
50      * @return value associated with specified key
51      * @param key
52      * @throws StorageException
53      * @throws StorageBadRequestException
54      */

55     public Object JavaDoc get(Object JavaDoc key) throws StorageException, StorageBadRequestException;
56
57     /** Like get, but if the index contains keys, this returns the object
58      * corresponding to the key
59      * @return
60      * @param key
61      * @throws StorageException
62      */

63     public Object JavaDoc getObject (Object JavaDoc key, SinglevaluedIndex repos) throws StorageException;
64
65     /** Returns the value to which this index maps the specified key
66      * or null if there is no value for this key.
67      * @return value associated with specified key or null
68      * @param key
69      * @throws StorageException
70      */

71     public Object JavaDoc getIfExists (Object JavaDoc key) throws StorageException;
72     
73     /** Like getIfExists, but if the index contains keys, this returns the object
74      * corresponding to the key
75      * @return
76      * @param key
77      * @throws StorageException
78      */

79     public Object JavaDoc getObjectIfExists (Object JavaDoc key, SinglevaluedIndex repos) throws StorageException;
80
81     /** Returns a collection view of the values contained in this index.
82      * Returned collection is read only and may not be modified.
83      * If this index has no items, empty Collection is returned.
84      * @return
85      * @throws StorageException
86      */

87     public java.util.Collection JavaDoc values () throws StorageException;
88     
89     /** Returns a collection view of {@link java.util.Map.Entry} key-value pairs in the index,
90      * where key matches the queried prefix. Values are objects (as returned by {@link getObject}
91      * method).
92      * @param prefix queried prefix
93      * @param repos primary index
94      * @return
95      * @throws StorageException
96      * @throws UnsupportedOperationException thrown if the index does not support quries on
97      * prefixes (due to unsuitable key entry type, etc.)
98      */

99     public java.util.Collection JavaDoc queryByKeyPrefix (Object JavaDoc prefix, SinglevaluedIndex repos) throws StorageException;
100 }
101
Popular Tags