001: /*
002: * Project: BeautyJ - Customizable Java Source Code Transformer
003: * Class: de.gulden.util.javasource.Method
004: * Version: 1.1
005: *
006: * Date: 2004-09-29
007: *
008: * Note: Contains auto-generated Javadoc comments created by BeautyJ.
009: *
010: * This is licensed under the GNU General Public License (GPL)
011: * and comes with NO WARRANTY. See file license.txt for details.
012: *
013: * Author: Jens Gulden
014: * Email: beautyj@jensgulden.de
015: */
016:
017: package de.gulden.util.javasource;
018:
019: import de.gulden.util.javasource.jjt.Node;
020: import de.gulden.util.javasource.jjt.*;
021: import de.gulden.util.xml.XMLToolbox;
022: import javax.xml.parsers.*;
023: import org.w3c.dom.*;
024: import java.io.*;
025: import java.util.*;
026:
027: /**
028: * Class Method.
029: *
030: * @author Jens Gulden
031: * @version 1.0
032: */
033: public class Method extends MemberExecutable implements Typed {
034:
035: // ------------------------------------------------------------------------
036: // --- field ---
037: // ------------------------------------------------------------------------
038:
039: /**
040: * The type.
041: */
042: protected Type type;
043:
044: // ------------------------------------------------------------------------
045: // --- constructor ---
046: // ------------------------------------------------------------------------
047:
048: /**
049: * Creates a new instance of Method.
050: */
051: public Method(Class c) {
052: super (c);
053: }
054:
055: // ------------------------------------------------------------------------
056: // --- methods ---
057: // ------------------------------------------------------------------------
058:
059: /**
060: * Returns the type.
061: */
062: public Type getType() {
063: return type;
064: }
065:
066: /**
067: * Sets the type.
068: */
069: public void setType(Type t) {
070: type = t;
071: }
072:
073: /**
074: * Initialize this object from XML.
075: *
076: * @param element The XML tag.
077: * @throws IOException if an i/o error occurs
078: */
079: public void initFromXML(Element element) throws IOException {
080: // to be extended (not overwritten) by subclasses
081: super .initFromXML(element);
082:
083: // type
084: Element ty = XMLToolbox.getChildRequired(element, "type");
085: type = new Type(this );
086: type.initFromXML(ty);
087: }
088:
089: /**
090: * Output this object as XML.
091: *
092: * @return The XML tag.
093: * @see #initFromXML
094: */
095: public Element buildXML(Document d) {
096: Element e = super .buildXML(d);
097: e.insertBefore(type.buildXML(d), e.getFirstChild());
098: return e;
099: }
100:
101: /**
102: * Initialize this object from parsed Java code.
103: *
104: * @param rootnode The corresponding node in the abstract syntax tree (AST).
105: */
106: void initFromAST(Node rootnode) {
107: super .initFromAST(rootnode); // sets name
108: type = new Type(this );
109: type.initFromAST(rootnode); // special way of invoking (using rootnode)
110: }
111:
112: } // end Method
|