KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Project: BeautyJ - Customizable Java Source Code Transformer
3  * Class: de.gulden.util.javasource.Exception
4  * Version: 1.0
5  *
6  * Date: 2002-10-27
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  * Represents a "throws" declaration, thrown by a method/constructor.
29  *
30  * @author Jens Gulden
31  * @version 1.0
32  */

33 public class Exception extends SourceObjectDeclared {
34
35     // ------------------------------------------------------------------------
36
// --- field ---
37
// ------------------------------------------------------------------------
38
/**
39      * The my member executable.
40      */

41     public MemberExecutable myMemberExecutable;
42
43
44     // ------------------------------------------------------------------------
45
// --- constructor ---
46
// ------------------------------------------------------------------------
47
/**
48      * Creates a new instance of Exception.
49      */

50     public Exception(MemberExecutable parent) {
51         myMemberExecutable=parent;
52     }
53
54
55     // ------------------------------------------------------------------------
56
// --- methods ---
57
// ------------------------------------------------------------------------
58
/**
59      * Output this object as XML.
60      *
61      * @return The XML tag.
62      * @see #initFromXML
63      */

64     public Element buildXML(Document d) {
65         Element e=d.createElement("throws");
66         e.setAttribute("exception",getName());
67         return e;
68     }
69
70     /**
71      * Overwrites SourceObjectDeclared.getDocumentation().
72      */

73     public Documentation getDocumentation() {
74         DocumentationDeclared dd=(DocumentationDeclared)myMemberExecutable.getDocumentation();
75         if (dd!=null) {
76             return dd.findTag("@exception",myMemberExecutable.getDeclaringClass().qualify(this.getName()));
77         }
78         else {
79             return null;
80         }
81     }
82
83     /**
84      * Initialize this object from XML.
85      *
86      * @param element The XML tag.
87      * @throws IOException if an i/o error occurs
88      */

89     public void initFromXML(Element element) throws IOException {
90         // to be extended (not overwritten) by subclasses
91
super.initFromXML(element);
92         name=element.getAttribute("exception");
93         Parameter.addDocumentationToMember((DocumentationDeclared)getDocumentation(),myMemberExecutable);
94     }
95
96     /**
97      * Initialize this object from parsed Java code.
98      */

99     void initFromAST(Node namenode) {
100         String JavaDoc name=namenode.retrieveName();
101         setName(myMemberExecutable.getDeclaringClass().qualify(name));
102     }
103
104 } // end Exception
105
Popular Tags