KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > BrowserTreeNode


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.browser;
9
10 import javax.swing.tree.DefaultMutableTreeNode JavaDoc;
11
12 /**
13  * Tree node contained in the tree of the <tt>BrowserTreePane</tt> and
14  * representing a structural element of the class file format.
15  *
16  * @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>, <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
17  * @version $Revision: 1.2 $ $Date: 2004/12/28 13:04:31 $
18  */

19 public class BrowserTreeNode extends DefaultMutableTreeNode JavaDoc {
20
21     /**
22      * Node that does not exhibit detail content.
23      */

24     public static final String JavaDoc NODE_NO_CONTENT = "noContent";
25     /**
26      * Node for general information on the class file structure.
27      */

28     public static final String JavaDoc NODE_GENERAL = "general";
29     /**
30      * Node for a constant pool entry (<tt>CPInfo</tt>).
31      */

32     public static final String JavaDoc NODE_CONSTANT_POOL = "constantPool";
33     /**
34      * Node for an interface entry.
35      */

36     public static final String JavaDoc NODE_INTERFACE = "interface";
37     /**
38      * Node for a field entry (<tt>FieldInfo</tt>).
39      */

40     public static final String JavaDoc NODE_FIELD = "field";
41     /**
42      * Node for a method entry (<tt>MethodInfo</tt>).
43      */

44     public static final String JavaDoc NODE_METHOD = "method";
45     /**
46      * Node for an attribute entry (<tt>AttributeInfo</tt>).
47      */

48     public static final String JavaDoc NODE_ATTRIBUTE = "attribute";
49     /**
50      * Node for an attribute entry (<tt>VisibleRuntimeAnnotation</tt>).
51      */

52     public static final String JavaDoc NODE_ANNOTATION = "annotation";
53     /**
54      * Node for an <tt>ElementValuePair</tt> entry.
55      */

56     public static final String JavaDoc NODE_ELEMENTVALUEPAIR = "elementvaluepair";
57     /**
58      * Node for an <tt>ElementValue</tt> entry.
59      */

60     public static final String JavaDoc NODE_ELEMENTVALUE = "elementvalue";
61     /**
62      * Node for an <tt>ArrayElementValue</tt> entry.
63      */

64     public static final String JavaDoc NODE_ARRAYELEMENTVALUE = "arrayelementvalue";
65
66
67     private String JavaDoc type;
68     private int index;
69     private Object JavaDoc element;
70
71     /**
72      * Constructor.
73      *
74      * @param text the display text.
75      */

76     public BrowserTreeNode(String JavaDoc text) {
77         this(text, NODE_NO_CONTENT);
78     }
79
80     /**
81      * Constructor.
82      *
83      * @param text the display text.
84      * @param type the node type. One of the <tt>NODE_</tt> constants.
85      */

86     public BrowserTreeNode(String JavaDoc text, String JavaDoc type) {
87         this(text, type, 0);
88     }
89
90     /**
91      * Constructor.
92      *
93      * @param text the display text.
94      * @param type the node type. One of the <tt>NODE_</tt> constants.
95      * @param index the logical index of this node.
96      */

97     public BrowserTreeNode(String JavaDoc text, String JavaDoc type, int index) {
98         this(text, type, index, null);
99     }
100
101     public BrowserTreeNode(String JavaDoc text, String JavaDoc type, int index, Object JavaDoc element) {
102         super(text);
103         this.type = type;
104         this.index = index;
105         this.element = element;
106     }
107
108     /**
109      * Get the type of the node as defined by the <tt>NODE_</tt> constants.
110      *
111      * @return the type
112      */

113     public String JavaDoc getType() {
114         return type;
115     }
116
117     /**
118      * Get the index of the node among its siblings. This information <i>could</i>
119      * be retrieved from a tree but is important structural information and
120      * should not be left to chance.
121      *
122      * @return the index
123      */

124     public int getIndex() {
125         return index;
126     }
127
128     /**
129      * Get the element associated with this node
130      *
131      * @return the element
132      */

133     public Object JavaDoc getElement() {
134         return element;
135     }
136 }
137
Popular Tags