KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > ClassIndexStorage


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.modules.javacore;
20
21 /** Private SPI for providing alternative backend behind the class index.
22  *
23  * @author Martin Matula
24  */

25 public interface ClassIndexStorage {
26     /** Checks whether there are any IDs registered for a given FQN.
27      * @param fqn Fully qualified name to be checked.
28      * @return true if the given fully qualified name exists (i.e. if {@link #getIDsForFQN}
29      * returns a non-null value).
30      */

31     boolean existsFQN(String JavaDoc fqn);
32
33     /** Returns IDs registered for a given fully qualified or simple name.
34      * @param name Name (fully qualified or simple).
35      * @param isSimpleName Indicates whether the first parameter is a fully qualified or simple name (true = simple name).
36      * @return IDs for a given name or null if there are
37      * no IDs for a given name. This method never returns an empty array.
38      */

39     long[] getIDsForName(String JavaDoc name, boolean isSimpleName);
40     
41     /** Sets IDs to be registered for a given name.
42      * @param name Simple or fully qualified name.
43      * @param isSimpleName Indicates whether the first parameter is a fully qualified or simple name (true = simple name).
44      * @param classIDs IDs for a given name or null (if no IDs should be registered
45      * for a given name).
46      */

47     void setIDsForName(String JavaDoc name, boolean isSimpleName, long[] classIDs);
48
49     /** Retrieves IDs registered for names with a given prefix
50      * and returns the IDs registered for the first name with a given prefix
51      * found in form of QueryItem. QueryItem.getNext() can be used to move forward
52      * in the result set. Each QueryItem represents an array of IDs registered for a single name.<p/>
53      * In case of a fully qualified name prefix (isSimpleName == false) the semantics of "FQN has fqnPrefix"
54      * in the context of this method means the following needs to be true:<br/>
55      * <pre> fqn.startsWith(fqnPrefix) && fqn.lastIndexOf('.') == fqnPrefix.lastIndexOf('.')
56      * </pre>
57      * @param prefix Name prefix for which the IDs should be returned.
58      * @param isSimpleName Indicates whether a prefix is a simple name prefix or a FQN prefix.
59      * @return QueryItem representing the IDs registered for the first simple name found (having the specified prefix)
60      */

61     QueryItem getFirstForNamePrefix(String JavaDoc prefix, boolean isSimpleName);
62
63     /** Returns integers (identifier hash codes) registered for a given ID.
64      * @param resourceId ID to return the hash codes for.
65      * @return Identifier hash codes registered for a given ID (naturally ordered) or null (if no
66      * identifier hash codes are registered for a given ID).
67      */

68     int[] getIdentifiers(long resourceId);
69     
70     /** Sets identifier hash codes to be registered for a given ID.
71      * @param resourceId ID to register the identifier hash codes for.
72      * @param hashCodes Identifier hash codes for a given ID or null if no IDs should be registered.
73      * <strong>The elements in the array must be ordered using ascending natural ordering.</strong>
74      */

75     void setIdentifiers(long resourceId, int[] hashCodes);
76     
77     /** Returns and removes identifier hash codes for a given ID.
78      * @param resourceId ID to remove the identifier hash codes registration for.
79      * @return Removed identifier hash codes (naturally ordered).
80      */

81     int[] removeIdentifiers(long resourceId);
82     
83     /** Returns all IDs for which a given identifier hash code is registered.
84      * @param hashCode Identifier hash code to search the IDs for.
85      * @return Array of all IDs for which a given hash code is registered. (Never returns null.)
86      */

87     long[] getIDsForIdentifier(int hashCode);
88
89     /** Initializes this storage. Can be used for deserializing the internal storage structures.
90      * @return true if the initialization succeeded. Otherwise returns false (e.g. if the persisted
91      * parts of the storage cannot be deserialized or are corrupted in some way or the index storage
92      * does not exist yet).
93      */

94     boolean mount();
95     
96     /** Called when the corresponding class index is released by the IDE. Can be used for a cleanup tasks
97      * and for serializing the index content.
98      */

99     void unmount();
100
101     /** Simple represenation of a result set.
102      */

103     public interface QueryItem {
104         /** Returns name the IDs represented by this QueryItem are registered.
105          * @return Name.
106          */

107         String JavaDoc getName();
108         
109         /** Returns IDs represented by this QueryItem.
110          * @return IDs
111          */

112         long[] getIDs();
113         
114         /** Sets IDs registered for a name this QueryItem corresponds to.
115          * The method may throw ConcurrentModificationException if the underlying data structures were concurrently modified.
116          * @param ids IDs to be registered or null if no IDs should be registered for a given name.
117          */

118         void setIDs(long[] ids);
119         
120         /** Returns next item in the result set.
121          * The method may throw ConcurrentModificationException if the underlying data structures were concurrently modified.
122          * @return Next item in the result set.
123          */

124         QueryItem getNext();
125     }
126 }
Popular Tags