1 22 23 package org.enhydra.kelp.common.bridge; 24 25 import org.enhydra.xml.xmlc.dom.XMLCDocument; 27 import org.w3c.dom.*; 28 29 import org.enhydra.kelp.common.Constants; 31 32 import java.io.*; 34 import java.util.ResourceBundle ; 35 import java.util.Vector ; 36 37 abstract public class PrintInfo { 38 private final String ARROW = " => "; private static ResourceBundle res = ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); 42 45 protected Vector urls = new Vector (); 46 47 50 protected Vector ids = new Vector (); 51 52 55 public PrintInfo(Document doc, XMLCDocument xmlcDoc) { 56 getNodeInfo(doc, xmlcDoc); 57 } 58 59 62 public void printInfo(PrintWriter out) { 63 out.println(res.getString("Element_IDs")); 64 for (int i = 0; i < ids.size(); i++) { 65 out.println(Constants.TAB4 + ids.elementAt(i).toString()); 66 } 67 out.println(res.getString("Document_URLs")); 68 for (int i = 0; i < urls.size(); i++) { 69 out.println(Constants.TAB4 + urls.elementAt(i).toString()); 70 } 71 } 72 73 abstract protected void getElementURLs(Element element, XMLCDocument xmlcDoc); 74 75 76 79 private void getNodeInfo(Node node, XMLCDocument xmlcDoc) { 80 if (node instanceof Element) { 81 Element elem = (Element)node; 82 getElementURLs(elem, xmlcDoc); 83 String id = xmlcDoc.getElementId(elem); 84 if ((id != null) && (id.length() > 0)) { 85 ids.addElement(id + ARROW 86 + xmlcDoc.nodeClassToInterface(node)); 87 } 88 } 89 90 for (Node child = node.getFirstChild(); child != null; 91 child = child.getNextSibling()) { 92 getNodeInfo(child, xmlcDoc); 93 } 94 } 95 96 } | Popular Tags |