Source Code Cross Referenced for ProjectXmlDom.java in  » J2EE » Pustefix » de » schlund » pfixcore » util » basicapp » projectdom » 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 » Pustefix » de.schlund.pfixcore.util.basicapp.projectdom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of PFIXCORE.
003:         *
004:         * PFIXCORE is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU Lesser General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * PFIXCORE 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
012:         * GNU Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public License
015:         * along with PFIXCORE; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         */
019:
020:        package de.schlund.pfixcore.util.basicapp.projectdom;
021:
022:        import org.w3c.dom.Document;
023:        import org.w3c.dom.Element;
024:        import org.w3c.dom.Node;
025:        import org.w3c.dom.Text;
026:
027:        import de.schlund.pfixcore.util.basicapp.helper.AppValues;
028:        import de.schlund.pfixcore.util.basicapp.helper.XmlUtils;
029:        import de.schlund.pfixcore.util.basicapp.objects.Project;
030:        import de.schlund.pfixcore.util.basicapp.objects.ServletObject;
031:
032:        /**
033:         * Represents the dom of project.xml.in
034:         * 
035:         * @author <a href="mailto:rapude@schlund.de">Ralf Rapude</a>
036:         * @version $Id: ProjectXmlDom.java 3302 2007-11-30 16:56:16Z jenstl $
037:         */
038:        public final class ProjectXmlDom {
039:            /** The current dom */
040:            private Document domDoc = null;
041:            /** A String Buffer to get e.g. correctPaths */
042:            private StringBuffer buffy = new StringBuffer();
043:            /** The current Project */
044:            Project project = null;
045:            private String projectName = null;
046:
047:            /**
048:             * Constructor initializes the Project Object
049:             * and the dom for the current document
050:             * @param project The current project
051:             * @param domDoc the current Dom given by HandleXmlFiles
052:             */
053:            public ProjectXmlDom(Project project, Document domDoc) {
054:                this .domDoc = domDoc;
055:                projectName = project.getProjectName();
056:                this .project = project;
057:                prepareProjectXml();
058:            }
059:
060:            /**
061:             * Preparing the project.xml whicht means, that the content of some 
062:             * of the doms attributes and tags will be changed
063:             * @param buffy A StringBuffer for the new values
064:             * @param domDoc The dom
065:             * @return The new dom
066:             */
067:            private void prepareProjectXml() {
068:                // change the tag depend
069:                buffy.append(projectName);
070:                buffy.append(AppValues.CONFFOLDER);
071:                buffy.append(AppValues.DEPENDXML);
072:                domDoc = XmlUtils.changeTextValues(domDoc,
073:                        AppValues.PROJECTTAG_DEPEND, buffy.toString(), /*true if firstChild ->*/
074:                        false);
075:                buffy.setLength(0);
076:
077:                // change attribute name for the project tag
078:                domDoc = XmlUtils.changeAttributes(domDoc,
079:                        AppValues.PROJECTTAG_PROJECT,
080:                        AppValues.PROJECTATT_NAME, projectName, false);
081:
082:                // change the tag comment
083:                buffy.append(project.getComment());
084:                domDoc = XmlUtils.changeTextValues(domDoc,
085:                        AppValues.PROJECTTAG_COMMENT, buffy.toString(), true);
086:                buffy.setLength(0);
087:
088:                // change the text content of servername and serveralias
089:                buffy.append(projectName);
090:                buffy.append(".");
091:                domDoc = XmlUtils.changeTextValues(domDoc,
092:                        AppValues.PROJECTTAG_SERVERNAME, buffy.toString(), /*true if firstChild ->*/
093:                        true);
094:                domDoc = XmlUtils.changeTextValues(domDoc,
095:                        AppValues.PROJECTTAG_SERVERALIAS, buffy.toString(), /*true if firstChild ->*/
096:                        true);
097:                buffy.setLength(0);
098:
099:                // change the content of the defpath tag
100:                String defServletHandler = ((ServletObject) (project
101:                        .getServletList().get(0))).getServletName();
102:                buffy.append(AppValues.XMLCONSTANT);
103:                buffy.append(defServletHandler);
104:                domDoc = XmlUtils.changeTextValues(domDoc,
105:                        AppValues.PROJECTTAG_DEFPATH, buffy.toString(), true);
106:                buffy.setLength(0);
107:
108:                // change the passthrough tag
109:                buffy.append(projectName);
110:                buffy.append(AppValues.IMGFOLDER);
111:                domDoc = XmlUtils.changeTextValues(domDoc,
112:                        AppValues.PROJECTTAG_PASSTHROUGH, buffy.toString(),
113:                        true);
114:                buffy.setLength(0);
115:
116:                // changing the text node for docroot
117:                buffy.append(projectName);
118:                buffy.append(AppValues.HTDOCSFOLDER);
119:                domDoc = XmlUtils.changeTextValues(domDoc,
120:                        AppValues.PROJECTTAG_DOCUMENTROOT, buffy.toString(),
121:                        false);
122:                buffy.setLength(0);
123:
124:                // creating the servlets
125:                for (int i = 0; i < project.getServletList().size(); i++) {
126:                    domDoc = insertServlets(domDoc, i);
127:                }
128:            }
129:
130:            /**
131:             * inserting the servlets created by the user
132:             * @return the dom with all servlets
133:             */
134:            private Document insertServlets(Document domDoc, int currentServlet) {
135:                // the current servlets name
136:                String curServletName = ((ServletObject) (project
137:                        .getServletList().get(currentServlet)))
138:                        .getServletName();
139:
140:                // my new servlet node
141:                Element myNewServlet = domDoc
142:                        .createElement(AppValues.PROJECTTAG_SERVLET);
143:                Element newServletActive = domDoc
144:                        .createElement(AppValues.PROJECTTAG_ACTIVE);
145:                Text servletActiveChild = domDoc
146:                        .createTextNode(AppValues.PROJECTVALUE_TRUE);
147:                Element servletClass = domDoc
148:                        .createElement(AppValues.PROJECTTAG_CLASS);
149:                Text classValue = domDoc
150:                        .createTextNode(AppValues.PROJECTVALUE_CLASS);
151:                Element newServletPropfile = domDoc
152:                        .createElement(AppValues.PROJECTTAG_PROPFILE);
153:                // Element newDocRootNode     = domDoc.createElement(AppValues.PROJECTTAG_DOCROOT);
154:                Element rootNode = domDoc.getDocumentElement();
155:                Text afterDocRootNode = domDoc.createTextNode(projectName
156:                        + AppValues.CONFFOLDER + curServletName
157:                        + AppValues.CFGFILESUFF);
158:
159:                // setting the attribute of the new servlet tag
160:                myNewServlet.setAttribute(AppValues.PROJECTATT_NAME,
161:                        curServletName);
162:                myNewServlet.setAttribute(AppValues.PROJECTATT_EDITOR,
163:                        AppValues.PROJECTVALUE_TRUE);
164:
165:                //setting the text value of active
166:                newServletActive.appendChild(servletActiveChild);
167:                myNewServlet.appendChild(newServletActive);
168:                Text myActiveReturn = domDoc.createTextNode("\n");
169:                Text myActiveIndent = domDoc.createTextNode("    ");
170:                myNewServlet.insertBefore(myActiveReturn, newServletActive);
171:                myNewServlet.insertBefore(myActiveIndent, newServletActive);
172:
173:                // setting the class tag
174:                servletClass.appendChild(classValue);
175:                myNewServlet.appendChild(servletClass);
176:                Text myClassReturn = domDoc.createTextNode("\n");
177:                Text myClassIndent = domDoc.createTextNode("    ");
178:                myNewServlet.insertBefore(myClassReturn, servletClass);
179:                myNewServlet.insertBefore(myClassIndent, servletClass);
180:
181:                // prepare the propfile tag
182:                newServletPropfile.appendChild(afterDocRootNode);
183:                // newServletPropfile.insertBefore(newDocRootNode,afterDocRootNode);
184:                Text myPropfileReturn = domDoc.createTextNode("\n");
185:                Text myPropfileIndent = domDoc.createTextNode("    ");
186:                myNewServlet.appendChild(newServletPropfile);
187:                myNewServlet.insertBefore(myPropfileReturn, newServletPropfile);
188:                myNewServlet.insertBefore(myPropfileIndent, newServletPropfile);
189:                Text lastReturn = domDoc.createTextNode("\n");
190:                Text lastIndent = domDoc.createTextNode("  ");
191:                myNewServlet.appendChild(lastReturn);
192:                myNewServlet.appendChild(lastIndent);
193:
194:                // go to the first servlet (it's the deref servlet
195:                Node servletNode = domDoc.getElementsByTagName(
196:                        AppValues.PROJECTTAG_SERVLET).item(0);
197:                Text mainServletReturn = domDoc.createTextNode("\n");
198:                Text mainServletIndent = domDoc.createTextNode("  ");
199:                rootNode.insertBefore(myNewServlet, servletNode);
200:                rootNode.insertBefore(mainServletReturn, servletNode);
201:                rootNode.insertBefore(mainServletIndent, servletNode);
202:
203:                return domDoc;
204:            }
205:
206:            /**
207:             * Gives the current dom back to 
208:             * HandleXmlFiles
209:             * @return Document The current dom
210:             */
211:            public Document getDom() {
212:                return domDoc;
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.