001: /*
002: * Project: BeautyJ - Customizable Java Source Code Transformer
003: * Class: de.gulden.util.javasource.Exception
004: * Version: 1.0
005: *
006: * Date: 2002-10-27
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: * Represents a "throws" declaration, thrown by a method/constructor.
029: *
030: * @author Jens Gulden
031: * @version 1.0
032: */
033: public class Exception extends SourceObjectDeclared {
034:
035: // ------------------------------------------------------------------------
036: // --- field ---
037: // ------------------------------------------------------------------------
038: /**
039: * The my member executable.
040: */
041: public MemberExecutable myMemberExecutable;
042:
043: // ------------------------------------------------------------------------
044: // --- constructor ---
045: // ------------------------------------------------------------------------
046: /**
047: * Creates a new instance of Exception.
048: */
049: public Exception(MemberExecutable parent) {
050: myMemberExecutable = parent;
051: }
052:
053: // ------------------------------------------------------------------------
054: // --- methods ---
055: // ------------------------------------------------------------------------
056: /**
057: * Output this object as XML.
058: *
059: * @return The XML tag.
060: * @see #initFromXML
061: */
062: public Element buildXML(Document d) {
063: Element e = d.createElement("throws");
064: e.setAttribute("exception", getName());
065: return e;
066: }
067:
068: /**
069: * Overwrites SourceObjectDeclared.getDocumentation().
070: */
071: public Documentation getDocumentation() {
072: DocumentationDeclared dd = (DocumentationDeclared) myMemberExecutable
073: .getDocumentation();
074: if (dd != null) {
075: return dd.findTag("@exception", myMemberExecutable
076: .getDeclaringClass().qualify(this .getName()));
077: } else {
078: return null;
079: }
080: }
081:
082: /**
083: * Initialize this object from XML.
084: *
085: * @param element The XML tag.
086: * @throws IOException if an i/o error occurs
087: */
088: public void initFromXML(Element element) throws IOException {
089: // to be extended (not overwritten) by subclasses
090: super .initFromXML(element);
091: name = element.getAttribute("exception");
092: Parameter.addDocumentationToMember(
093: (DocumentationDeclared) getDocumentation(),
094: myMemberExecutable);
095: }
096:
097: /**
098: * Initialize this object from parsed Java code.
099: */
100: void initFromAST(Node namenode) {
101: String name = namenode.retrieveName();
102: setName(myMemberExecutable.getDeclaringClass().qualify(name));
103: }
104:
105: } // end Exception
|