Source Code Cross Referenced for XMLConfig.java in  » Database-JDBC-Connection-Pool » octopus » 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 » Database JDBC Connection Pool » octopus » org.enhydra.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            Copyright (C) 2003  Together
003:
004:            This library is free software; you can redistribute it and/or
005:            modify it under the terms of the GNU Lesser General Public
006:            License as published by the Free Software Foundation; either
007:            version 2.1 of the License, or (at your option) any later version.
008:
009:            This library is distributed in the hope that it will be useful,
010:            but WITHOUT ANY WARRANTY; without even the implied warranty of
011:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:            Lesser General Public License for more details.
013:
014:            You should have received a copy of the GNU Lesser General Public
015:            License along with this library; if not, write to the Free Software
016:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package org.enhydra.xml;
020:
021:        import java.io.IOException;
022:        import java.util.ArrayList;
023:        import java.util.List;
024:        import java.util.Properties;
025:
026:        //import org.apache.xerces.parsers.DOMParser;
027:        import org.w3c.dom.DOMException;
028:        import org.w3c.dom.Document;
029:        import org.w3c.dom.Node;
030:        import org.w3c.dom.NodeList;
031:        import org.w3c.dom.Element;
032:        import org.xml.sax.SAXException;
033:
034:        /**
035:         * @author Tweety
036:         *
037:         * A class representing
038:         *
039:         * @version 1.0
040:         */
041:        public class XMLConfig extends SearchElement {
042:
043:            /**
044:             * Constructs an empty <code>SearchElement</code>.
045:             */
046:            public XMLConfig() {
047:            }
048:
049:            /**
050:             * Constructs an <code>XMLConfig</code> with the given
051:             * document owner and node name.
052:             *
053:             * @param ownerDoc the document owner of the node, as a <code>Document</code>.
054:             * @param name is the name of the node, as a <code>String</code>.
055:             */
056:            public XMLConfig(Document ownerDoc, String name) {
057:                super (ownerDoc, name);
058:            }
059:
060:            /**
061:             * Constructs an <code>XMLConfig</code> from a given node
062:             * (creates the children subtree too), as a <code>Node</code>
063:             *
064:             * @param node , as a <code>Node</code>.
065:             */
066:            public XMLConfig(Node node) {
067:                super (node);
068:            }
069:
070:            /**
071:             * Constructs a <code>XMLConfig</code> from the given node,
072:             * without creating entire children subtree.
073:             *
074:             * @param node , as a <code>XMLConfig</code>.
075:             */
076:            public XMLConfig(XMLConfig node) {
077:                super ((HashMapElement) node);
078:            }
079:
080:            /**
081:             * Creates new instance of the XMLConfig class from the given <code>Node</code>.
082:             *
083:             * @param node , as a <code>Node</code>.
084:             *
085:             * @return new instance of the XMLConfig class.
086:             */
087:            protected Node newElementInstance(Node node) {
088:                return new XMLConfig(node);
089:            }
090:
091:            /**
092:             * Creates new instance of <code>XMLConfig</code> from a given document
093:             * as a <code>Document</code>
094:             *
095:             * @param document document ant type of node.
096:             *
097:             * @return new instance of <code>XMLConfig</code> from a given document.
098:             */
099:            public static XMLConfig newXMLConfigInstance(Document document) {
100:                Node root = document.getDocumentElement();
101:                return new XMLConfig(root);
102:            }
103:
104:            /**
105:             * Returns <code>XMLConfig</code> as a subconfiguration with the given condition.
106:             *
107:             * @param name is type of node.
108:             * @return node
109:             */
110:            public XMLConfig getSection(String name) {
111:                return (XMLConfig) getFirstSubElementsByCondition(name);
112:            }
113:
114:            //	/**
115:            //	 * .
116:            //	 */
117:            //	public void setText(String namePath, String text, boolean create) {
118:            //
119:            //      if (!create) {
120:            //         setText(namePath,text);
121:            //         return;
122:            //      }
123:            //		NodeList nodes = this.getSubElementsByTagName(namePath);
124:            //		if (nodes != null && nodes.getLength() > 0)
125:            //			 ((SearchElement) nodes.item(0)).setText(text);
126:            //	}
127:            //
128:            //
129:            //	/**
130:            //	 * @return recursive funtion that fullfills the <code>list</code>
131:            //	 * parameter with all the nodes in the given path.
132:            //	 */
133:            //	private void createSubElementsByTag(String namePath) {
134:            //
135:            //		String[] keys = namePath.split(this.TAG_SEPARATOR, 2);
136:            //		if (keys.length == 1) {
137:            //			List fList = (List) this.children.get(tagName);
138:            //			if (fList != null) {
139:            //				for (int i = 0; i < fList.size(); i++) {
140:            //					HashMapElement elm = (HashMapElement) fList.get(i);
141:            //					String val = (String) elm.getText();
142:            //					if (val != null)
143:            //						if (val.equals(tagValue))
144:            //							list.add(elm);
145:            //				}
146:            //   		} else {
147:            //      		Element newElement = new XMLConfig(this.ownerDocument,keys[0]);
148:            //            this.appendChild(newElement);
149:            //   	   }
150:            //			return ;
151:            //		}
152:            //		NodeList tagChildren = this.getChildrenByTagName(keys[0]);
153:            //		if (tagChildren != null) {
154:            //			for (int i = 0; i < tagChildren.getLength(); i++)
155:            //				((SearchElement) tagChildren.item(i)).getSubElementsByTagText(keys[1], tagValue, list);
156:            //		} else {
157:            //   		Element newElement = new XMLConfig(this.ownerDocument,keys[0]);
158:            //         this.appendChild(newElement);
159:            //	   }
160:            //	}
161:
162:            public static void main(String[] args) {
163:                try {
164:                    System.out.println("Reading document ...");
165:                    Document doc = XMLDocumentFactory.parse("input.xml");
166:                    System.out.println("Creating node ...");
167:                    XMLConfig node = XMLConfig.newXMLConfigInstance(doc);
168:                    System.out.println("Serialize node ...");
169:
170:                    Properties prop = new Properties();
171:                    prop.put(javax.xml.transform.OutputKeys.DOCTYPE_PUBLIC,
172:                            "http:///enhydra.org");
173:                    prop.put(javax.xml.transform.OutputKeys.VERSION, "1.1");
174:                    XMLDocumentFactory.serialize(node, "output.xml ", prop);
175:                    System.out.println("Searching ...");
176:
177:                    for (int i = 0; i < 1000; i++) {
178:                        if (i % 10 == 0)
179:                            System.out.print("\rprogress " + i / 10 + " %");
180:                        XMLConfig section = node
181:                                .getSection("database/package/package/package/package/package/package/table/column@id=EMAILADRESSE");
182:                        //       			node.getSubElementsByAttrValue("database/package/package/package/package/package/table@dbTableName","OLSERVER");
183:                    }
184:                    System.out.println("\rprogress 100 %");
185:                    System.out.println();
186:
187:                    //			NodeList nodeList = node.getSubElementsByAttrValue("database/package/package/package/package/package/table@dbTableName","OLSERVER");
188:                    XMLConfig section = node
189:                            .getSection("database/package/package/package/package/package/package/table/column@id=EMAILADRESSE");
190:                    section.setAttr("type@javaType", "Zoka");
191:                    if (section == null)
192:                        System.out.println("section = null");
193:                    else {
194:                        System.out.println("section = " + section);
195:                    }
196:
197:                    //			NodeList nodeList = node.getSubElementsByTagText("databaseManager/database/type","Oracle");
198:                    //            NodeList nodeList = node.getSubElementsByCondition("database/package/package/package/package/package/table@dbTableName=OLSERVER");
199:                    //	        if (nodeList == null)
200:                    //	            System.out.println("nodeList = null");
201:                    //	        else {
202:                    //	            for (int i=0; i<nodeList.getLength(); i++)
203:                    //	                System.out.println("node["+i+"] = "+nodeList.item(i));
204:                    //	        }
205:
206:                } catch (Exception e) {
207:                    e.printStackTrace();
208:                    System.out.println("NOOOOOOOOOOOOO");
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.