Source Code Cross Referenced for XMLWriter.java in  » Graphic-Library » jcommon-components » org » jfree » xml » writer » 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 » Graphic Library » jcommon components » org.jfree.xml.writer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ========================================================================
002:         * JCommon : a free general purpose class library for the Java(tm) platform
003:         * ========================================================================
004:         *
005:         * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006:         * 
007:         * Project Info:  http://www.jfree.org/jcommon/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         * 
027:         * --------------
028:         * XMLWriter.java
029:         * --------------
030:         * (C) Copyright 2003-2005, by Thomas Morgner and Contributors.
031:         *
032:         * Original Author:  Thomas Morgner;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: XMLWriter.java,v 1.5 2005/11/08 14:42:42 mungady Exp $
036:         *
037:         * Changes (from 26-Nov-2003)
038:         * --------------------------
039:         * 26-Nov-2003 : Added standard header and Javadocs (DG);
040:         *
041:         */
042:
043:        package org.jfree.xml.writer;
044:
045:        import java.io.IOException;
046:        import java.io.Writer;
047:        import java.util.Properties;
048:
049:        /**
050:         * A class for writing XML to a character stream.
051:         */
052:        public class XMLWriter extends XMLWriterSupport {
053:
054:            /**
055:             * The character stream.
056:             */
057:            private Writer writer;
058:
059:            /**
060:             * Creates a new XML writer for the specified character stream.  By 
061:             * default, four spaces are used for indentation.
062:             *
063:             * @param writer the character stream.
064:             */
065:            public XMLWriter(final Writer writer) {
066:                this (writer, "    ");
067:            }
068:
069:            /**
070:             * Creates a new XML writer for the specified character stream.
071:             *
072:             * @param writer       the character stream.
073:             * @param indentString the string used for indentation (should contain 
074:             *                     white space, for example four spaces).
075:             */
076:            public XMLWriter(final Writer writer, final String indentString) {
077:                super (new SafeTagList(), 0, indentString);
078:                if (writer == null) {
079:                    throw new NullPointerException("Writer must not be null.");
080:                }
081:
082:                this .writer = writer;
083:            }
084:
085:            /**
086:             * Writes the XML declaration that usually appears at the top of every XML 
087:             * file.
088:             * 
089:             * @throws IOException if there is a problem writing to the character 
090:             *                     stream.               
091:             */
092:            public void writeXmlDeclaration() throws IOException {
093:                this .writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
094:                this .writer.write(getLineSeparator());
095:            }
096:
097:            /**
098:             * Writes an opening XML tag that has no attributes.
099:             *
100:             * @param name  the tag name.
101:             * @param close a flag that controls whether or not the tag is closed 
102:             *              immediately.
103:             * @throws java.io.IOException if there is an I/O problem.
104:             */
105:            public void writeTag(final String name, final boolean close)
106:                    throws IOException {
107:                if (close) {
108:                    writeTag(this .writer, name, new AttributeList(), close);
109:                } else {
110:                    writeTag(this .writer, name);
111:                }
112:            }
113:
114:            /**
115:             * Writes a closing XML tag.
116:             *
117:             * @param tag the tag name.
118:             * @throws java.io.IOException if there is an I/O problem.
119:             */
120:            public void writeCloseTag(final String tag) throws IOException {
121:                writeCloseTag(this .writer, tag);
122:            }
123:
124:            /**
125:             * Writes an opening XML tag with an attribute/value pair.
126:             *
127:             * @param name           the tag name.
128:             * @param attributeName  the attribute name.
129:             * @param attributeValue the attribute value.
130:             * @param close          controls whether the tag is closed.
131:             * @throws java.io.IOException if there is an I/O problem.
132:             */
133:            public void writeTag(final String name, final String attributeName,
134:                    final String attributeValue, final boolean close)
135:                    throws IOException {
136:                writeTag(this .writer, name, attributeName, attributeValue,
137:                        close);
138:            }
139:
140:            /**
141:             * Writes an opening XML tag along with a list of attribute/value pairs.
142:             *
143:             * @param name       the tag name.
144:             * @param attributes the attributes.
145:             * @param close      controls whether the tag is closed.
146:             * @throws java.io.IOException if there is an I/O problem.
147:             */
148:            public void writeTag(final String name,
149:                    final AttributeList attributes, final boolean close)
150:                    throws IOException {
151:                writeTag(this .writer, name, attributes, close);
152:            }
153:
154:            /**
155:             * Writes an opening XML tag along with a list of attribute/value pairs.
156:             *
157:             * @param name       the tag name.
158:             * @param attributes the attributes.
159:             * @param close      controls whether the tag is closed.
160:             * @throws java.io.IOException if there is an I/O problem.
161:             * @deprecated use the attribute list instead ...
162:             */
163:            public void writeTag(final String name,
164:                    final Properties attributes, final boolean close)
165:                    throws IOException {
166:                writeTag(this .writer, name, attributes, close);
167:            }
168:
169:            /**
170:             * Writes some text to the character stream.
171:             *
172:             * @param text the text.
173:             * @throws IOException if there is a problem writing to the character 
174:             *                     stream.
175:             */
176:            public void writeText(final String text) throws IOException {
177:                this .writer.write(text);
178:            }
179:
180:            /**
181:             * Closes the underlying character stream.
182:             * 
183:             * @throws IOException if there is a problem closing the character stream.
184:             */
185:            public void close() throws IOException {
186:                this.writer.close();
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.