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 abstract class Import extends SourceObject implements ParserTreeConstants { 34 35 41 public Import(Package p) { 42 myPackage=p; 43 } 44 45 46 54 public abstract String qualify(String name); 55 56 62 public Element buildXML(Document d) { 63 String tagName=getXMLName(); 66 Element e=d.createElement(tagName); 67 e.appendChild(d.createTextNode(getName())); 68 return e; 69 } 70 71 74 protected String getXMLName() { 75 return "import"; 76 } 77 78 79 88 public static Import createFromXML(Package parent, Element element) throws IOException { 89 String name=XMLToolbox.getText(element); String kind=element.getAttribute("kind"); 91 boolean isClass=kind.equals("class"); 92 if (!isClass) { 93 return new ImportPackage(parent,name); 94 } 95 else { 96 return new ImportClass(parent,name); 97 } 98 } 99 100 104 static Import createFromAST(Package p, Node node) { 105 Import im; 106 if (node.getChild(JJT_PACKAGEIMPORT)!=null) { 108 im=new ImportPackage(p); 109 im.setName(node.getName()+".*"); 110 } 111 else { 112 im=new ImportClass(p); 113 im.setName(node.getName()); 114 } 115 return im; 116 } 117 118 } | Popular Tags |