diff options
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse')
5 files changed, 0 insertions, 432 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/DomElementHelper.java b/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/DomElementHelper.java deleted file mode 100644 index 97ea2bdd9..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/DomElementHelper.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.util; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; - -/** - * @author gilberta - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class DomElementHelper { - - - public static org.w3c.dom.Element createDomElementFromXMLString(java.lang.String xmlString ) - { - java.io.StringReader stringReader = new java.io.StringReader(xmlString); - org.xml.sax.InputSource inputSource = new org.xml.sax.InputSource(stringReader); - try - { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); - Document document = docBuilder.parse(inputSource); - return document.getDocumentElement(); - } - catch (Throwable t) - { - return null; - } - } - - public static java.lang.String domWriter(org.w3c.dom.Node node,java.lang.StringBuffer buffer) - { - if ( node == null ) { - return ""; - } - int type = node.getNodeType(); - switch ( type ) { - case org.w3c.dom.Node.DOCUMENT_NODE: { - buffer.append(JspUtils.markup("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + "<br>"); - domWriter(((org.w3c.dom.Document)node).getDocumentElement(),buffer); - break; - } - case org.w3c.dom.Node.ELEMENT_NODE: { - buffer.append(JspUtils.markup("<" + node.getNodeName())); - org.w3c.dom.Attr attrs[] = sortAttributes(node.getAttributes()); - for ( int i = 0; i < attrs.length; i++ ) { - org.w3c.dom.Attr attr = attrs[i]; - buffer.append(" " + attr.getNodeName() + "=\"" + JspUtils.markup(attr.getNodeValue()) + "\""); - } - buffer.append(JspUtils.markup(">")); - org.w3c.dom.NodeList children = node.getChildNodes(); - if ( children != null ) { - int len = children.getLength(); - for ( int i = 0; i < len; i++ ) { - if(((org.w3c.dom.Node)children.item(i)).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) - buffer.append("<br>"); - domWriter(children.item(i),buffer); - } - } - buffer.append(JspUtils.markup("</" + node.getNodeName() + ">")); - break; - } - case org.w3c.dom.Node.ENTITY_REFERENCE_NODE: { - org.w3c.dom.NodeList children = node.getChildNodes(); - if ( children != null ) { - int len = children.getLength(); - for ( int i = 0; i < len; i++ ) - { - buffer.append(children.item(i)); - } - } - break; - } - case org.w3c.dom.Node.CDATA_SECTION_NODE: { - buffer.append(JspUtils.markup(node.getNodeValue())); - break; - } - case org.w3c.dom.Node.TEXT_NODE:{ - buffer.append(JspUtils.markup(node.getNodeValue())); - break; - } - case org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE:{ - buffer.append(JspUtils.markup("<?")); - buffer.append(node.getNodeName()); - String data = node.getNodeValue(); - if ( data != null && data.length() > 0 ){ - buffer.append(" "); - buffer.append(data); - } - buffer.append(JspUtils.markup("?>")); - break; - } - } - return buffer.toString(); - } - - public static org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs) - { - int len = (attrs != null) ? attrs.getLength() : 0; - org.w3c.dom.Attr array[] = new org.w3c.dom.Attr[len]; - for ( int i = 0; i < len; i++ ){ - array[i] = (org.w3c.dom.Attr)attrs.item(i); - } - for ( int i = 0; i < len - 1; i++ ) { - String name = array[i].getNodeName(); - int index = i; - for ( int j = i + 1; j < len; j++ ) { - String curName = array[j].getNodeName(); - if ( curName.compareTo(name) < 0 ) { - name = curName; - index = j; - } - } - if ( index != i ) { - org.w3c.dom.Attr temp = array[i]; - array[i] = array[index]; - array[index] = temp; - } - } - return (array); - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/JspUtils.java b/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/JspUtils.java deleted file mode 100644 index abb9013e9..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/JspUtils.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.util; - -/** - * @author gilberta - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class JspUtils { - public static String markup(String text) { - if (text == null) { - return null; - } - - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < text.length(); i++) { - char c = text.charAt(i); - switch (c) { - case '<': - buffer.append("<"); - break; - case '&': - buffer.append("&"); - break; - case '>': - buffer.append(">"); - break; - case '"': - buffer.append("""); - break; - default: - buffer.append(c); - break; - } - } - return buffer.toString(); - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementHelper.java b/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementHelper.java deleted file mode 100644 index 18030062b..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005,2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060131 123963 andyzhai@ca.ibm.com - Andy Zhai - *******************************************************************************/ -package org.eclipse.jst.ws.util; - -import java.io.IOException; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.SAXException; - -/** - * @author gilberta - */ -public class SoapElementHelper -{ - public static javax.xml.soap.SOAPElement createSOAPElementFromXMLString(String xmlString) throws ParserConfigurationException, IOException, SAXException - { - java.io.StringReader stringReader = new java.io.StringReader(xmlString); - org.xml.sax.InputSource inputSource = new org.xml.sax.InputSource(stringReader); - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - SAXParser parser = factory.newSAXParser(); - SoapElementSaxHandler handler = new SoapElementSaxHandler(); - parser.parse(inputSource,handler); - return handler.getSOAPElement(); - } - - public static java.lang.String soapElementWriter(javax.xml.soap.SOAPElement node,java.lang.StringBuffer buffer) - { - if (node == null ) { - return ""; - } - - buffer.append(JspUtils.markup("<" + node.getElementName().getLocalName())); - java.util.Iterator attrs = node.getAllAttributes(); - while(attrs.hasNext()) { - javax.xml.soap.Name attr = (javax.xml.soap.Name)attrs.next(); - buffer.append(" " + attr.getQualifiedName() + "=\"" + JspUtils.markup(node.getAttributeValue(attr)) + "\""); - } - buffer.append(JspUtils.markup(">")); - java.util.Iterator children = node.getChildElements(); - if ( children != null ) { - while(children.hasNext()){ - javax.xml.soap.Node childNode = (javax.xml.soap.Node)children.next(); - if(childNode instanceof javax.xml.soap.SOAPElement){ - buffer.append("<br>"); - soapElementWriter((javax.xml.soap.SOAPElement)childNode,buffer); - } - else - buffer.append(JspUtils.markup(((javax.xml.soap.Text)childNode).getValue())); - } - buffer.append(JspUtils.markup("</" + node.getElementName().getLocalName() + ">")); - } - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementRuntimeException.java b/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementRuntimeException.java deleted file mode 100644 index 0d670fe3c..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementRuntimeException.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.util; - -/** - * @author gilberta - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class SoapElementRuntimeException extends Exception { - - /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = 3761693372674748471L; - -public SoapElementRuntimeException(String message){ - super(message); - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementSaxHandler.java b/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementSaxHandler.java deleted file mode 100644 index ac43cda9c..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/webserviceutils/org/eclipse/jst/ws/util/SoapElementSaxHandler.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060131 123963 andyzhai@ca.ibm.com - Andy Zhai - * 20090806 285933 ericdp@ca.ibm.com - Eric D. Peters, SOAPElementSaxHandler to create text nodes results in null return for char size 1 - *******************************************************************************/ - -package org.eclipse.jst.ws.util; - -import java.util.ArrayList; -import java.util.HashMap; - -import javax.xml.soap.Name; -import javax.xml.soap.SOAPElement; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * @author xinzhai - */ -public class SoapElementSaxHandler extends DefaultHandler -{ - //Stores all values of pairs of prefix and URI in the document - private HashMap prefixURIMapping = new HashMap(); - //Stores a list of URIs for a particular SOAP element - private ArrayList uris = new ArrayList(); - //Represents the whole(root) SOAP document - private SOAPElement rootElement = null; - //Represents the current SOAP element where SAX parser is reading - private SOAPElement currentElement = null; - private SOAPFactory soapFactory; - - public SOAPElement getSOAPElement() - { - return rootElement; - } - - public void startDocument() throws SAXException - { - try - { - soapFactory = SOAPFactory.newInstance(); - } - catch (SOAPException e) - { - throw new SAXException("Can't create a SOAPFactory instance", e); - } - } - - public void startPrefixMapping(String prefix, String uri) - { - prefixURIMapping.put(uri,prefix); - uris.add(uri); - } - - public void characters(char[] ch, int start, int length) throws SAXException - { - String str = String.valueOf(ch); - //Add non-trivial text as a text node - if (length > 0) - { - try - { - currentElement.addTextNode(str.substring(start,start+length)); - } - catch (SOAPException e) - { - throw new SAXException("Can't add a text node into SOAPElement from text", e); - } - } - } - - public void endElement (String uri, String localName, String qName) - { - if (currentElement != rootElement ) - { - currentElement = currentElement.getParentElement(); - } - } - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException - { - String prefix = (String)prefixURIMapping.get(namespaceURI); - try - { - // Create and/or add child element - if (rootElement == null && currentElement == null) - { - rootElement = soapFactory.createElement(localName,prefix,namespaceURI); - currentElement = rootElement; - } - else - { - currentElement = currentElement.addChildElement(localName,prefix,namespaceURI); - } - - // Add namespace declaration - if (uris.size() > 0) - { - for (int i = 0; i < uris.size(); i++) - { - String uri = (String)uris.get(i); - String pre = (String)prefixURIMapping.get(uri); - currentElement.addNamespaceDeclaration(pre,uri); - } - // Need to reset uris as we will use it for next element. - uris.clear(); - } - - // Add attibutes - for (int i =0; i<atts.getLength(); i++) - { - Name attriName; - if (atts.getURI(i) != null) - { - String attriPre = (String)prefixURIMapping.get(atts.getURI(i)); - attriName = soapFactory.createName(atts.getLocalName(i),attriPre,atts.getURI(i)); - } - else - { - attriName = soapFactory.createName(atts.getLocalName(i)); - } - currentElement.addAttribute(attriName, atts.getValue(i)); - } - } - catch (SOAPException e) - { - throw new SAXException(e); - } - } -} - |