cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r438845 - in /incubator/cxf/trunk: common/src/main/java/org/apache/cxf/helpers/ tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/ tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/ tools/common...
Date Thu, 31 Aug 2006 08:57:40 GMT
Author: ffang
Date: Thu Aug 31 01:57:39 2006
New Revision: 438845

URL: http://svn.apache.org/viewvc?rev=438845&view=rev
Log:
using static method for XMLUtils

Modified:
    incubator/cxf/trunk/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressParser.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatBindingSerializer.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatParser.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatSerializer.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLHttpSerializer.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/generator/HandlerConfigGenerator.java

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=438845&r1=438844&r2=438845&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 Thu Aug
31 01:57:39 2006
@@ -42,31 +42,35 @@
 import org.apache.cxf.common.logging.LogUtils;
 
 
-public class XMLUtils {
+public final 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;
+    private static DocumentBuilderFactory parserFactory;
+    private static TransformerFactory transformerFactory;
+    private static String omitXmlDecl = "no";
+    private static String charset = "utf-8";
+    private static int indent = -1;
     
-    public XMLUtils() {
+    static {
         parserFactory = DocumentBuilderFactory.newInstance();
         parserFactory.setNamespaceAware(true);
         
         transformerFactory = TransformerFactory.newInstance();
     }
-
-    private Transformer newTransformer() throws TransformerConfigurationException {
+    
+    private XMLUtils() {
+        
+    }
+    
+    private static  Transformer newTransformer() throws TransformerConfigurationException
{
         return transformerFactory.newTransformer();
     }
 
-    private DocumentBuilder getParser() throws ParserConfigurationException {
+    private static DocumentBuilder getParser() throws ParserConfigurationException {
         return parserFactory.newDocumentBuilder();
     }
     
-    public Document parse(InputStream in) 
+    public static Document parse(InputStream in) 
         throws ParserConfigurationException, SAXException, IOException {
         if (in == null && LOG.isLoggable(Level.FINE)) {
             LOG.fine("XMLUtils trying to parse a null inputstream");
@@ -74,12 +78,12 @@
         return getParser().parse(in);
     }
 
-    public Document parse(String in) 
+    public static Document parse(String in) 
         throws ParserConfigurationException, SAXException, IOException {
         return parse(in.getBytes());
     }
 
-    public Document parse(byte[] in) 
+    public static Document parse(byte[] in) 
         throws ParserConfigurationException, SAXException, IOException {
         if (in == null && LOG.isLoggable(Level.FINE)) {
             LOG.fine("XMLUtils trying to parse a null bytes");
@@ -87,27 +91,27 @@
         return getParser().parse(new ByteArrayInputStream(in));
     }
 
-    public Document newDocument() throws ParserConfigurationException {
+    public static Document newDocument() throws ParserConfigurationException {
         return getParser().newDocument();
     }
 
-    public void setOmitXmlDecl(String value) {
-        this.omitXmlDecl = value;        
+    public static void setOmitXmlDecl(String value) {
+        omitXmlDecl = value;        
     }
     
-    public void setCharsetEncoding(String value) {
-        this.charset = value;
+    public static void setCharsetEncoding(String value) {
+        charset = value;
     }
 
-    public void setIndention(int i) {
-        this.indent = i;
+    public static void setIndention(int i) {
+        indent = i;
     }
 
-    private boolean indent() {
-        return this.indent != -1;
+    private static boolean indent() {
+        return indent != -1;
     }
     
-    public void writeTo(Node node, OutputStream os) {
+    public static void writeTo(Node node, OutputStream os) {
         try {
             Transformer it = newTransformer();
             
@@ -115,7 +119,7 @@
             if (indent()) {
                 it.setOutputProperty(OutputKeys.INDENT, "yes");
                 it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-                                     Integer.toString(this.indent));
+                                     Integer.toString(indent));
             }
             it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
             it.setOutputProperty(OutputKeys.ENCODING, charset);
@@ -125,33 +129,33 @@
         }
     }
     
-    public String toString(Node node) {
+    public static String toString(Node node) {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         writeTo(node, out);
         return out.toString();
     }
 
-    public void printDOM(Node node) {
+    public static void printDOM(Node node) {
         printDOM("", node);
     }
 
-    public void printDOM(String words, Node node) {
+    public static void printDOM(String words, Node node) {
         System.out.println(words);
         System.out.println(toString(node));
     }
 
-    public Attr getAttribute(Element el, String attrName) {
+    public static Attr getAttribute(Element el, String attrName) {
         return el.getAttributeNode(attrName);
     }
 
-    public void replaceAttribute(Element element, String attr, String value) {
+    public static 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) {
+    public static boolean hasAttribute(Element element, String value) {
         NamedNodeMap attributes = element.getAttributes();
         for (int i = 0; i < attributes.getLength(); i++) {
             Node node = attributes.item(i);
@@ -171,7 +175,7 @@
         }
     }
 
-    public QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace)
{
+    public static QName getNamespace(Map<String, String> namespaces, String str, String
defaultNamespace) {
         String prefix = null;
         String localName = null;
         
@@ -190,7 +194,7 @@
         return new QName(namespceURI, localName);
     }
 
-    public void generateXMLFile(Element element, Writer writer) {
+    public static void generateXMLFile(Element element, Writer writer) {
         try {
             Transformer it = newTransformer();
             
@@ -204,27 +208,27 @@
         }
     }
 
-    public Element createElementNS(Node node, QName name) {
+    public static Element createElementNS(Node node, QName name) {
         return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(), name.getLocalPart());
     }
 
-    public Element createElementNS(Document root, QName name) {
+    public static Element createElementNS(Document root, QName name) {
         return createElementNS(root, name.getNamespaceURI(), name.getLocalPart());
     }
     
-    public Element createElementNS(Document root, String namespaceURI, String qualifiedName)
{
+    public static Element createElementNS(Document root, String namespaceURI, String qualifiedName)
{
         return root.createElementNS(namespaceURI, qualifiedName);
     }
 
-    public Text createTextNode(Document root, String data) {
+    public static Text createTextNode(Document root, String data) {
         return root.createTextNode(data);
     }
 
-    public Text createTextNode(Node node, String data) {
+    public static Text createTextNode(Node node, String data) {
         return createTextNode(node.getOwnerDocument(), data);
     }
 
-    public void removeContents(Node node) {
+    public static void removeContents(Node node) {
         NodeList list = node.getChildNodes();
         for (int i = 0; i < list.getLength(); i++) {
             Node entry = list.item(i);
@@ -232,7 +236,7 @@
         }
     }
     
-    public String writeQName(Definition def, QName qname) {
+    public static String writeQName(Definition def, QName qname) {
         return def.getPrefix(qname.getNamespaceURI()) + ":" + qname.getLocalPart();
     }
 

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressParser.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressParser.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressParser.java
Thu Aug 31 01:57:39 2006
@@ -26,46 +26,46 @@
 
 public class JMSAddressParser {
 
-    private XMLUtils xmlUtils = new XMLUtils();
+    
 
     public void parseElement(JMSAddress jmsAddress, Element element) {
         try {
-            Attr jndiURL = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_URL);
+            Attr jndiURL = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_URL);
             if (jndiURL != null) {
                 jmsAddress.setJndiProviderURL(jndiURL.getValue());
             }
 
-            Attr destStyle = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_DEST_STYLE);
+            Attr destStyle = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_DEST_STYLE);
             if (destStyle != null) {
                 jmsAddress.setDestinationStyle(destStyle.getValue());
             }
 
-            Attr initCtx = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_INIT_CTX);
+            Attr initCtx = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_INIT_CTX);
             if (initCtx != null) {
                 jmsAddress.setInitialContextFactory(initCtx.getValue());
             }
 
-            Attr jndiDest = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_DEST);
+            Attr jndiDest = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_DEST);
             if (jndiDest != null) {
                 jmsAddress.setJndiDestinationName(jndiDest.getValue());
             }
 
-            Attr jndiFac = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_FAC);
+            Attr jndiFac = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_JNDI_FAC);
             if (jndiFac != null) {
                 jmsAddress.setJndiConnectionFactoryName(jndiFac.getValue());
             }
 
-            Attr msgType = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_MSG_TYPE);
+            Attr msgType = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_MSG_TYPE);
             if (msgType != null) {
                 jmsAddress.setMessageType(msgType.getValue());
             }
 
-            Attr msgID = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_MSGID_TO_CORRID);
+            Attr msgID = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_MSGID_TO_CORRID);
             if (msgID != null) {
                 jmsAddress.setUseMessageIDAsCorrelationID(Boolean.parseBoolean(msgID.getValue()));
             }
 
-            Attr subsName = xmlUtils.getAttribute(element, ToolConstants.JMS_ADDR_SUBSCRIBER_NAME);
+            Attr subsName = XMLUtils.getAttribute(element, ToolConstants.JMS_ADDR_SUBSCRIBER_NAME);
             if (subsName != null) {
                 jmsAddress.setDurableSubscriberName(subsName.getValue());
             }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
Thu Aug 31 01:57:39 2006
@@ -38,7 +38,7 @@
                                              ExtensionDeserializer,
                                              Serializable {
     public static final long serialVersionUID = 1;
-    XMLUtils xmlUtils = new XMLUtils();
+    
     
     public void marshall(Class parentType,
                          QName elementType,
@@ -49,7 +49,7 @@
 
         JMSAddress jmsAddress = (JMSAddress)extension;
         StringBuffer sb = new StringBuffer(300);        
-        sb.append(" <" + xmlUtils.writeQName(def, elementType) + " ");
+        sb.append(" <" + XMLUtils.writeQName(def, elementType) + " ");
         sb.append(jmsAddress.getAttrXMLString());
         sb.append("/>");
         pw.print(sb.toString());

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatBindingSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatBindingSerializer.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatBindingSerializer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatBindingSerializer.java
Thu Aug 31 01:57:39 2006
@@ -35,12 +35,11 @@
 
 public class XMLFormatBindingSerializer implements ExtensionDeserializer, ExtensionSerializer
{
 
-    XMLUtils xmlUtils = new XMLUtils();
-    
+        
     public void marshall(Class parentType, QName elementType, ExtensibilityElement extension,
PrintWriter pw,
                          Definition def, ExtensionRegistry extReg) throws WSDLException {
 
-        pw.print("<" + xmlUtils.writeQName(def, elementType) + "/>");
+        pw.print("<" + XMLUtils.writeQName(def, elementType) + "/>");
         pw.println();
     }
 

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatParser.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatParser.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatParser.java
Thu Aug 31 01:57:39 2006
@@ -32,15 +32,14 @@
 
 public class XMLFormatParser {
 
-    private XMLUtils xmlUtils = new XMLUtils();
-    
+        
     public void parseElement(Definition def, XMLFormat xmlFormat, Element element) {
-        Attr rootNodeAttribute = xmlUtils.getAttribute(element, ToolConstants.XMLBINDING_ROOTNODE);
+        Attr rootNodeAttribute = XMLUtils.getAttribute(element, ToolConstants.XMLBINDING_ROOTNODE);
         String rootNodeValue = rootNodeAttribute.getValue();
         
         if (rootNodeValue != null) {
             Map<String, String> mp = CastUtils.cast(def.getNamespaces());
-            xmlFormat.setRootNode(xmlUtils.getNamespace(
+            xmlFormat.setRootNode(XMLUtils.getNamespace(
                 mp,
                 rootNodeValue,
                 def.getTargetNamespace()));

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatSerializer.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatSerializer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLFormatSerializer.java
Thu Aug 31 01:57:39 2006
@@ -37,17 +37,17 @@
 
 public class XMLFormatSerializer implements ExtensionSerializer, ExtensionDeserializer, Serializable
{
 
-    XMLUtils xmlUtils = new XMLUtils();
+    
     
     public void marshall(Class parentType, QName elementType, ExtensibilityElement extension,
PrintWriter pw,
                          Definition def, ExtensionRegistry extReg) throws WSDLException {
 
         XMLFormat xmlFormat = (XMLFormat)extension;
         StringBuffer sb = new StringBuffer(300);
-        sb.append("<" + xmlUtils.writeQName(def, elementType) + " ");
+        sb.append("<" + XMLUtils.writeQName(def, elementType) + " ");
         if (xmlFormat.getRootNode() != null) {
             sb.append(ToolConstants.XMLBINDING_ROOTNODE + "=\""
-                      + xmlUtils.writeQName(def, xmlFormat.getRootNode()) + "\"");
+                      + XMLUtils.writeQName(def, xmlFormat.getRootNode()) + "\"");
         }
         sb.append(" />");
         pw.print(sb.toString());

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLHttpSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLHttpSerializer.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLHttpSerializer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/XMLHttpSerializer.java
Thu Aug 31 01:57:39 2006
@@ -36,13 +36,12 @@
 
 public class XMLHttpSerializer implements ExtensionSerializer, ExtensionDeserializer {
 
-    XMLUtils xmlUtils = new XMLUtils();
     public void marshall(Class parentType, QName elementType, ExtensibilityElement extension,
PrintWriter pw,
                          Definition def, ExtensionRegistry extReg) throws WSDLException {
 
         XMLHttpAddress xmlHttpAddress = (XMLHttpAddress)extension;
         StringBuffer sb = new StringBuffer(300);
-        sb.append("<" + xmlUtils.writeQName(def, elementType) + " ");
+        sb.append("<" + XMLUtils.writeQName(def, elementType) + " ");
         if (xmlHttpAddress.getLocation() != null) {
             sb.append(ToolConstants.XMLBINDING_HTTP_LOCATION + "=\"" + xmlHttpAddress.getLocation()
+ "\"");
         }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
Thu Aug 31 01:57:39 2006
@@ -41,8 +41,8 @@
 
     public static Node innerJaxbPackageBinding(Element schema, String packagevalue) {
         Document doc = schema.getOwnerDocument();
-        XMLUtils xmlUtils = new XMLUtils();
-        if (!xmlUtils.hasAttribute(schema, ToolConstants.NS_JAXB_BINDINGS)) {
+        
+        if (!XMLUtils.hasAttribute(schema, ToolConstants.NS_JAXB_BINDINGS)) {
             schema.setAttributeNS(ToolConstants.NS_JAXB_BINDINGS, "version", "2.0");
         }
 

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/generator/HandlerConfigGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/generator/HandlerConfigGenerator.java?rev=438845&r1=438844&r2=438845&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/generator/HandlerConfigGenerator.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/generator/HandlerConfigGenerator.java
Thu Aug 31 01:57:39 2006
@@ -76,7 +76,7 @@
     }
 
     private void generateHandlerChainFile(Element hChains, Writer writer) throws ToolException
{
-        XMLUtils xmlUtils = new XMLUtils();
-        xmlUtils.generateXMLFile(hChains, writer);
+        
+        XMLUtils.generateXMLFile(hChains, writer);
     }
 }



Mime
View raw message