1 19 20 package org.netbeans.modules.websvc.registry.jaxrpc; 21 22 23 public class Configuration { 24 25 private WsdlType wsdl; 26 27 public Configuration() { 28 } 29 30 public void setWsdl(WsdlType value) { 31 wsdl = value; 32 } 33 34 public WsdlType getWsdl() { 35 return wsdl; 36 } 37 38 public void write(java.io.OutputStream out) throws java.io.IOException { 39 write(out, null); 40 } 41 42 public void write(java.io.OutputStream out, String encoding) throws java.io.IOException { 43 java.io.Writer w; 44 if (encoding == null) { 45 encoding = "UTF-8"; } 47 w = new java.io.BufferedWriter (new java.io.OutputStreamWriter (out, encoding)); 48 write(w, encoding); 49 w.flush(); 50 } 51 52 public void write(java.io.Writer out, String encoding) throws java.io.IOException { 53 out.write("<?xml version='1.0'"); if (encoding != null) 55 out.write(" encoding='"+encoding+"'"); out.write(" ?>\n"); writeNode(out, "configuration", ""); } 59 60 public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException { 61 out.write(indent); 62 out.write("<"); 63 out.write(nodeName); 64 out.write(" xmlns='"); out.write("http://java.sun.com/xml/ns/jax-rpc/ri/config"); out.write("'"); out.write(">\n"); 68 String nextIndent = indent + " "; 69 if (wsdl != null) { 70 wsdl.writeNode(out, "wsdl", nextIndent); 71 } 72 out.write(indent); 73 out.write("</"+nodeName+">\n"); 74 } 75 76 public static Configuration read(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 77 return read(new org.xml.sax.InputSource (in), false, null, null); 78 } 79 80 public static Configuration read(org.xml.sax.InputSource in, boolean validate, org.xml.sax.EntityResolver er, org.xml.sax.ErrorHandler eh) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 81 javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance(); 82 dbf.setValidating(validate); 83 javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder(); 84 if (er != null) db.setEntityResolver(er); 85 if (eh != null) db.setErrorHandler(eh); 86 org.w3c.dom.Document doc = db.parse(in); 87 return read(doc); 88 } 89 90 public static Configuration read(org.w3c.dom.Document document) { 91 Configuration aConfiguration = new Configuration(); 92 aConfiguration.readNode(document.getDocumentElement()); 93 return aConfiguration; 94 } 95 96 public void readNode(org.w3c.dom.Node node) { 97 if (node.hasAttributes()) { 98 org.w3c.dom.NamedNodeMap attrs = node.getAttributes(); 99 org.w3c.dom.Attr attr; 100 java.lang.String attrValue; 101 attr = (org.w3c.dom.Attr ) attrs.getNamedItem("xsi:schemaLocation"); 102 if (attr != null) { 103 attrValue = attr.getValue(); 104 } else { 105 attrValue = null; 106 } 107 } 109 org.w3c.dom.NodeList children = node.getChildNodes(); 110 for (int i = 0, size = children.getLength(); i < size; ++i) { 111 org.w3c.dom.Node childNode = children.item(i); 112 String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern()); 113 String childNodeValue = ""; 114 if (childNode.getFirstChild() != null) { 115 childNodeValue = childNode.getFirstChild().getNodeValue(); 116 }else if (childNodeName == "wsdl") { 117 wsdl = new WsdlType(); 118 wsdl.readNode(childNode); 119 }else { 120 } 122 } 123 } 124 125 public static void writeXML(java.io.Writer out, String msg) throws java.io.IOException { 126 writeXML(out, msg, true); 127 } 128 129 public static void writeXML(java.io.Writer out, String msg, boolean attribute) throws java.io.IOException { 130 if (msg == null) 131 return; 132 int msgLength = msg.length(); 133 for (int i = 0; i < msgLength; ++i) { 134 char c = msg.charAt(i); 135 writeXML(out, c, attribute); 136 } 137 } 138 139 public static void writeXML(java.io.Writer out, char msg, boolean attribute) throws java.io.IOException { 140 if (msg == '&') 141 out.write("&"); 142 else if (msg == '<') 143 out.write("<"); 144 else if (msg == '>') 145 out.write(">"); 146 else if (attribute && msg == '"') 147 out.write("""); 148 else if (attribute && msg == '\'') 149 out.write("'"); 150 else if (attribute && msg == '\n') 151 out.write("
"); 152 else if (attribute && msg == '\t') 153 out.write("	"); 154 else 155 out.write(msg); 156 } 157 } 158 159 160 | Popular Tags |