KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Project: BeautyJ - Customizable Java Source Code Transformer
3  * Class: de.gulden.util.javasource.Method
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 de.gulden.util.javasource.jjt.Node;
20 import de.gulden.util.javasource.jjt.*;
21 import de.gulden.util.xml.XMLToolbox;
22 import javax.xml.parsers.*;
23 import org.w3c.dom.*;
24 import java.io.*;
25 import java.util.*;
26
27 /**
28  * Class Method.
29  *
30  * @author Jens Gulden
31  * @version 1.0
32  */

33 public class Method extends MemberExecutable implements Typed {
34
35     // ------------------------------------------------------------------------
36
// --- field ---
37
// ------------------------------------------------------------------------
38

39     /**
40      * The type.
41      */

42     protected Type type;
43
44
45     // ------------------------------------------------------------------------
46
// --- constructor ---
47
// ------------------------------------------------------------------------
48

49     /**
50      * Creates a new instance of Method.
51      */

52     public Method(Class JavaDoc c) {
53         super(c);
54     }
55
56
57     // ------------------------------------------------------------------------
58
// --- methods ---
59
// ------------------------------------------------------------------------
60

61     /**
62      * Returns the type.
63      */

64     public Type getType() {
65         return type;
66     }
67
68     /**
69      * Sets the type.
70      */

71     public void setType(Type t) {
72         type=t;
73     }
74
75     /**
76      * Initialize this object from XML.
77      *
78      * @param element The XML tag.
79      * @throws IOException if an i/o error occurs
80      */

81     public void initFromXML(Element element) throws IOException {
82         // to be extended (not overwritten) by subclasses
83
super.initFromXML(element);
84
85         // type
86
Element ty=XMLToolbox.getChildRequired(element,"type");
87         type=new Type(this);
88         type.initFromXML(ty);
89     }
90
91     /**
92      * Output this object as XML.
93      *
94      * @return The XML tag.
95      * @see #initFromXML
96      */

97     public Element buildXML(Document d) {
98         Element e=super.buildXML(d);
99         e.insertBefore(type.buildXML(d),e.getFirstChild());
100         return e;
101     }
102
103     /**
104      * Initialize this object from parsed Java code.
105      *
106      * @param rootnode The corresponding node in the abstract syntax tree (AST).
107      */

108     void initFromAST(Node rootnode) {
109         super.initFromAST(rootnode); // sets name
110
type=new Type(this);
111         type.initFromAST(rootnode); // special way of invoking (using rootnode)
112
}
113
114 } // end Method
115
Popular Tags