Source Code Cross Referenced for XmlHelper.java in  » J2EE » webwork-2.2.6 » com » opensymphony » xwork » config » providers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » webwork 2.2.6 » com.opensymphony.xwork.config.providers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         * Copyright (c) 2002-2006 by OpenSymphony
03:         * All rights reserved.
04:         */
05:        package com.opensymphony.xwork.config.providers;
06:
07:        import org.w3c.dom.Element;
08:        import org.w3c.dom.Node;
09:        import org.w3c.dom.NodeList;
10:
11:        import java.util.Iterator;
12:        import java.util.Map;
13:        import java.util.LinkedHashMap;
14:
15:        /**
16:         * XML utilities.
17:         *
18:         * @author Mike
19:         * @author tmjee
20:         */
21:        public class XmlHelper {
22:
23:            /**
24:             * This method will find all the parameters under this <code>paramsElement</code> and return them as
25:             * Map<String, String>. For example,
26:             * <pre>
27:             *   <result ... >
28:             *      <param name="param1">value1</param>
29:             *      <param name="param2">value2</param>
30:             *      <param name="param3">value3</param>
31:             *   </result>
32:             * </pre>
33:             * will returns a Map<String, String> with the following key, value pairs :-
34:             * <ul>
35:             *  <li>param1 - value1</li>
36:             *  <li>param2 - value2</li>
37:             *  <li>param3 - value3</li>
38:             * </ul>
39:             *
40:             * @param paramsElement
41:             * @return
42:             */
43:            public static Map getParams(Element paramsElement) {
44:                LinkedHashMap params = new LinkedHashMap();
45:
46:                if (paramsElement == null) {
47:                    return params;
48:                }
49:
50:                NodeList childNodes = paramsElement.getChildNodes();
51:                for (int i = 0; i < childNodes.getLength(); i++) {
52:                    Node childNode = childNodes.item(i);
53:
54:                    if ((childNode.getNodeType() == Node.ELEMENT_NODE)
55:                            && "param".equals(childNode.getNodeName())) {
56:                        Element paramElement = (Element) childNode;
57:                        String paramName = paramElement.getAttribute("name");
58:
59:                        String val = getContent(paramElement);
60:                        if (val.length() > 0) {
61:                            params.put(paramName, val);
62:                        }
63:                    }
64:                }
65:                return params;
66:            }
67:
68:            /**
69:             * This method will return the content of this particular <code>element</code>.
70:             * For example,
71:             *
72:             * <pre>
73:             *    <result>something_1</result>
74:             * </pre>
75:             * When the {@link org.w3c.dom.Element} <code>&lt;result&gt;</code> is passed in as
76:             * argument (<code>element</code> to this method, it returns the content of it,
77:             * namely, <code>something_1</code> in the example above.
78:             * 
79:             * @return
80:             */
81:            public static String getContent(Element element) {
82:                StringBuffer paramValue = new StringBuffer();
83:                NodeList childNodes = element.getChildNodes();
84:                for (int j = 0; j < childNodes.getLength(); j++) {
85:                    Node currentNode = childNodes.item(j);
86:                    if (currentNode != null
87:                            && currentNode.getNodeType() == Node.TEXT_NODE) {
88:                        String val = currentNode.getNodeValue();
89:                        if (val != null) {
90:                            paramValue.append(val.trim());
91:                        }
92:                    }
93:                }
94:                String val = paramValue.toString().trim();
95:                return val;
96:            }
97:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.