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 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 33 public class Field extends Member implements Typed { 34 35 39 42 protected Type type; 43 44 45 49 52 public Field(Class c) { 53 super(c); 54 } 55 56 57 61 64 public Type getType() { 65 return type; 66 } 67 68 71 public void setType(Type t) { 72 type=t; 73 } 74 75 81 public Element buildXML(Document d) { 82 Element e=super.buildXML(d); 83 e.insertBefore(type.buildXML(d),e.getFirstChild()); 84 if (getCode()!=null) { 85 Element ee=d.createElement("initializer"); 86 ee.appendChild(getCode().buildXML(d)); 87 e.appendChild(ee); 88 } 89 return e; 90 } 91 92 98 public void initFromXML(Element element) throws IOException { 99 super.initFromXML(element); 101 102 Element ty=XMLToolbox.getChildRequired(element,"type"); 104 type=new Type(this); 105 type.initFromXML(ty); 106 107 Element in=XMLToolbox.getChild(element,"initializer"); 109 if (in!=null) { 110 code=new Code(); 111 code.initFromXML(XMLToolbox.getChildRequired(in,"code")); 112 } 113 else { 114 code=null; 115 } 116 } 117 118 124 void initFromAST(Node rootnode, Node varnode) { 125 super.initFromAST(rootnode); 126 String className=getDeclaringClass().getName(); 127 name=className+"."+varnode.getName(); 128 129 type=new Type(this); 130 type.initFromAST(rootnode, varnode); 132 Node codenode=varnode.getChild(JJT_CODE); 133 if (codenode!=null) { 135 code=new Code(); 136 code.initFromAST(varnode); } 138 else { 139 code=null; 140 } 141 } 142 143 } | Popular Tags |