You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2006/08/25 15:17:37 UTC
svn commit: r436785 [4/18] - in /incubator/cxf/trunk: ./ api/
api/src/main/java/org/apache/cxf/buslifecycle/
api/src/main/java/org/apache/cxf/databinding/
api/src/main/java/org/apache/cxf/endpoint/
api/src/main/java/org/apache/cxf/interceptor/ api/src/...
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java Fri Aug 25 06:16:36 2006
@@ -1,324 +1,324 @@
-package org.apache.cxf.helpers;
-
-import java.io.File;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.*;
-import javax.jws.WebParam;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Part;
-import javax.wsdl.PortType;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.soap.SOAPHeader;
-import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.ws.RequestWrapper;
-
-public class WSDLHelper {
-
- public BindingOperation getBindingOperation(Definition def, String operationName) {
- if (operationName == null) {
- return null;
- }
- Iterator ite = def.getBindings().values().iterator();
- while (ite.hasNext()) {
- Binding binding = (Binding)ite.next();
- Iterator ite1 = binding.getBindingOperations().iterator();
- while (ite1.hasNext()) {
- BindingOperation bop = (BindingOperation)ite1.next();
- if (bop.getName().equals(operationName)) {
- return bop;
- }
- }
- }
- return null;
- }
-
- public BindingOperation getBindingOperation(Binding binding, String operationName) {
- if (operationName == null) {
- return null;
- }
- List bindingOperations = binding.getBindingOperations();
- for (Iterator iter = bindingOperations.iterator(); iter.hasNext();) {
- BindingOperation bindingOperation = (BindingOperation)iter.next();
- if (operationName.equals(bindingOperation.getName())) {
- return bindingOperation;
- }
- }
- return null;
- }
-
- public Map getParts(Operation operation, boolean out) {
- Message message = null;
- if (out) {
- Output output = operation.getOutput();
- message = output.getMessage();
- } else {
- Input input = operation.getInput();
- message = input.getMessage();
- }
- return message.getParts() == null ? new HashMap() : message.getParts();
- }
-
- public javax.jws.soap.SOAPBinding getBindingAnnotationFromClass(List<Class<?>> classList) {
- javax.jws.soap.SOAPBinding sb = null;
- for (Class<?> c : classList) {
- sb = c.getAnnotation(javax.jws.soap.SOAPBinding.class);
- if (null != sb) {
- break;
- }
- }
- return sb;
- }
-
- public javax.jws.soap.SOAPBinding getBindingAnnotationFromMethod(Method m) {
- javax.jws.soap.SOAPBinding sb = null;
- if (null != m) {
- sb = m.getAnnotation(javax.jws.soap.SOAPBinding.class);
- }
- return sb;
- }
-
- public WebParam getWebParamAnnotation(Annotation[] pa) {
- WebParam wp = null;
-
- if (null != pa) {
- for (Annotation annotation : pa) {
- if (WebParam.class.equals(annotation.annotationType())) {
- wp = (WebParam)annotation;
- break;
- }
- }
- }
- return wp;
- }
-
- public RequestWrapper getRequestWrapperAnnotation(Method m) {
- RequestWrapper rw = null;
-
- if (null != m) {
- rw = m.getAnnotation(RequestWrapper.class);
- }
- return rw;
- }
-
- public List<PortType> getPortTypes(Definition def) {
- List<PortType> portTypes = new ArrayList<PortType>();
- Iterator ite = def.getPortTypes().values().iterator();
- while (ite.hasNext()) {
- PortType portType = (PortType)ite.next();
- portTypes.add(portType);
- }
- return portTypes;
- }
-
- public List<Part> getInMessageParts(Operation operation) {
- Input input = operation.getInput();
- List<Part> partsList = new ArrayList<Part>();
- if (input != null) {
- Iterator ite = input.getMessage().getParts().values().iterator();
- while (ite.hasNext()) {
- partsList.add((Part)ite.next());
- }
- }
- return partsList;
- }
-
- public List<Part> getOutMessageParts(Operation operation) {
- Output output = operation.getOutput();
- List<Part> partsList = new ArrayList<Part>();
- if (output != null) {
- Iterator ite = output.getMessage().getParts().values().iterator();
- while (ite.hasNext()) {
- partsList.add((Part)ite.next());
- }
- }
- return partsList;
- }
-
- public String getBindingStyle(Binding binding) {
- Iterator ite = binding.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPBinding) {
- return ((SOAPBinding)obj).getStyle();
- }
- }
- return "";
- }
-
- public Binding getBinding(BindingOperation bop, Definition def) {
- Iterator ite = def.getBindings().values().iterator();
- while (ite.hasNext()) {
- Binding binding = (Binding)ite.next();
- for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2.hasNext();) {
- BindingOperation bindingOperation = (BindingOperation)ite2.next();
- if (bindingOperation.getName().equals(bop)) {
- return binding;
- }
- }
- }
- return null;
- }
-
- public String getSOAPOperationStyle(BindingOperation bop) {
- String style = "";
- Iterator ite = bop.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPOperation) {
- SOAPOperation soapOperation = (SOAPOperation)obj;
- style = soapOperation.getStyle();
- break;
- }
- }
- return style;
-
- }
-
- public SOAPBody getBindingInputSOAPBody(BindingOperation bop) {
- BindingInput bindingInput = bop.getBindingInput();
- if (bindingInput != null) {
- Iterator ite = bindingInput.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPBody) {
- return (SOAPBody)obj;
- }
- }
- }
-
- return null;
- }
-
- public SOAPHeader getBindingInputSOAPHeader(BindingOperation bop) {
- BindingInput bindingInput = bop.getBindingInput();
- if (bindingInput != null) {
- Iterator ite = bindingInput.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPHeader) {
- return (SOAPHeader)obj;
- }
- }
- }
-
- return null;
- }
-
- public SOAPHeader getBindingOutputSOAPHeader(BindingOperation bop) {
- BindingOutput bindingOutput = bop.getBindingOutput();
- if (bindingOutput != null) {
- Iterator ite = bindingOutput.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPHeader) {
- return (SOAPHeader)obj;
- }
- }
- }
-
- return null;
- }
-
- public SOAPBody getBindingOutputSOAPBody(BindingOperation bop) {
- BindingOutput bindingOutput = bop.getBindingOutput();
- if (bindingOutput != null) {
- Iterator ite = bindingOutput.getExtensibilityElements().iterator();
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPBody) {
- return (SOAPBody)obj;
- }
- }
- }
-
- return null;
- }
-
- public Definition getDefinition(File wsdlFile) throws Exception {
- WSDLFactory wsdlFactory = WSDLFactory.newInstance();
- WSDLReader reader = wsdlFactory.newWSDLReader();
- reader.setFeature("javax.wsdl.verbose", false);
- return reader.readWSDL(wsdlFile.toURL().toString());
- }
-
- public boolean isMixedStyle(Binding binding) {
- Iterator ite = binding.getExtensibilityElements().iterator();
- String bindingStyle = "";
- String previousOpStyle = "";
- String style = "";
- while (ite.hasNext()) {
- Object obj = ite.next();
- if (obj instanceof SOAPBinding) {
- SOAPBinding soapBinding = (SOAPBinding)obj;
- bindingStyle = soapBinding.getStyle();
- if (bindingStyle == null) {
- bindingStyle = "";
- }
- }
- }
- Iterator ite2 = binding.getBindingOperations().iterator();
- while (ite2.hasNext()) {
- BindingOperation bop = (BindingOperation)ite2.next();
- Iterator ite3 = bop.getExtensibilityElements().iterator();
- while (ite3.hasNext()) {
- Object obj = ite3.next();
-
- if (obj instanceof SOAPOperation) {
- SOAPOperation soapOperation = (SOAPOperation)obj;
- style = soapOperation.getStyle();
- if (style == null) {
- style = "";
- }
-
- if ("".equals(bindingStyle) && "".equals(previousOpStyle) || "".equals(bindingStyle)
- && previousOpStyle.equalsIgnoreCase(style)) {
- previousOpStyle = style;
-
- } else if (!"".equals(bindingStyle) && "".equals(previousOpStyle)
- && bindingStyle.equalsIgnoreCase(style)
- || bindingStyle.equalsIgnoreCase(previousOpStyle)
- && bindingStyle.equalsIgnoreCase(style)) {
- previousOpStyle = style;
- } else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
- continue;
- } else {
- return true;
- }
-
- }
-
- }
- }
-
- return false;
-
- }
-
- public String getCanonicalBindingStyle(Binding binding) {
- String bindingStyle = getBindingStyle(binding);
- if (bindingStyle != null && !("".equals(bindingStyle))) {
- return bindingStyle;
- }
- for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2.hasNext();) {
- BindingOperation bindingOp = (BindingOperation)ite2.next();
- String bopStyle = getSOAPOperationStyle(bindingOp);
- if (!"".equals(bopStyle)) {
- return bopStyle;
- }
- }
- return "";
-
- }
-}
+package org.apache.cxf.helpers;
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.*;
+import javax.jws.WebParam;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.ws.RequestWrapper;
+
+public class WSDLHelper {
+
+ public BindingOperation getBindingOperation(Definition def, String operationName) {
+ if (operationName == null) {
+ return null;
+ }
+ Iterator ite = def.getBindings().values().iterator();
+ while (ite.hasNext()) {
+ Binding binding = (Binding)ite.next();
+ Iterator ite1 = binding.getBindingOperations().iterator();
+ while (ite1.hasNext()) {
+ BindingOperation bop = (BindingOperation)ite1.next();
+ if (bop.getName().equals(operationName)) {
+ return bop;
+ }
+ }
+ }
+ return null;
+ }
+
+ public BindingOperation getBindingOperation(Binding binding, String operationName) {
+ if (operationName == null) {
+ return null;
+ }
+ List bindingOperations = binding.getBindingOperations();
+ for (Iterator iter = bindingOperations.iterator(); iter.hasNext();) {
+ BindingOperation bindingOperation = (BindingOperation)iter.next();
+ if (operationName.equals(bindingOperation.getName())) {
+ return bindingOperation;
+ }
+ }
+ return null;
+ }
+
+ public Map getParts(Operation operation, boolean out) {
+ Message message = null;
+ if (out) {
+ Output output = operation.getOutput();
+ message = output.getMessage();
+ } else {
+ Input input = operation.getInput();
+ message = input.getMessage();
+ }
+ return message.getParts() == null ? new HashMap() : message.getParts();
+ }
+
+ public javax.jws.soap.SOAPBinding getBindingAnnotationFromClass(List<Class<?>> classList) {
+ javax.jws.soap.SOAPBinding sb = null;
+ for (Class<?> c : classList) {
+ sb = c.getAnnotation(javax.jws.soap.SOAPBinding.class);
+ if (null != sb) {
+ break;
+ }
+ }
+ return sb;
+ }
+
+ public javax.jws.soap.SOAPBinding getBindingAnnotationFromMethod(Method m) {
+ javax.jws.soap.SOAPBinding sb = null;
+ if (null != m) {
+ sb = m.getAnnotation(javax.jws.soap.SOAPBinding.class);
+ }
+ return sb;
+ }
+
+ public WebParam getWebParamAnnotation(Annotation[] pa) {
+ WebParam wp = null;
+
+ if (null != pa) {
+ for (Annotation annotation : pa) {
+ if (WebParam.class.equals(annotation.annotationType())) {
+ wp = (WebParam)annotation;
+ break;
+ }
+ }
+ }
+ return wp;
+ }
+
+ public RequestWrapper getRequestWrapperAnnotation(Method m) {
+ RequestWrapper rw = null;
+
+ if (null != m) {
+ rw = m.getAnnotation(RequestWrapper.class);
+ }
+ return rw;
+ }
+
+ public List<PortType> getPortTypes(Definition def) {
+ List<PortType> portTypes = new ArrayList<PortType>();
+ Iterator ite = def.getPortTypes().values().iterator();
+ while (ite.hasNext()) {
+ PortType portType = (PortType)ite.next();
+ portTypes.add(portType);
+ }
+ return portTypes;
+ }
+
+ public List<Part> getInMessageParts(Operation operation) {
+ Input input = operation.getInput();
+ List<Part> partsList = new ArrayList<Part>();
+ if (input != null) {
+ Iterator ite = input.getMessage().getParts().values().iterator();
+ while (ite.hasNext()) {
+ partsList.add((Part)ite.next());
+ }
+ }
+ return partsList;
+ }
+
+ public List<Part> getOutMessageParts(Operation operation) {
+ Output output = operation.getOutput();
+ List<Part> partsList = new ArrayList<Part>();
+ if (output != null) {
+ Iterator ite = output.getMessage().getParts().values().iterator();
+ while (ite.hasNext()) {
+ partsList.add((Part)ite.next());
+ }
+ }
+ return partsList;
+ }
+
+ public String getBindingStyle(Binding binding) {
+ Iterator ite = binding.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPBinding) {
+ return ((SOAPBinding)obj).getStyle();
+ }
+ }
+ return "";
+ }
+
+ public Binding getBinding(BindingOperation bop, Definition def) {
+ Iterator ite = def.getBindings().values().iterator();
+ while (ite.hasNext()) {
+ Binding binding = (Binding)ite.next();
+ for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2.hasNext();) {
+ BindingOperation bindingOperation = (BindingOperation)ite2.next();
+ if (bindingOperation.getName().equals(bop)) {
+ return binding;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getSOAPOperationStyle(BindingOperation bop) {
+ String style = "";
+ Iterator ite = bop.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPOperation) {
+ SOAPOperation soapOperation = (SOAPOperation)obj;
+ style = soapOperation.getStyle();
+ break;
+ }
+ }
+ return style;
+
+ }
+
+ public SOAPBody getBindingInputSOAPBody(BindingOperation bop) {
+ BindingInput bindingInput = bop.getBindingInput();
+ if (bindingInput != null) {
+ Iterator ite = bindingInput.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPBody) {
+ return (SOAPBody)obj;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public SOAPHeader getBindingInputSOAPHeader(BindingOperation bop) {
+ BindingInput bindingInput = bop.getBindingInput();
+ if (bindingInput != null) {
+ Iterator ite = bindingInput.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPHeader) {
+ return (SOAPHeader)obj;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public SOAPHeader getBindingOutputSOAPHeader(BindingOperation bop) {
+ BindingOutput bindingOutput = bop.getBindingOutput();
+ if (bindingOutput != null) {
+ Iterator ite = bindingOutput.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPHeader) {
+ return (SOAPHeader)obj;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public SOAPBody getBindingOutputSOAPBody(BindingOperation bop) {
+ BindingOutput bindingOutput = bop.getBindingOutput();
+ if (bindingOutput != null) {
+ Iterator ite = bindingOutput.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPBody) {
+ return (SOAPBody)obj;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public Definition getDefinition(File wsdlFile) throws Exception {
+ WSDLFactory wsdlFactory = WSDLFactory.newInstance();
+ WSDLReader reader = wsdlFactory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ return reader.readWSDL(wsdlFile.toURL().toString());
+ }
+
+ public boolean isMixedStyle(Binding binding) {
+ Iterator ite = binding.getExtensibilityElements().iterator();
+ String bindingStyle = "";
+ String previousOpStyle = "";
+ String style = "";
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof SOAPBinding) {
+ SOAPBinding soapBinding = (SOAPBinding)obj;
+ bindingStyle = soapBinding.getStyle();
+ if (bindingStyle == null) {
+ bindingStyle = "";
+ }
+ }
+ }
+ Iterator ite2 = binding.getBindingOperations().iterator();
+ while (ite2.hasNext()) {
+ BindingOperation bop = (BindingOperation)ite2.next();
+ Iterator ite3 = bop.getExtensibilityElements().iterator();
+ while (ite3.hasNext()) {
+ Object obj = ite3.next();
+
+ if (obj instanceof SOAPOperation) {
+ SOAPOperation soapOperation = (SOAPOperation)obj;
+ style = soapOperation.getStyle();
+ if (style == null) {
+ style = "";
+ }
+
+ if ("".equals(bindingStyle) && "".equals(previousOpStyle) || "".equals(bindingStyle)
+ && previousOpStyle.equalsIgnoreCase(style)) {
+ previousOpStyle = style;
+
+ } else if (!"".equals(bindingStyle) && "".equals(previousOpStyle)
+ && bindingStyle.equalsIgnoreCase(style)
+ || bindingStyle.equalsIgnoreCase(previousOpStyle)
+ && bindingStyle.equalsIgnoreCase(style)) {
+ previousOpStyle = style;
+ } else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
+ continue;
+ } else {
+ return true;
+ }
+
+ }
+
+ }
+ }
+
+ return false;
+
+ }
+
+ public String getCanonicalBindingStyle(Binding binding) {
+ String bindingStyle = getBindingStyle(binding);
+ if (bindingStyle != null && !("".equals(bindingStyle))) {
+ return bindingStyle;
+ }
+ for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2.hasNext();) {
+ BindingOperation bindingOp = (BindingOperation)ite2.next();
+ String bopStyle = getSOAPOperationStyle(bindingOp);
+ if (!"".equals(bopStyle)) {
+ return bopStyle;
+ }
+ }
+ return "";
+
+ }
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/WSDLHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java Fri Aug 25 06:16:36 2006
@@ -1,220 +1,220 @@
-package org.apache.cxf.helpers;
-
-import java.io.*;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.wsdl.Definition;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-
-import org.apache.cxf.common.logging.LogUtils;
-
-
-public class XMLUtils {
-
- private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
- private final DocumentBuilderFactory parserFactory;
- private final TransformerFactory transformerFactory;
- private String omitXmlDecl = "no";
- private String charset = "utf-8";
- private int indent = -1;
-
- public XMLUtils() {
- parserFactory = DocumentBuilderFactory.newInstance();
- parserFactory.setNamespaceAware(true);
-
- transformerFactory = TransformerFactory.newInstance();
- }
-
- private Transformer newTransformer() throws TransformerConfigurationException {
- return transformerFactory.newTransformer();
- }
-
- private DocumentBuilder getParser() throws ParserConfigurationException {
- return parserFactory.newDocumentBuilder();
- }
-
- public Document parse(InputStream in)
- throws ParserConfigurationException, SAXException, IOException {
- if (in == null && LOG.isLoggable(Level.FINE)) {
- LOG.fine("XMLUtils trying to parse a null inputstream");
- }
- return getParser().parse(in);
- }
-
- public Document parse(String in)
- throws ParserConfigurationException, SAXException, IOException {
- return parse(in.getBytes());
- }
-
- public Document parse(byte[] in)
- throws ParserConfigurationException, SAXException, IOException {
- if (in == null && LOG.isLoggable(Level.FINE)) {
- LOG.fine("XMLUtils trying to parse a null bytes");
- }
- return getParser().parse(new ByteArrayInputStream(in));
- }
-
- public Document newDocument() throws ParserConfigurationException {
- return getParser().newDocument();
- }
-
- public void setOmitXmlDecl(String value) {
- this.omitXmlDecl = value;
- }
-
- public void setCharsetEncoding(String value) {
- this.charset = value;
- }
-
- public void setIndention(int i) {
- this.indent = i;
- }
-
- private boolean indent() {
- return this.indent != -1;
- }
-
- public void writeTo(Node node, OutputStream os) {
- try {
- Transformer it = newTransformer();
-
- it.setOutputProperty(OutputKeys.METHOD, "xml");
- if (indent()) {
- it.setOutputProperty(OutputKeys.INDENT, "yes");
- it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
- Integer.toString(this.indent));
- }
- it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
- it.setOutputProperty(OutputKeys.ENCODING, charset);
- it.transform(new DOMSource(node), new StreamResult(os));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public String toString(Node node) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- writeTo(node, out);
- return out.toString();
- }
-
- public void printDOM(Node node) {
- printDOM("", node);
- }
-
- public void printDOM(String words, Node node) {
- System.out.println(words);
- System.out.println(toString(node));
- }
-
- public Attr getAttribute(Element el, String attrName) {
- return el.getAttributeNode(attrName);
- }
-
- public void replaceAttribute(Element element, String attr, String value) {
- if (element.hasAttribute(attr)) {
- element.removeAttribute(attr);
- }
- element.setAttribute(attr, value);
- }
-
- public boolean hasAttribute(Element element, String value) {
- NamedNodeMap attributes = element.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Node node = attributes.item(i);
- if (value.equals(node.getNodeValue())) {
- return true;
- }
- }
- return false;
- }
-
- public static void printAttributes(Element element) {
- NamedNodeMap attributes = element.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Node node = attributes.item(i);
- System.err.println("## prefix=" + node.getPrefix() + " localname:"
- + node.getLocalName() + " value=" + node.getNodeValue());
- }
- }
-
- public QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) {
- String prefix = null;
- String localName = null;
-
- StringTokenizer tokenizer = new StringTokenizer(str, ":");
- if (tokenizer.countTokens() == 2) {
- prefix = tokenizer.nextToken();
- localName = tokenizer.nextToken();
- } else if (tokenizer.countTokens() == 1) {
- localName = tokenizer.nextToken();
- }
-
- String namespceURI = defaultNamespace;
- if (prefix != null) {
- namespceURI = (String)namespaces.get(prefix);
- }
- return new QName(namespceURI, localName);
- }
-
- public void generateXMLFile(Element element, Writer writer) {
- try {
- Transformer it = newTransformer();
-
- it.setOutputProperty(OutputKeys.METHOD, "xml");
- it.setOutputProperty(OutputKeys.INDENT, "yes");
- it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- it.transform(new DOMSource(element), new StreamResult(writer));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public Element createElementNS(Node node, QName name) {
- return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(), name.getLocalPart());
- }
-
- public Element createElementNS(Document root, QName name) {
- return createElementNS(root, name.getNamespaceURI(), name.getLocalPart());
- }
-
- public Element createElementNS(Document root, String namespaceURI, String qualifiedName) {
- return root.createElementNS(namespaceURI, qualifiedName);
- }
-
- public Text createTextNode(Document root, String data) {
- return root.createTextNode(data);
- }
-
- public Text createTextNode(Node node, String data) {
- return createTextNode(node.getOwnerDocument(), data);
- }
-
- public void removeContents(Node node) {
- NodeList list = node.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node entry = list.item(i);
- node.removeChild(entry);
- }
- }
-
- public String writeQName(Definition def, QName qname) {
- return def.getPrefix(qname.getNamespaceURI()) + ":" + qname.getLocalPart();
- }
-
-}
+package org.apache.cxf.helpers;
+
+import java.io.*;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+
+public class XMLUtils {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
+ private final DocumentBuilderFactory parserFactory;
+ private final TransformerFactory transformerFactory;
+ private String omitXmlDecl = "no";
+ private String charset = "utf-8";
+ private int indent = -1;
+
+ public XMLUtils() {
+ parserFactory = DocumentBuilderFactory.newInstance();
+ parserFactory.setNamespaceAware(true);
+
+ transformerFactory = TransformerFactory.newInstance();
+ }
+
+ private Transformer newTransformer() throws TransformerConfigurationException {
+ return transformerFactory.newTransformer();
+ }
+
+ private DocumentBuilder getParser() throws ParserConfigurationException {
+ return parserFactory.newDocumentBuilder();
+ }
+
+ public Document parse(InputStream in)
+ throws ParserConfigurationException, SAXException, IOException {
+ if (in == null && LOG.isLoggable(Level.FINE)) {
+ LOG.fine("XMLUtils trying to parse a null inputstream");
+ }
+ return getParser().parse(in);
+ }
+
+ public Document parse(String in)
+ throws ParserConfigurationException, SAXException, IOException {
+ return parse(in.getBytes());
+ }
+
+ public Document parse(byte[] in)
+ throws ParserConfigurationException, SAXException, IOException {
+ if (in == null && LOG.isLoggable(Level.FINE)) {
+ LOG.fine("XMLUtils trying to parse a null bytes");
+ }
+ return getParser().parse(new ByteArrayInputStream(in));
+ }
+
+ public Document newDocument() throws ParserConfigurationException {
+ return getParser().newDocument();
+ }
+
+ public void setOmitXmlDecl(String value) {
+ this.omitXmlDecl = value;
+ }
+
+ public void setCharsetEncoding(String value) {
+ this.charset = value;
+ }
+
+ public void setIndention(int i) {
+ this.indent = i;
+ }
+
+ private boolean indent() {
+ return this.indent != -1;
+ }
+
+ public void writeTo(Node node, OutputStream os) {
+ try {
+ Transformer it = newTransformer();
+
+ it.setOutputProperty(OutputKeys.METHOD, "xml");
+ if (indent()) {
+ it.setOutputProperty(OutputKeys.INDENT, "yes");
+ it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
+ Integer.toString(this.indent));
+ }
+ it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
+ it.setOutputProperty(OutputKeys.ENCODING, charset);
+ it.transform(new DOMSource(node), new StreamResult(os));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String toString(Node node) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writeTo(node, out);
+ return out.toString();
+ }
+
+ public void printDOM(Node node) {
+ printDOM("", node);
+ }
+
+ public void printDOM(String words, Node node) {
+ System.out.println(words);
+ System.out.println(toString(node));
+ }
+
+ public Attr getAttribute(Element el, String attrName) {
+ return el.getAttributeNode(attrName);
+ }
+
+ public void replaceAttribute(Element element, String attr, String value) {
+ if (element.hasAttribute(attr)) {
+ element.removeAttribute(attr);
+ }
+ element.setAttribute(attr, value);
+ }
+
+ public boolean hasAttribute(Element element, String value) {
+ NamedNodeMap attributes = element.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node node = attributes.item(i);
+ if (value.equals(node.getNodeValue())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void printAttributes(Element element) {
+ NamedNodeMap attributes = element.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node node = attributes.item(i);
+ System.err.println("## prefix=" + node.getPrefix() + " localname:"
+ + node.getLocalName() + " value=" + node.getNodeValue());
+ }
+ }
+
+ public QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) {
+ String prefix = null;
+ String localName = null;
+
+ StringTokenizer tokenizer = new StringTokenizer(str, ":");
+ if (tokenizer.countTokens() == 2) {
+ prefix = tokenizer.nextToken();
+ localName = tokenizer.nextToken();
+ } else if (tokenizer.countTokens() == 1) {
+ localName = tokenizer.nextToken();
+ }
+
+ String namespceURI = defaultNamespace;
+ if (prefix != null) {
+ namespceURI = (String)namespaces.get(prefix);
+ }
+ return new QName(namespceURI, localName);
+ }
+
+ public void generateXMLFile(Element element, Writer writer) {
+ try {
+ Transformer it = newTransformer();
+
+ it.setOutputProperty(OutputKeys.METHOD, "xml");
+ it.setOutputProperty(OutputKeys.INDENT, "yes");
+ it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ it.transform(new DOMSource(element), new StreamResult(writer));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Element createElementNS(Node node, QName name) {
+ return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(), name.getLocalPart());
+ }
+
+ public Element createElementNS(Document root, QName name) {
+ return createElementNS(root, name.getNamespaceURI(), name.getLocalPart());
+ }
+
+ public Element createElementNS(Document root, String namespaceURI, String qualifiedName) {
+ return root.createElementNS(namespaceURI, qualifiedName);
+ }
+
+ public Text createTextNode(Document root, String data) {
+ return root.createTextNode(data);
+ }
+
+ public Text createTextNode(Node node, String data) {
+ return createTextNode(node.getOwnerDocument(), data);
+ }
+
+ public void removeContents(Node node) {
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node entry = list.item(i);
+ node.removeChild(entry);
+ }
+ }
+
+ public String writeQName(Definition def, QName qname) {
+ return def.getPrefix(qname.getNamespaceURI()) + ":" + qname.getLocalPart();
+ }
+
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/Instrumentation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/InstrumentationFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/InstrumentationManager.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedAttribute.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedNotification.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedNotifications.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedOperation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedOperationParameter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedOperationParameters.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/management/annotation/ManagedResource.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/ClassLoaderResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/ClasspathResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/Messages.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/Messages.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/ResourceManager.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/ResourceResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/ResourceResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java Fri Aug 25 06:16:36 2006
@@ -1,125 +1,125 @@
-package org.apache.cxf.resource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-
-/**
- * Resolves a File, classpath resource, or URL according to the follow rules:
- * <ul>
- * <li>Check to see if a File exists with the specified URI.</li>
- * <li>Attempt to create URI from the uri string directly and create an
- * InputStream from it.</li>
- * <li>Check to see if a File exists relative to the specified base URI.</li>
- * <li>Attempt to create URI relative to the base URI and create an InputStream
- * from it.</li>
- * <li>If the classpath doesn't exist, try to create URL from the URI.</li>
- * </ul>
- *
- * @author Dan Diephouse
- */
-public class URIResolver {
- private File file;
- private URI uri;
- private InputStream is;
-
- public URIResolver(String path) throws IOException {
- this("", path);
- }
-
- public URIResolver(String baseUriStr, String uriStr) throws IOException {
- try {
- URI relative;
- File uriFile = new File(uriStr);
- uriFile = new File(uriFile.getAbsolutePath());
- if (uriFile.exists()) {
- relative = uriFile.toURI();
- } else {
- relative = new URI(uriStr);
- }
-
- if (relative.isAbsolute()) {
- uri = relative;
- is = relative.toURL().openStream();
- } else if (baseUriStr != null) {
- URI base;
- File baseFile = new File(baseUriStr);
- if (baseFile.exists()) {
- base = baseFile.toURI();
- } else {
- base = new URI(baseUriStr);
- }
-
- base = base.resolve(relative);
- if (base.isAbsolute()) {
- is = base.toURL().openStream();
- uri = base;
- }
- }
- } catch (URISyntaxException e) {
- // Do nothing
- }
-
- if (uri != null && "file".equals(uri.getScheme())) {
- file = new File(uri);
- }
-
- if (is == null && file != null && file.exists()) {
- uri = file.toURI();
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- throw new RuntimeException("File was deleted! " + uriStr, e);
- }
- } else if (is == null) {
- URL url = ClassLoaderUtils.getResource(uriStr, getClass());
-
- if (url == null) {
- try {
- url = new URL(uriStr);
- uri = new URI(url.toString());
- is = url.openStream();
- } catch (MalformedURLException e) {
- // Do nothing
- } catch (URISyntaxException e) {
- // Do nothing
- }
- } else {
- is = url.openStream();
- }
- }
-
- if (is == null) {
- throw new IOException("Could not find resource '" + uriStr
- + "' relative to '" + baseUriStr + "'");
- }
- }
-
- public URI getURI() {
- return uri;
- }
-
- public InputStream getInputStream() {
- return is;
- }
-
- public boolean isFile() {
- return file.exists();
- }
-
- public File getFile() {
- return file;
- }
-
- public boolean isResolved() {
- return uri != null;
- }
-}
+package org.apache.cxf.resource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+
+/**
+ * Resolves a File, classpath resource, or URL according to the follow rules:
+ * <ul>
+ * <li>Check to see if a File exists with the specified URI.</li>
+ * <li>Attempt to create URI from the uri string directly and create an
+ * InputStream from it.</li>
+ * <li>Check to see if a File exists relative to the specified base URI.</li>
+ * <li>Attempt to create URI relative to the base URI and create an InputStream
+ * from it.</li>
+ * <li>If the classpath doesn't exist, try to create URL from the URI.</li>
+ * </ul>
+ *
+ * @author Dan Diephouse
+ */
+public class URIResolver {
+ private File file;
+ private URI uri;
+ private InputStream is;
+
+ public URIResolver(String path) throws IOException {
+ this("", path);
+ }
+
+ public URIResolver(String baseUriStr, String uriStr) throws IOException {
+ try {
+ URI relative;
+ File uriFile = new File(uriStr);
+ uriFile = new File(uriFile.getAbsolutePath());
+ if (uriFile.exists()) {
+ relative = uriFile.toURI();
+ } else {
+ relative = new URI(uriStr);
+ }
+
+ if (relative.isAbsolute()) {
+ uri = relative;
+ is = relative.toURL().openStream();
+ } else if (baseUriStr != null) {
+ URI base;
+ File baseFile = new File(baseUriStr);
+ if (baseFile.exists()) {
+ base = baseFile.toURI();
+ } else {
+ base = new URI(baseUriStr);
+ }
+
+ base = base.resolve(relative);
+ if (base.isAbsolute()) {
+ is = base.toURL().openStream();
+ uri = base;
+ }
+ }
+ } catch (URISyntaxException e) {
+ // Do nothing
+ }
+
+ if (uri != null && "file".equals(uri.getScheme())) {
+ file = new File(uri);
+ }
+
+ if (is == null && file != null && file.exists()) {
+ uri = file.toURI();
+ try {
+ is = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("File was deleted! " + uriStr, e);
+ }
+ } else if (is == null) {
+ URL url = ClassLoaderUtils.getResource(uriStr, getClass());
+
+ if (url == null) {
+ try {
+ url = new URL(uriStr);
+ uri = new URI(url.toString());
+ is = url.openStream();
+ } catch (MalformedURLException e) {
+ // Do nothing
+ } catch (URISyntaxException e) {
+ // Do nothing
+ }
+ } else {
+ is = url.openStream();
+ }
+ }
+
+ if (is == null) {
+ throw new IOException("Could not find resource '" + uriStr
+ + "' relative to '" + baseUriStr + "'");
+ }
+ }
+
+ public URI getURI() {
+ return uri;
+ }
+
+ public InputStream getInputStream() {
+ return is;
+ }
+
+ public boolean isFile() {
+ return file.exists();
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public boolean isResolved() {
+ return uri != null;
+ }
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/resource/URIResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java Fri Aug 25 06:16:36 2006
@@ -1,240 +1,240 @@
-package org.apache.cxf.staxutils;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-public class DepthXMLStreamReader implements XMLStreamReader {
-
- protected XMLStreamReader reader;
- private int depth;
-
- public DepthXMLStreamReader(XMLStreamReader r) {
- this.reader = r;
- }
-
- public XMLStreamReader getReader() {
- return this.reader;
- }
-
- public int getDepth() {
- return depth;
- }
-
- public void close() throws XMLStreamException {
- reader.close();
- }
-
- public int getAttributeCount() {
- return reader.getAttributeCount();
- }
-
- public String getAttributeLocalName(int arg0) {
- return reader.getAttributeLocalName(arg0);
- }
-
- public QName getAttributeName(int arg0) {
- return reader.getAttributeName(arg0);
- }
-
- public String getAttributeNamespace(int arg0) {
- return reader.getAttributeNamespace(arg0);
- }
-
- public String getAttributePrefix(int arg0) {
- return reader.getAttributePrefix(arg0);
- }
-
- public String getAttributeType(int arg0) {
- return reader.getAttributeType(arg0);
- }
-
- public String getAttributeValue(int arg0) {
- return reader.getAttributeValue(arg0);
- }
-
- public String getAttributeValue(String arg0, String arg1) {
- return reader.getAttributeValue(arg0, arg1);
- }
-
- public String getCharacterEncodingScheme() {
- return reader.getCharacterEncodingScheme();
- }
-
- public String getElementText() throws XMLStreamException {
- return reader.getElementText();
- }
-
- public String getEncoding() {
- return reader.getEncoding();
- }
-
- public int getEventType() {
- return reader.getEventType();
- }
-
- public String getLocalName() {
- return reader.getLocalName();
- }
-
- public Location getLocation() {
- return reader.getLocation();
- }
-
- public QName getName() {
- return reader.getName();
- }
-
- public NamespaceContext getNamespaceContext() {
- return reader.getNamespaceContext();
- }
-
- public int getNamespaceCount() {
- return reader.getNamespaceCount();
- }
-
- public String getNamespacePrefix(int arg0) {
- return reader.getNamespacePrefix(arg0);
- }
-
- public String getNamespaceURI() {
- return reader.getNamespaceURI();
- }
-
- public String getNamespaceURI(int arg0) {
-
- return reader.getNamespaceURI(arg0);
- }
-
- public String getNamespaceURI(String arg0) {
- return reader.getNamespaceURI(arg0);
- }
-
- public String getPIData() {
- return reader.getPIData();
- }
-
- public String getPITarget() {
- return reader.getPITarget();
- }
-
- public String getPrefix() {
- return reader.getPrefix();
- }
-
- public Object getProperty(String arg0) throws IllegalArgumentException {
-
- return reader.getProperty(arg0);
- }
-
- public String getText() {
- return reader.getText();
- }
-
- public char[] getTextCharacters() {
- return reader.getTextCharacters();
- }
-
- public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException {
- return reader.getTextCharacters(arg0, arg1, arg2, arg3);
- }
-
- public int getTextLength() {
- return reader.getTextLength();
- }
-
- public int getTextStart() {
- return reader.getTextStart();
- }
-
- public String getVersion() {
- return reader.getVersion();
- }
-
- public boolean hasName() {
- return reader.hasName();
- }
-
- public boolean hasNext() throws XMLStreamException {
- return reader.hasNext();
- }
-
- public boolean hasText() {
- return reader.hasText();
- }
-
- public boolean isAttributeSpecified(int arg0) {
- return reader.isAttributeSpecified(arg0);
- }
-
- public boolean isCharacters() {
- return reader.isCharacters();
- }
-
- public boolean isEndElement() {
- return reader.isEndElement();
- }
-
- public boolean isStandalone() {
- return reader.isStandalone();
- }
-
- public boolean isStartElement() {
- return reader.isStartElement();
- }
-
- public boolean isWhiteSpace() {
- return reader.isWhiteSpace();
- }
-
- public int next() throws XMLStreamException {
- int next = reader.next();
-
- if (next == START_ELEMENT) {
- depth++;
- } else if (next == END_ELEMENT) {
- depth--;
- }
-
- return next;
- }
-
- public int nextTag() throws XMLStreamException {
- int eventType = next();
- while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace())
- || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
- // skip whitespace
- || eventType == XMLStreamConstants.SPACE
- || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
- || eventType == XMLStreamConstants.COMMENT) {
- eventType = next();
- }
- if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
- throw new XMLStreamException("expected start or end tag", getLocation());
- }
- return eventType;
- }
-
- public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
- reader.require(arg0, arg1, arg2);
- }
-
- public boolean standaloneSet() {
- return reader.standaloneSet();
- }
-
- public int hashCode() {
- return reader.hashCode();
- }
-
- public boolean equals(Object arg0) {
- return reader.equals(arg0);
- }
-
- public String toString() {
- return reader.toString();
- }
-}
+package org.apache.cxf.staxutils;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+public class DepthXMLStreamReader implements XMLStreamReader {
+
+ protected XMLStreamReader reader;
+ private int depth;
+
+ public DepthXMLStreamReader(XMLStreamReader r) {
+ this.reader = r;
+ }
+
+ public XMLStreamReader getReader() {
+ return this.reader;
+ }
+
+ public int getDepth() {
+ return depth;
+ }
+
+ public void close() throws XMLStreamException {
+ reader.close();
+ }
+
+ public int getAttributeCount() {
+ return reader.getAttributeCount();
+ }
+
+ public String getAttributeLocalName(int arg0) {
+ return reader.getAttributeLocalName(arg0);
+ }
+
+ public QName getAttributeName(int arg0) {
+ return reader.getAttributeName(arg0);
+ }
+
+ public String getAttributeNamespace(int arg0) {
+ return reader.getAttributeNamespace(arg0);
+ }
+
+ public String getAttributePrefix(int arg0) {
+ return reader.getAttributePrefix(arg0);
+ }
+
+ public String getAttributeType(int arg0) {
+ return reader.getAttributeType(arg0);
+ }
+
+ public String getAttributeValue(int arg0) {
+ return reader.getAttributeValue(arg0);
+ }
+
+ public String getAttributeValue(String arg0, String arg1) {
+ return reader.getAttributeValue(arg0, arg1);
+ }
+
+ public String getCharacterEncodingScheme() {
+ return reader.getCharacterEncodingScheme();
+ }
+
+ public String getElementText() throws XMLStreamException {
+ return reader.getElementText();
+ }
+
+ public String getEncoding() {
+ return reader.getEncoding();
+ }
+
+ public int getEventType() {
+ return reader.getEventType();
+ }
+
+ public String getLocalName() {
+ return reader.getLocalName();
+ }
+
+ public Location getLocation() {
+ return reader.getLocation();
+ }
+
+ public QName getName() {
+ return reader.getName();
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return reader.getNamespaceContext();
+ }
+
+ public int getNamespaceCount() {
+ return reader.getNamespaceCount();
+ }
+
+ public String getNamespacePrefix(int arg0) {
+ return reader.getNamespacePrefix(arg0);
+ }
+
+ public String getNamespaceURI() {
+ return reader.getNamespaceURI();
+ }
+
+ public String getNamespaceURI(int arg0) {
+
+ return reader.getNamespaceURI(arg0);
+ }
+
+ public String getNamespaceURI(String arg0) {
+ return reader.getNamespaceURI(arg0);
+ }
+
+ public String getPIData() {
+ return reader.getPIData();
+ }
+
+ public String getPITarget() {
+ return reader.getPITarget();
+ }
+
+ public String getPrefix() {
+ return reader.getPrefix();
+ }
+
+ public Object getProperty(String arg0) throws IllegalArgumentException {
+
+ return reader.getProperty(arg0);
+ }
+
+ public String getText() {
+ return reader.getText();
+ }
+
+ public char[] getTextCharacters() {
+ return reader.getTextCharacters();
+ }
+
+ public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException {
+ return reader.getTextCharacters(arg0, arg1, arg2, arg3);
+ }
+
+ public int getTextLength() {
+ return reader.getTextLength();
+ }
+
+ public int getTextStart() {
+ return reader.getTextStart();
+ }
+
+ public String getVersion() {
+ return reader.getVersion();
+ }
+
+ public boolean hasName() {
+ return reader.hasName();
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return reader.hasNext();
+ }
+
+ public boolean hasText() {
+ return reader.hasText();
+ }
+
+ public boolean isAttributeSpecified(int arg0) {
+ return reader.isAttributeSpecified(arg0);
+ }
+
+ public boolean isCharacters() {
+ return reader.isCharacters();
+ }
+
+ public boolean isEndElement() {
+ return reader.isEndElement();
+ }
+
+ public boolean isStandalone() {
+ return reader.isStandalone();
+ }
+
+ public boolean isStartElement() {
+ return reader.isStartElement();
+ }
+
+ public boolean isWhiteSpace() {
+ return reader.isWhiteSpace();
+ }
+
+ public int next() throws XMLStreamException {
+ int next = reader.next();
+
+ if (next == START_ELEMENT) {
+ depth++;
+ } else if (next == END_ELEMENT) {
+ depth--;
+ }
+
+ return next;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ int eventType = next();
+ while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace())
+ || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
+ // skip whitespace
+ || eventType == XMLStreamConstants.SPACE
+ || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+ || eventType == XMLStreamConstants.COMMENT) {
+ eventType = next();
+ }
+ if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
+ throw new XMLStreamException("expected start or end tag", getLocation());
+ }
+ return eventType;
+ }
+
+ public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
+ reader.require(arg0, arg1, arg2);
+ }
+
+ public boolean standaloneSet() {
+ return reader.standaloneSet();
+ }
+
+ public int hashCode() {
+ return reader.hashCode();
+ }
+
+ public boolean equals(Object arg0) {
+ return reader.equals(arg0);
+ }
+
+ public String toString() {
+ return reader.toString();
+ }
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/DepthXMLStreamReader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java Fri Aug 25 06:16:36 2006
@@ -1,95 +1,95 @@
-package org.apache.cxf.staxutils;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-/**
- * Wraps a XMLStreamReader and provides START_DOCUMENT and END_DOCUMENT events.
- *
- * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
- */
-public class FragmentStreamReader extends DepthXMLStreamReader {
- private boolean startDoc;
- private boolean startElement;
- private boolean middle = true;
- private boolean endDoc;
-
- private int depth;
- private int current = -1;
- private boolean filter = true;
- private boolean advanceAtEnd = true;
-
- public FragmentStreamReader(XMLStreamReader reader) {
- super(reader);
- }
-
- public int getEventType() {
- return current;
- }
-
- public boolean hasNext() throws XMLStreamException {
- if (!startDoc) {
- return true;
- }
-
- if (endDoc) {
- return false;
- }
-
- return reader.hasNext();
- }
-
- public int next() throws XMLStreamException {
- if (!startDoc) {
- startDoc = true;
- current = START_DOCUMENT;
- } else if (!startElement) {
- depth = getDepth();
-
- current = reader.getEventType();
-
- if (filter) {
- while (current != START_ELEMENT && depth >= getDepth() && super.hasNext()) {
- current = super.next();
- }
-
- filter = false;
- }
-
- startElement = true;
- current = START_ELEMENT;
- } else if (middle) {
- current = super.next();
-
- if (current == END_ELEMENT && getDepth() < depth) {
- middle = false;
- }
- } else if (!endDoc) {
- // Move past the END_ELEMENT token.
- if (advanceAtEnd) {
- super.next();
- }
-
- endDoc = true;
- current = END_DOCUMENT;
- } else {
- throw new XMLStreamException("Already at the end of the document.");
- }
-
- return current;
- }
-
- public boolean isAdvanceAtEnd() {
- return advanceAtEnd;
- }
-
- /**
- * Set whether or not the FragmentStreamReader should move past the END_ELEMENT
- * when it is done parsing.
- * @param advanceAtEnd
- */
- public void setAdvanceAtEnd(boolean a) {
- this.advanceAtEnd = a;
- }
-
-}
+package org.apache.cxf.staxutils;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Wraps a XMLStreamReader and provides START_DOCUMENT and END_DOCUMENT events.
+ *
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class FragmentStreamReader extends DepthXMLStreamReader {
+ private boolean startDoc;
+ private boolean startElement;
+ private boolean middle = true;
+ private boolean endDoc;
+
+ private int depth;
+ private int current = -1;
+ private boolean filter = true;
+ private boolean advanceAtEnd = true;
+
+ public FragmentStreamReader(XMLStreamReader reader) {
+ super(reader);
+ }
+
+ public int getEventType() {
+ return current;
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ if (!startDoc) {
+ return true;
+ }
+
+ if (endDoc) {
+ return false;
+ }
+
+ return reader.hasNext();
+ }
+
+ public int next() throws XMLStreamException {
+ if (!startDoc) {
+ startDoc = true;
+ current = START_DOCUMENT;
+ } else if (!startElement) {
+ depth = getDepth();
+
+ current = reader.getEventType();
+
+ if (filter) {
+ while (current != START_ELEMENT && depth >= getDepth() && super.hasNext()) {
+ current = super.next();
+ }
+
+ filter = false;
+ }
+
+ startElement = true;
+ current = START_ELEMENT;
+ } else if (middle) {
+ current = super.next();
+
+ if (current == END_ELEMENT && getDepth() < depth) {
+ middle = false;
+ }
+ } else if (!endDoc) {
+ // Move past the END_ELEMENT token.
+ if (advanceAtEnd) {
+ super.next();
+ }
+
+ endDoc = true;
+ current = END_DOCUMENT;
+ } else {
+ throw new XMLStreamException("Already at the end of the document.");
+ }
+
+ return current;
+ }
+
+ public boolean isAdvanceAtEnd() {
+ return advanceAtEnd;
+ }
+
+ /**
+ * Set whether or not the FragmentStreamReader should move past the END_ELEMENT
+ * when it is done parsing.
+ * @param advanceAtEnd
+ */
+ public void setAdvanceAtEnd(boolean a) {
+ this.advanceAtEnd = a;
+ }
+
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java?rev=436785&r1=436784&r2=436785&view=diff
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java Fri Aug 25 06:16:36 2006
@@ -1,35 +1,35 @@
-package org.apache.cxf.staxutils;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.StreamFilter;
-import javax.xml.stream.XMLStreamReader;
-
-public class StaxStreamFilter implements StreamFilter {
- private QName[] tags;
-
- public StaxStreamFilter(QName[] eventsToReject) {
- tags = eventsToReject;
- }
-
- public boolean accept(XMLStreamReader reader) {
-
- if (reader.isStartElement()) {
- QName elName = reader.getName();
- for (QName tag : tags) {
- if (elName.equals(tag)) {
- return false;
- }
- }
- }
-
- if (reader.isEndElement()) {
- QName elName = reader.getName();
- for (QName tag : tags) {
- if (elName.equals(tag)) {
- return false;
- }
- }
- }
- return true;
- }
-}
+package org.apache.cxf.staxutils;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLStreamReader;
+
+public class StaxStreamFilter implements StreamFilter {
+ private QName[] tags;
+
+ public StaxStreamFilter(QName[] eventsToReject) {
+ tags = eventsToReject;
+ }
+
+ public boolean accept(XMLStreamReader reader) {
+
+ if (reader.isStartElement()) {
+ QName elName = reader.getName();
+ for (QName tag : tags) {
+ if (elName.equals(tag)) {
+ return false;
+ }
+ }
+ }
+
+ if (reader.isEndElement()) {
+ QName elName = reader.getName();
+ for (QName tag : tags) {
+ if (elName.equals(tag)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxStreamFilter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date