Source Code Cross Referenced for DOMUtils.java in  » Build » ANT » org » apache » tools » ant » util » 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 » Build » ANT » org.apache.tools.ant.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.util;
020:
021:        import org.w3c.dom.CDATASection;
022:        import org.w3c.dom.Document;
023:        import org.w3c.dom.Element;
024:        import org.w3c.dom.Text;
025:
026:        // CheckStyle:HideUtilityClassConstructorCheck OFF - bc
027:
028:        /**
029:         * Some utility methods for common tasks when building DOM trees in memory.
030:         *
031:         * <p>In this documentation <code>&lt;a&gt;</code> means an {@link
032:         * org.w3c.dom.Element Element} instance with name <code>a</code>.</p>
033:         *
034:         * @since Ant 1.6.3
035:         */
036:        public class DOMUtils {
037:
038:            /**
039:             * Get a new Document instance,
040:             * @return the document.
041:             * @since Ant 1.6.3
042:             */
043:            public static Document newDocument() {
044:                return JAXPUtils.getDocumentBuilder().newDocument();
045:            }
046:
047:            /**
048:             * Creates a named Element and appends it to the given element,
049:             * returns it.
050:             *
051:             * <p>This means
052:             * <pre>createChildElement(&lt;a&gt;, "b")</pre>
053:             * creates
054:             * <pre>
055:             * &lt;a&gt;
056:             *   &lt;b/&gt;
057:             * &lt;/a&gt;
058:             * </pre>
059:             * and returns <code>&lt;b&gt;</code>.</p>
060:             *
061:             * @param parent element that will receive the new element as child.
062:             * @param name name of the new element.
063:             * @return the new element.
064:             *
065:             * @since Ant 1.6.3
066:             */
067:            public static Element createChildElement(Element parent, String name) {
068:                Document doc = parent.getOwnerDocument();
069:                Element e = doc.createElement(name);
070:                parent.appendChild(e);
071:                return e;
072:            }
073:
074:            /**
075:             * Adds nested text.
076:             *
077:             * <p>This means
078:             * <pre>appendText(&lt;a&gt;, "b")</pre>
079:             * creates
080:             * <pre>
081:             * &lt;a&gt;b&lt;/a&gt;
082:             * </pre>
083:             * </p>
084:             *
085:             * @param parent element that will receive the new element as child.
086:             * @param content text content.
087:             *
088:             * @since Ant 1.6.3
089:             */
090:            public static void appendText(Element parent, String content) {
091:                Document doc = parent.getOwnerDocument();
092:                Text t = doc.createTextNode(content);
093:                parent.appendChild(t);
094:            }
095:
096:            /**
097:             * Adds a nested CDATA section.
098:             *
099:             * <p>This means
100:             * <pre>appendCDATA(&lt;a&gt;, "b")</pre>
101:             * creates
102:             * <pre>
103:             * &lt;a&gt;&lt;[!CDATA[b]]&gt;&lt;/a&gt;
104:             * </pre>
105:             * </p>
106:             *
107:             * @param parent element that will receive the new element as child.
108:             * @param content text content.
109:             *
110:             * @since Ant 1.6.3
111:             */
112:            public static void appendCDATA(Element parent, String content) {
113:                Document doc = parent.getOwnerDocument();
114:                CDATASection c = doc.createCDATASection(content);
115:                parent.appendChild(c);
116:            }
117:
118:            /**
119:             * Adds nested text in a new child element.
120:             *
121:             * <p>This means
122:             * <pre>appendTextElement(&lt;a&gt;, "b", "c")</pre>
123:             * creates
124:             * <pre>
125:             * &lt;a&gt;
126:             *   &lt;b&gt;c&lt;/b&gt;
127:             * &lt;/a&gt;
128:             * </pre>
129:             * </p>
130:             *
131:             * @param parent element that will receive the new element as child.
132:             * @param name of the child element.
133:             * @param content text content.
134:             *
135:             * @since Ant 1.6.3
136:             */
137:            public static void appendTextElement(Element parent, String name,
138:                    String content) {
139:                Element e = createChildElement(parent, name);
140:                appendText(e, content);
141:            }
142:
143:            /**
144:             * Adds a nested CDATA section in a new child element.
145:             *
146:             * <p>This means
147:             * <pre>appendCDATAElement(&lt;a&gt;, "b", "c")</pre>
148:             * creates
149:             * <pre>
150:             * &lt;a&gt;
151:             *   &lt;b&gt;&lt;![CDATA[c]]>&lt;/b&gt;
152:             * &lt;/a&gt;
153:             * </pre>
154:             * </pre>
155:             * </p>
156:             *
157:             * @param parent element that will receive the new element as child.
158:             * @param name of the child element.
159:             * @param content text content.
160:             *
161:             * @since Ant 1.6.3
162:             */
163:            public static void appendCDATAElement(Element parent, String name,
164:                    String content) {
165:                Element e = createChildElement(parent, name);
166:                appendCDATA(e, content);
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.