KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > api > WhereUsedQuery


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.refactoring.api;
20
21 import java.util.Hashtable JavaDoc;
22 import org.netbeans.modules.refactoring.api.*;
23 import org.openide.util.Lookup;
24
25 /**
26  * Where used query does not do any "real" refactoring.
27  * It just encapsulates parameters for Find Usages, which is implemented by
28  * plugins.
29  * Refactoring itself is implemented in plugins
30  * @see org.netbeans.modules.refactoring.spi.RefactoringPlugin
31  * @see org.netbeans.modules.refactoring.spi.RefactoringPluginFactory
32  * @see AbstractRefactoring
33  * @see RefactoringSession
34  * @author Jan Becicka
35  */

36 public final class WhereUsedQuery extends AbstractRefactoring {
37     /**
38      * key for {@link getBooleanValue()}
39      * is search in comments requested?
40      */

41     public static final String JavaDoc SEARCH_IN_COMMENTS = "SEARCH_IN_COMMENTS";
42     /**
43      * key for {@link getBooleanValue()}
44      * is find references requested?
45      */

46     public static final String JavaDoc FIND_REFERENCES = "FIND_REFERENCES";
47     
48     /**
49      * Creates a new instance of WhereUsedQuery.
50      * WhereUsedQuery implementations currently understand following types:
51      * <table border="1">
52      * <tr><th>Module</th><th>Types the Module Understands</th><th>Implementation</th></tr>
53      * <tr><td>Java Refactoring</td><td><ul>
54      * <li>{@link org.openide.filesystems.FileObject} with content type text/x-java (class references)
55      * <li>{@link org.netbeans.api.java.source.TreePathHandle} (class, field, method references)
56      * </ul>
57      * <td>Finds references</td></tr>
58      * </table>
59      * @param lookup put object for which you request references into Lookup instance.
60      */

61     public WhereUsedQuery(Lookup lookup) {
62         super(lookup);
63         putValue(FIND_REFERENCES, true);
64     }
65
66    /**
67      * Setter for searched item
68      * @param lookup put object for which you request references into Lookup instance.
69      */

70     public final void setRefactoringSource(Lookup lookup) {
71         this.refactoringSource = lookup;
72     }
73     
74     private Hashtable JavaDoc hash = new Hashtable JavaDoc();
75     
76     /**
77      * getter for various properties
78      * @param key
79      * @return value for given key
80      * @see WhereUsedQuery#SEARCH_IN_COMMENTS
81      * @see WhereUsedQuery#FIND_REFERENCES
82      */

83     public final boolean getBooleanValue(Object JavaDoc key) {
84         Object JavaDoc o = hash.get(key);
85         if (o instanceof Boolean JavaDoc)
86             return (Boolean JavaDoc)o;
87         return false;
88     }
89     
90     /**
91      * setter for various properties
92      * @param key
93      * @param value set value for given key
94      * @see WhereUsedQuery#SEARCH_IN_COMMENTS
95      * @see WhereUsedQuery#FIND_REFERENCES
96      */

97     public final void putValue(Object JavaDoc key, Object JavaDoc value) {
98         hash.put(key, (Boolean JavaDoc) value);
99     }
100 }
101
102
Popular Tags