Source Code Cross Referenced for XMLConfig.java in  » J2EE » Enhydra-Application-Framework » org » enhydra » xml » 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 » Enhydra Application Framework » org.enhydra.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.xml;
002:
003:        import java.util.Properties;
004:
005:        import org.w3c.dom.Document;
006:        import org.w3c.dom.Node;
007:
008:        /**
009:         * @author Tweety
010:         *
011:         * A class representing 
012:         *
013:         * @version 1.0
014:         */
015:        public class XMLConfig extends SearchElement {
016:
017:            /**
018:             * Constructs an empty <code>SearchElement</code>.
019:             */
020:            public XMLConfig() {
021:            }
022:
023:            /**
024:             * Constructs an <code>XMLConfig</code> with the given 
025:             * document owner and node name.
026:             *
027:             * @param ownerDoc the document owner of the node, as a <code>Document</code>.
028:             * @param nodeName the name of the node, as a <code>String</code>.
029:             */
030:            public XMLConfig(Document ownerDoc, String name) {
031:                super (ownerDoc, name);
032:            }
033:
034:            /**
035:             * Constructs an <code>XMLConfig</code> from a given node 
036:             * (creates the children subtree too), as a <code>Node</code>
037:             *
038:             * @param node, as a <code>Node</code>.
039:             */
040:            public XMLConfig(Node node) {
041:                super (node);
042:            }
043:
044:            /**
045:             * Constructs a <code>XMLConfig</code> from the given node,
046:             * without creating entire children subtree.
047:             * 
048:             * @param element, as a <code>XMLConfig</code>.
049:             */
050:            public XMLConfig(XMLConfig node) {
051:                super ((HashMapElement) node);
052:            }
053:
054:            /**
055:             * Creates new instance of the XMLConfig class from the given <code>Node</code>.
056:             * 
057:             * @param node, as a <code>Node</code>.
058:             * 
059:             * @return new instance of the XMLConfig class.
060:             */
061:            protected Node newElementInstance(Node node) {
062:                return new XMLConfig(node);
063:            }
064:
065:            /**
066:             * Creates new instance of <code>XMLConfig</code> from a given document
067:             * as a <code>Document</code>
068:             *
069:             * @param document document ant type of node.
070:             * 
071:             * @return new instance of <code>XMLConfig</code> from a given document.
072:             */
073:            public static XMLConfig newXMLConfigInstance(Document document) {
074:                Node root = document.getDocumentElement();
075:                return new XMLConfig(root);
076:            }
077:
078:            /**
079:             * Returns <code>XMLConfig</code> as a subconfiguration with the given condition.
080:             *
081:             * @param document document ant type of node.
082:             */
083:            public XMLConfig getSection(String name) {
084:                return (XMLConfig) getFirstSubElementsByCondition(name);
085:            }
086:
087:            //	/**
088:            //	 * .
089:            //	 */
090:            //	public void setText(String namePath, String text, boolean create) {
091:            //
092:            //      if (!create) {
093:            //         setText(namePath,text);
094:            //         return;
095:            //      }
096:            //		NodeList nodes = this.getSubElementsByTagName(namePath);
097:            //		if (nodes != null && nodes.getLength() > 0)
098:            //			 ((SearchElement) nodes.item(0)).setText(text);
099:            //	}
100:            //
101:            //
102:            //	/**
103:            //	 * @return recursive funtion that fullfills the <code>list</code>
104:            //	 * parameter with all the nodes in the given path.
105:            //	 */
106:            //	private void createSubElementsByTag(String namePath) {
107:            //
108:            //		String[] keys = namePath.split(this.TAG_SEPARATOR, 2);
109:            //		if (keys.length == 1) {
110:            //			List fList = (List) this.children.get(tagName);
111:            //			if (fList != null) {
112:            //				for (int i = 0; i < fList.size(); i++) {
113:            //					HashMapElement elm = (HashMapElement) fList.get(i);
114:            //					String val = (String) elm.getText();
115:            //					if (val != null)
116:            //						if (val.equals(tagValue))
117:            //							list.add(elm);
118:            //				}
119:            //   		} else {
120:            //      		Element newElement = new XMLConfig(this.ownerDocument,keys[0]);
121:            //            this.appendChild(newElement);
122:            //   	   }
123:            //			return ;
124:            //		}
125:            //		NodeList tagChildren = this.getChildrenByTagName(keys[0]);
126:            //		if (tagChildren != null) {
127:            //			for (int i = 0; i < tagChildren.getLength(); i++)
128:            //				((SearchElement) tagChildren.item(i)).getSubElementsByTagText(keys[1], tagValue, list);
129:            //		} else {
130:            //   		Element newElement = new XMLConfig(this.ownerDocument,keys[0]);
131:            //         this.appendChild(newElement);
132:            //	   }
133:            //	}
134:
135:            public static void main(String[] args) {
136:                try {
137:                    System.out.println("Reading document ...");
138:                    Document doc = XMLDocumentFactory.parse("input.xml");
139:                    System.out.println("Creating node ...");
140:                    XMLConfig node = XMLConfig.newXMLConfigInstance(doc);
141:                    System.out.println("Serialize node ...");
142:
143:                    Properties prop = new Properties();
144:                    prop.put(javax.xml.transform.OutputKeys.DOCTYPE_PUBLIC,
145:                            "http:///enhydra.org");
146:                    prop.put(javax.xml.transform.OutputKeys.VERSION, "1.1");
147:                    XMLDocumentFactory.serialize(node, "output.xml ", prop);
148:                    System.out.println("Searching ...");
149:
150:                    for (int i = 0; i < 1000; i++) {
151:                        if (i % 10 == 0)
152:                            System.out.print("\rprogress " + i / 10 + " %");
153:                        XMLConfig section = node
154:                                .getSection("database/package/package/package/package/package/package/table/column@id=EMAILADRESSE");
155:                        //       			node.getSubElementsByAttrValue("database/package/package/package/package/package/table@dbTableName","OLSERVER");
156:                    }
157:                    System.out.println("\rprogress 100 %");
158:                    System.out.println();
159:
160:                    //			NodeList nodeList = node.getSubElementsByAttrValue("database/package/package/package/package/package/table@dbTableName","OLSERVER");
161:                    XMLConfig section = node
162:                            .getSection("database/package/package/package/package/package/package/table/column@id=EMAILADRESSE");
163:                    section.setAttr("type@javaType", "Zoka");
164:                    /* Alex
165:                     * if (section == null)
166:                        System.out.println("section = null");
167:                    else {*/
168:                    System.out.println("section = " + section);
169:                    //	        }
170:
171:                    //			NodeList nodeList = node.getSubElementsByTagText("databaseManager/database/type","Oracle");
172:                    //            NodeList nodeList = node.getSubElementsByCondition("database/package/package/package/package/package/table@dbTableName=OLSERVER");
173:                    //	        if (nodeList == null)
174:                    //	            System.out.println("nodeList = null");
175:                    //	        else {
176:                    //	            for (int i=0; i<nodeList.getLength(); i++)
177:                    //	                System.out.println("node["+i+"] = "+nodeList.item(i));
178:                    //	        }
179:
180:                } catch (Exception e) {
181:                    e.printStackTrace();
182:                    System.out.println("NOOOOOOOOOOOOO");
183:                }
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.