KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > util > javasource > ClassInner


1 /*
2  * Project: BeautyJ - Customizable Java Source Code Transformer
3  * Class: de.gulden.util.javasource.ClassInner
4  * Version: 1.1
5  *
6  * Date: 2004-09-29
7  *
8  * Note: Contains auto-generated Javadoc comments created by BeautyJ.
9  *
10  * This is licensed under the GNU General Public License (GPL)
11  * and comes with NO WARRANTY. See file license.txt for details.
12  *
13  * Author: Jens Gulden
14  * Email: beautyj@jensgulden.de
15  */

16
17 package de.gulden.util.javasource;
18
19 import javax.xml.parsers.*;
20 import org.w3c.dom.*;
21 import java.util.*;
22
23 /**
24  * Represents an inner class declaration.
25  *
26  * @author Jens Gulden
27  * @version 1.0
28  */

29 public class ClassInner extends Class JavaDoc {
30
31     // ------------------------------------------------------------------------
32
// --- field ---
33
// ------------------------------------------------------------------------
34

35     /**
36      */

37     public Vector myClass;
38
39
40     // ------------------------------------------------------------------------
41
// --- constructor ---
42
// ------------------------------------------------------------------------
43

44     /**
45      * Creates a new instance of ClassInner.
46      */

47     public ClassInner() {
48         super();
49     }
50
51
52     // ------------------------------------------------------------------------
53
// --- methods ---
54
// ------------------------------------------------------------------------
55

56     /**
57      * Sets the class within which this SourceObjectDeclared is declared.
58      */

59     public void setDeclaringClass(Class JavaDoc declaring) {
60         super.setDeclaringClass(declaring);
61         setPackage(declaring.getPackage());
62         myImport=declaring.myImport;
63     }
64
65     /**
66      * Returns the name.
67      */

68     public String JavaDoc getName() {
69         return getDeclaringClass().getName()+"."+getUnqualifiedName();
70     }
71
72     /**
73      * Gets the unqualified name of this, that means the name without any leading package information.
74      */

75     public String JavaDoc getUnqualifiedName() {
76         return unqualify(name);
77     }
78
79     /**
80      * Output this object as XML.
81      *
82      * @return The XML tag.
83      * @see #initFromXML
84      */

85     public Element buildXML(Document d) {
86         Element e=super.buildXML(d);
87         Element outer=d.createElement("outerclass");
88         outer.appendChild(d.createTextNode(getDeclaringClass().getName()));
89         e.appendChild(outer);
90         return e;
91     }
92
93     /**
94      * Fully qualifies a class identifier, taking into account the current
95      * package of this class and the import statements.
96      *
97      * @return The fully qualified class identifier.
98      */

99     protected String JavaDoc qualifyInternal(String JavaDoc name) {
100         String JavaDoc q = super.qualifyInternal(name);
101         if (q==null) {
102             q = getDeclaringClass().qualifyInternal(name); // will also find inner classes of this
103
}
104            return q;
105     }
106
107     protected void registerAtPackage(Package JavaDoc p) {
108         // overwrites Class.registerAtPackage
109
// nop
110
}
111
112 } // end ClassInner
113
Popular Tags