KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > ui > nodes > elements > SourceElementFilter


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
20 package org.netbeans.modules.java.ui.nodes.elements;
21
22 import java.lang.reflect.Modifier JavaDoc;
23
24 /** Interface for filtering and ordering the items in the visual
25 * presentation of a source element.
26 * Used to control the children of a source element node.
27 * <p>Note that this does <em>not</em> fire events for changes
28 * in its properties; it is expected that a new filter will instead
29 * be created and applied to the source children.
30 *
31 * @see org.openide.src.SourceElement
32 * @see org.netbeans.modules.java.ui.nodes.elements.SourceChildren
33 * @author Dafe Simonek, Jan Jancura
34 */

35 public class SourceElementFilter {
36
37     /** Specifies a child representing a package or class import. */
38     public static final int IMPORT = 1;
39     /** Specifies a child representing a (top-level) class. */
40     public static final int CLASS = IMPORT << 1;
41     /** Specifies a child representing a (top-level) interface. */
42     public static final int INTERFACE = CLASS << 1;
43     /** Specifies a child representing a (top-level) annotation type. */
44     public static final int ANNOTATION_TYPE = INTERFACE << 1;
45     /** Specifies a child representing a (top-level) enum. */
46     public static final int ENUM = ANNOTATION_TYPE << 1;
47     /** Does not specify any top-level element. */
48     public static final int ALL = IMPORT + CLASS + INTERFACE + ANNOTATION_TYPE + ENUM;
49
50     /** Specifies package-private member access. */
51     public static final int PACKAGE = 65536;
52     /** Specifies public member access. */
53     public static final int PUBLIC = Modifier.PUBLIC;
54     /** Specifies private member access. */
55     public static final int PRIVATE = Modifier.PRIVATE;
56     /** Specifies protected member access. */
57     public static final int PROTECTED = Modifier.PROTECTED;
58     /** Does not specify any member access. */
59     public static final int ALL_MODIFIERS = PROTECTED | PUBLIC | PRIVATE | PACKAGE;
60
61     /** Default order of the top-level element types in the hierarchy.
62     * A list, each of whose elements is a bitwise disjunction of element types.
63     * By default, only classes and interfaces are listed, and these together.
64     */

65     public static final int[] DEFAULT_ORDER = {CLASS + INTERFACE + ANNOTATION_TYPE + ENUM};
66
67     /** stores property value */
68     private boolean allClasses = false;
69     /** stores property value */
70     private int[] order = null;
71     /** stores property value */
72     private int modifiers = ALL_MODIFIERS;
73
74
75     /** Test whether all classes in the source should be recursively shown.
76     * @return <code>true</code> to include inner classes/interfaces, <code>false</code> to only
77     * include top-level classes/interfaces
78     */

79     public boolean isAllClasses () {
80         return allClasses;
81     }
82
83     /** Set whether all classes should be shown.
84     * @param allClasses <code>true</code> if so
85     * @see #isAllClasses
86     */

87     public void setAllClasses (boolean allClasses) {
88         this.allClasses = allClasses;
89     }
90
91     /** Get the current order for elements.
92     * @return the current order, as a list of bitwise disjunctions among element
93     * types (e.g. {@link #CLASS}). If <code>null</code>, the {@link #DEFAULT_ORDER},
94     * or no particular order at all, may be used.
95     */

96     public int[] getOrder () {
97         return order;
98     }
99
100     /** Set a new order for elements.
101     * Should update the children list of the source element node.
102     * @param order the new order, or <code>null</code> for the default
103     * @see #getOrder
104     */

105     public void setOrder (int[] order) {
106         this.order = order;
107     }
108
109     /**
110     * Get permitted access modes.
111     * Members with excluded access modes will not be displayed.
112     * @return a modifier mask, as a bitwise disjunction of modes, e.g. {@link #PROTECTED}
113     */

114     public int getModifiers () {
115         return modifiers;
116     }
117
118     /**
119     * Set permitted access modes.
120     * @param modifiers the new modifier mask
121     * @see #getModifiers
122     */

123     public void setModifiers (int modifiers) {
124         this.modifiers = modifiers;
125     }
126 }
127
Popular Tags