cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [01/55] [abbrv] Removing ^M's from code.
Date Mon, 08 Apr 2013 13:13:11 GMT
Updated Branches:
  refs/heads/cisco-vnmc-api-integration 3422ceefb -> f38be4810


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
index af62bed..3a44c51 100644
--- a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
@@ -14,110 +14,110 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package com.cloud.utils.xmlobject;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Stack;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class XmlObjectParser {
-    final private InputStream is;
-
-    private class XmlHandler extends DefaultHandler {
-        private Stack<XmlObject> stack;
-        private String currentValue;
-        private XmlObject root;
-
-        XmlHandler() {
-            stack = new Stack<XmlObject>();
-        }
-
-        @Override
-        public void startElement(String namespaceURI, String localName, String qName, Attributes
atts) throws SAXException {
-            //System.out.println(String.format("startElement: namespaceURI:%s, localName:%s,
qName:%s", namespaceURI, localName, qName));
-            currentValue = null;
-            XmlObject obj = new XmlObject();
-            for (int i=0; i<atts.getLength(); i++) {
-                obj.putElement(atts.getQName(i), atts.getValue(i));
-            }
-            obj.setTag(qName);
-            if (!stack.isEmpty()) {
-                XmlObject parent = stack.peek();
-                parent.putElement(qName, obj);
-            }
-            stack.push(obj);
-        }
-
-        @Override
-        public void endElement(String namespaceURI, String localName, String qName) throws
SAXException {
-            XmlObject currObj = stack.pop();
-            if (currentValue != null) {
-                currObj.setText(currentValue);
-            }
-            
-            if (stack.isEmpty()) {
-                root = currObj;
-            }
-            
-            //System.out.println(String.format("endElement: namespaceURI:%s, localName:%s,
qName:%s", namespaceURI, localName, qName));
-        }
-        
-        @Override
-        public void characters(char[] ch, int start, int length) throws SAXException {
-            StringBuilder str = new StringBuilder();
-            str.append(ch, start, length);
-            currentValue = str.toString();
-            //System.out.println(String.format("characters: %s", str.toString()));
-        }
-        
-        XmlObject getRoot() {
-            return root;
-        }
-    }
-
-    private XmlObjectParser(InputStream is) {
-        super();
-        this.is = is;
-    }
-
-    public static XmlObject parseFromFile(String filePath) {
-        FileInputStream fs;
-        try {
-            fs = new FileInputStream(new File(filePath));
-            XmlObjectParser p = new XmlObjectParser(fs);
-            return p.parse();
-        } catch (FileNotFoundException e) {
-            throw new CloudRuntimeException(e);
-        }
-    }
-    
-    public static XmlObject parseFromString(String xmlString) {
-        InputStream stream = new ByteArrayInputStream(xmlString.getBytes());
-        XmlObjectParser p = new XmlObjectParser(stream);
-        return p.parse();
-    }
-
-    private XmlObject parse() {
-        SAXParserFactory spfactory = SAXParserFactory.newInstance();
-        try {
-            SAXParser saxParser = spfactory.newSAXParser();
-            XmlHandler handler = new XmlHandler();
-            saxParser.parse(is, handler);
-            return handler.getRoot();
-        } catch (Exception e) {
-            throw new CloudRuntimeException(e);
-        }
-    }
-}
+package com.cloud.utils.xmlobject;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Stack;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class XmlObjectParser {
+    final private InputStream is;
+
+    private class XmlHandler extends DefaultHandler {
+        private Stack<XmlObject> stack;
+        private String currentValue;
+        private XmlObject root;
+
+        XmlHandler() {
+            stack = new Stack<XmlObject>();
+        }
+
+        @Override
+        public void startElement(String namespaceURI, String localName, String qName, Attributes
atts) throws SAXException {
+            //System.out.println(String.format("startElement: namespaceURI:%s, localName:%s,
qName:%s", namespaceURI, localName, qName));
+            currentValue = null;
+            XmlObject obj = new XmlObject();
+            for (int i=0; i<atts.getLength(); i++) {
+                obj.putElement(atts.getQName(i), atts.getValue(i));
+            }
+            obj.setTag(qName);
+            if (!stack.isEmpty()) {
+                XmlObject parent = stack.peek();
+                parent.putElement(qName, obj);
+            }
+            stack.push(obj);
+        }
+
+        @Override
+        public void endElement(String namespaceURI, String localName, String qName) throws
SAXException {
+            XmlObject currObj = stack.pop();
+            if (currentValue != null) {
+                currObj.setText(currentValue);
+            }
+
+            if (stack.isEmpty()) {
+                root = currObj;
+            }
+
+            //System.out.println(String.format("endElement: namespaceURI:%s, localName:%s,
qName:%s", namespaceURI, localName, qName));
+        }
+
+        @Override
+        public void characters(char[] ch, int start, int length) throws SAXException {
+            StringBuilder str = new StringBuilder();
+            str.append(ch, start, length);
+            currentValue = str.toString();
+            //System.out.println(String.format("characters: %s", str.toString()));
+        }
+
+        XmlObject getRoot() {
+            return root;
+        }
+    }
+
+    private XmlObjectParser(InputStream is) {
+        super();
+        this.is = is;
+    }
+
+    public static XmlObject parseFromFile(String filePath) {
+        FileInputStream fs;
+        try {
+            fs = new FileInputStream(new File(filePath));
+            XmlObjectParser p = new XmlObjectParser(fs);
+            return p.parse();
+        } catch (FileNotFoundException e) {
+            throw new CloudRuntimeException(e);
+        }
+    }
+
+    public static XmlObject parseFromString(String xmlString) {
+        InputStream stream = new ByteArrayInputStream(xmlString.getBytes());
+        XmlObjectParser p = new XmlObjectParser(stream);
+        return p.parse();
+    }
+
+    private XmlObject parse() {
+        SAXParserFactory spfactory = SAXParserFactory.newInstance();
+        try {
+            SAXParser saxParser = spfactory.newSAXParser();
+            XmlHandler handler = new XmlHandler();
+            saxParser.parse(is, handler);
+            return handler.getRoot();
+        } catch (Exception e) {
+            throw new CloudRuntimeException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
index c2bcd02..934a3ef 100644
--- a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
+++ b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
@@ -14,36 +14,36 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package com.cloud.utils.xmlobject;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class TestXmlObject {
-
-    void p(String str) {
-        System.out.println(str);
-    }
-    
-    @Test
-    public void test() {
-    	
-    	// deprecated, since we no longer use component.xml.in any more
-    	/*
-        XmlObject xo = XmlObjectParser.parseFromFile("z:/components.xml.in");
-        p(xo.getTag());
-        p((String) xo.get("system-integrity-checker.checker").toString());
-        List<XmlObject> lst = xo.get("management-server.adapters");
-        for (XmlObject x : lst) {
-            List<XmlObject> lst1 = x.getAsList("adapter");
-            for (XmlObject y : lst1) {
-                p(y.toString());
-            }
-        }
-        */
-    }
-
-}
+package com.cloud.utils.xmlobject;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class TestXmlObject {
+
+    void p(String str) {
+        System.out.println(str);
+    }
+
+    @Test
+    public void test() {
+
+	// deprecated, since we no longer use component.xml.in any more
+	/*
+        XmlObject xo = XmlObjectParser.parseFromFile("z:/components.xml.in");
+        p(xo.getTag());
+        p((String) xo.get("system-integrity-checker.checker").toString());
+        List<XmlObject> lst = xo.get("management-server.adapters");
+        for (XmlObject x : lst) {
+            List<XmlObject> lst1 = x.getAsList("adapter");
+            for (XmlObject y : lst1) {
+                p(y.toString());
+            }
+        }
+        */
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java b/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
index 9bde687..e7e0d10 100644
--- a/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
+++ b/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
@@ -14,40 +14,40 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package com.cloud.utils.xmlobject;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TestXmlObject2 {
-    void p(String str) {
-        System.out.println(str);
-    }
-    
-    XmlObject xo(String name) {
-        return new XmlObject(name);
-    }
-    
-    @Test
-    public void test() {
-        XmlObject root = new XmlObject("test");
-        root.putElement("key1", "value1").putElement("key2", "value2");
-        p(root.dump());
-        
-        XmlObject c1 = new XmlObject("child1");
-        XmlObject c2 = new XmlObject("child2");
-        c2.putElement("ckey1", "value1");
-        c1.putElement(c2.getTag(), c2);
-        root.putElement(c1.getTag(), c1);
-        p(root.dump());
-        
-        root = xo("test2").putElement("key1", "value1").putElement("child1", xo("child1").setText("yyy"))
-                .putElement("child1", xo("child1")
-                    .putElement("child2", xo("child2")
-                            .putElement("child3", xo("child3").putElement("key3", "value3").setText("xxxxx"))));
-        
-        p(root.dump());
-    }
-
-}
+package com.cloud.utils.xmlobject;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestXmlObject2 {
+    void p(String str) {
+        System.out.println(str);
+    }
+
+    XmlObject xo(String name) {
+        return new XmlObject(name);
+    }
+
+    @Test
+    public void test() {
+        XmlObject root = new XmlObject("test");
+        root.putElement("key1", "value1").putElement("key2", "value2");
+        p(root.dump());
+
+        XmlObject c1 = new XmlObject("child1");
+        XmlObject c2 = new XmlObject("child2");
+        c2.putElement("ckey1", "value1");
+        c1.putElement(c2.getTag(), c2);
+        root.putElement(c1.getTag(), c1);
+        p(root.dump());
+
+        root = xo("test2").putElement("key1", "value1").putElement("child1", xo("child1").setText("yyy"))
+                .putElement("child1", xo("child1")
+                    .putElement("child2", xo("child2")
+                            .putElement("child3", xo("child3").putElement("key3", "value3").setText("xxxxx"))));
+
+        p(root.dump());
+    }
+
+}


Mime
View raw message