1 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 javax.xml.parsers.*; 22 import org.w3c.dom.*; 23 import java.io.*; 24 import java.util.*; 25 26 32 public class Parameter extends SourceObjectDeclared implements Typed, ParserTreeConstants { 33 34 38 41 public MemberExecutable myMemberExecutable; 42 43 46 protected String name; 47 48 51 protected Type type; 52 53 54 58 61 public Parameter(MemberExecutable parent) { 62 myMemberExecutable=parent; 63 } 64 65 66 70 73 public String getName() { 74 return name; 75 } 76 77 80 public void setName(String n) { 81 name=n; 82 } 83 84 87 public Type getType() { 88 return type; 89 } 90 91 94 public void setType(Type t) { 95 type=t; 96 } 97 98 104 public Element buildXML(Document d) { 105 Element e=super.buildXML(d); 106 e.appendChild(getType().buildXML(d)); 107 return e; 108 } 109 110 116 public void initFromXML(Element element) throws IOException { 117 super.initFromXML(element); 119 name=element.getAttribute("name"); addDocumentationToMember((DocumentationDeclared)getDocumentation(),myMemberExecutable); 121 } 122 123 126 public Documentation getDocumentation() { 127 DocumentationDeclared dd=(DocumentationDeclared)myMemberExecutable.getDocumentation(); 129 if (dd!=null) { 130 return dd.findTag("@param",this.getName()); 131 } 132 else { 133 return null; 134 } 135 } 136 137 140 public MemberExecutable getMemberExecutable() { 141 return myMemberExecutable; 142 } 143 144 149 void initFromAST(Node rootnode) { 150 this.modifier=0; 152 if (rootnode.hasChild(JJT_FINAL)) { 153 this.modifier|=java.lang.reflect.Modifier.FINAL; 154 } 155 156 name=rootnode.getName(); 157 type=new Type(myMemberExecutable); 158 type.initFromAST(rootnode); } 160 161 162 166 169 static void addDocumentationToMember(DocumentationDeclared d, MemberExecutable mex) { 170 if (d!=null) { 171 DocumentationDeclared dd; 172 if (mex.getDocumentation()==null) { 173 dd=new DocumentationDeclared(); 174 dd.setText(""); 175 mex.setDocumentation(dd); 176 } 177 else { 178 dd=(DocumentationDeclared)mex.getDocumentation(); 179 } 180 for (Enumeration e=d.getTags();e.hasMoreElements();) { 181 DocumentationTagged dt=(DocumentationTagged)e.nextElement(); 182 dd.addTag(dt); 183 } 184 } 185 } 186 187 } | Popular Tags |