Source Code Cross Referenced for WriterUtils.java in  » GIS » GeoTools-2.4.1 » org » geotools » validation » 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 » GIS » GeoTools 2.4.1 » org.geotools.validation.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2004, TOPP - www.openplans.org
006:         *    
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation; either
010:         *    version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.validation.xml;
018:
019:        import java.io.IOException;
020:        import java.io.Writer;
021:        import java.util.Iterator;
022:        import java.util.Map;
023:        import java.util.logging.Logger;
024:
025:        /**
026:         * WriterUtils purpose.
027:         * 
028:         * <p>
029:         * Used to provide assitance writing xml to a Writer.
030:         * </p>
031:         * 
032:         * <p></p>
033:         *
034:         * @author dzwiers, Refractions Research, Inc.
035:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/xml/WriterUtils.java $
036:         * @version $Id: WriterUtils.java 27862 2007-11-12 19:51:19Z desruisseaux $
037:         */
038:        class WriterUtils {
039:            /** Used internally to create log information to detect errors. */
040:            private static final Logger LOGGER = org.geotools.util.logging.Logging
041:                    .getLogger("org.vfny.geoserver.global");
042:
043:            /** The output writer. */
044:            protected Writer writer;
045:
046:            /**
047:             * WriterUtils constructor.
048:             * 
049:             * <p>
050:             * Should never be called.
051:             * </p>
052:             */
053:            protected WriterUtils() {
054:            }
055:
056:            /**
057:             * WriterUtils constructor.
058:             * 
059:             * <p>
060:             * Stores the specified writer to use for output.
061:             * </p>
062:             *
063:             * @param writer the writer which will be used for outputing the xml.
064:             */
065:            public WriterUtils(Writer writer) {
066:                //LOGGER.finest("In constructor WriterHelper");
067:                this .writer = writer;
068:            }
069:
070:            /**
071:             * write purpose.
072:             * 
073:             * <p>
074:             * Writes the String specified to the stored output writer.
075:             * </p>
076:             *
077:             * @param s The String to write.
078:             *
079:             * @throws IOException When an IO exception occurs.
080:             */
081:            public void write(String s) throws IOException {
082:                writer.write(s);
083:                writer.flush();
084:            }
085:
086:            /**
087:             * writeln purpose.
088:             * 
089:             * <p>
090:             * Writes the String specified to the stored output writer.
091:             * </p>
092:             *
093:             * @param s The String to write.
094:             *
095:             * @throws IOException When an IO exception occurs.
096:             */
097:            public void writeln(String s) throws IOException {
098:                writer.write(s + "\n");
099:                writer.flush();
100:            }
101:
102:            /**
103:             * openTag purpose.
104:             * 
105:             * <p>
106:             * Writes an open xml tag with the name specified to the stored output
107:             * writer.
108:             * </p>
109:             *
110:             * @param tagName The tag name to write.
111:             *
112:             * @throws IOException When an IO exception occurs.
113:             */
114:            public void openTag(String tagName) throws IOException {
115:                writeln("<" + tagName + ">");
116:            }
117:
118:            /**
119:             * openTag purpose.
120:             * 
121:             * <p>
122:             * Writes an open xml tag with the name and attributes specified to the
123:             * stored output writer.
124:             * </p>
125:             *
126:             * @param tagName The tag name to write.
127:             * @param attributes The tag attributes to write.
128:             *
129:             * @throws IOException When an IO exception occurs.
130:             */
131:            public void openTag(String tagName, Map attributes)
132:                    throws IOException {
133:                write("<" + tagName + " ");
134:
135:                Iterator i = attributes.keySet().iterator();
136:
137:                while (i.hasNext()) {
138:                    String s = (String) i.next();
139:                    write(s + " = " + "\"" + (attributes.get(s)).toString()
140:                            + "\" ");
141:                }
142:
143:                writeln(">");
144:            }
145:
146:            /**
147:             * closeTag purpose.
148:             * 
149:             * <p>
150:             * Writes an close xml tag with the name specified to the stored output
151:             * writer.
152:             * </p>
153:             *
154:             * @param tagName The tag name to write.
155:             *
156:             * @throws IOException When an IO exception occurs.
157:             */
158:            public void closeTag(String tagName) throws IOException {
159:                writeln("</" + tagName + ">");
160:            }
161:
162:            /**
163:             * textTag purpose.
164:             * 
165:             * <p>
166:             * Writes a text xml tag with the name and text specified to the stored
167:             * output writer.
168:             * </p>
169:             *
170:             * @param tagName The tag name to write.
171:             * @param data The text data to write.
172:             *
173:             * @throws IOException When an IO exception occurs.
174:             */
175:            public void textTag(String tagName, String data) throws IOException {
176:                writeln("<" + tagName + ">" + data + "</" + tagName + ">");
177:            }
178:
179:            /**
180:             * valueTag purpose.
181:             * 
182:             * <p>
183:             * Writes an xml tag with the name and value specified to the stored output
184:             * writer.
185:             * </p>
186:             *
187:             * @param tagName The tag name to write.
188:             * @param value The text data to write.
189:             *
190:             * @throws IOException When an IO exception occurs.
191:             */
192:            public void valueTag(String tagName, String value)
193:                    throws IOException {
194:                writeln("<" + tagName + " value = \"" + value + "\" />");
195:            }
196:
197:            /**
198:             * attrTag purpose.
199:             * 
200:             * <p>
201:             * Writes an xml tag with the name and attributes specified to the stored
202:             * output writer.
203:             * </p>
204:             *
205:             * @param tagName The tag name to write.
206:             * @param attributes The tag attributes to write.
207:             *
208:             * @throws IOException When an IO exception occurs.
209:             */
210:            public void attrTag(String tagName, Map attributes)
211:                    throws IOException {
212:                write("<" + tagName + " ");
213:
214:                Iterator i = attributes.keySet().iterator();
215:
216:                while (i.hasNext()) {
217:                    String s = (String) i.next();
218:                    write(s + " = " + "\"" + (attributes.get(s)).toString()
219:                            + "\" ");
220:                }
221:
222:                write(" />");
223:            }
224:
225:            /**
226:             * textTag purpose.
227:             * 
228:             * <p>
229:             * Writes an xml tag with the name, text and attributes specified to the
230:             * stored output writer.
231:             * </p>
232:             *
233:             * @param tagName The tag name to write.
234:             * @param attributes The tag attributes to write.
235:             * @param data The tag text to write.
236:             *
237:             * @throws IOException When an IO exception occurs.
238:             */
239:            public void textTag(String tagName, Map attributes, String data)
240:                    throws IOException {
241:                write("<" + tagName + " ");
242:
243:                Iterator i = attributes.keySet().iterator();
244:
245:                while (i.hasNext()) {
246:                    String s = (String) i.next();
247:                    write(s + " = " + "\"" + (attributes.get(s)).toString()
248:                            + "\" ");
249:                }
250:
251:                write(">" + data + "</" + tagName + ">");
252:            }
253:
254:            /**
255:             * comment purpose.
256:             * 
257:             * <p>
258:             * Writes an xml comment with the text specified to the stored output
259:             * writer.
260:             * </p>
261:             *
262:             * @param comment The comment text to write.
263:             *
264:             * @throws IOException When an IO exception occurs.
265:             */
266:            public void comment(String comment) throws IOException {
267:                writeln("<!--");
268:                writeln(comment);
269:                writeln("-->");
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.