Source Code Cross Referenced for SAXBeanWriter.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » io » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.betwixt.io 
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:        package org.apache.commons.betwixt.io;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:        import org.xml.sax.Attributes;
022:        import org.xml.sax.ContentHandler;
023:        import org.xml.sax.SAXException;
024:
025:        // FIX ME
026:        // At the moment, namespaces are NOT supported!
027:
028:        /**
029:         * The SAXBeanwriter will send events to a ContentHandler
030:         * 
031:         * @author <a href="mailto:rdonkin@apache.org">Robert Burrell Donkin</a>
032:         * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
033:         */
034:        public class SAXBeanWriter extends AbstractBeanWriter {
035:
036:            /** Where the output goes */
037:            private ContentHandler contentHandler;
038:            /** Log used for logging (Doh!) */
039:            private Log log = LogFactory.getLog(SAXBeanWriter.class);
040:            /** Should document events (ie. start and end) be called? */
041:            private boolean callDocumentEvents = true;
042:
043:            /**
044:             * <p> Constructor sets writer used for output.</p>
045:             *
046:             * @param contentHandler feed events to this content handler
047:             */
048:            public SAXBeanWriter(ContentHandler contentHandler) {
049:                this .contentHandler = contentHandler;
050:            }
051:
052:            /** 
053:             * Should document events (ie start and end) be called?
054:             *
055:             * @return true if this SAXWriter should call start 
056:             * and end of the content handler
057:             * @since 0.5
058:             */
059:            public boolean getCallDocumentEvents() {
060:                return callDocumentEvents;
061:            }
062:
063:            /**
064:             * Sets whether the document events (ie start and end) should be called.
065:             *
066:             * @param callDocumentEvents should document events be called
067:             * @since 0.5
068:             */
069:            public void setCallDocumentEvents(boolean callDocumentEvents) {
070:                this .callDocumentEvents = callDocumentEvents;
071:            }
072:
073:            /**
074:             * <p> Set the log implementation used. </p>
075:             *
076:             * @return <code>Log</code> implementation that this class logs to
077:             */
078:            public Log getLog() {
079:                return log;
080:            }
081:
082:            /**
083:             * <p> Set the log implementation used. </p>
084:             *
085:             * @param log <code>Log</code> implementation to use
086:             */
087:            public void setLog(Log log) {
088:                this .log = log;
089:            }
090:
091:            // Expression methods
092:            //-------------------------------------------------------------------------     
093:
094:            // Replaced by new API
095:
096:            // New API
097:            // -------------------------------------------------------------------------
098:
099:            /**
100:             * Writes the start tag for an element.
101:             *
102:             * @param uri the element's namespace uri
103:             * @param localName the element's local name 
104:             * @param qName the element's qualified name
105:             * @param attributes the element's attributes
106:             * @throws SAXException if an SAX problem occurs during writing 
107:             * @since 0.5
108:             */
109:            protected void startElement(WriteContext context, String uri,
110:                    String localName, String qName, Attributes attributes)
111:                    throws SAXException {
112:                contentHandler.startElement(uri, localName, qName, attributes);
113:            }
114:
115:            /**
116:             * Writes the end tag for an element
117:             *
118:             * @param uri the element's namespace uri
119:             * @param localName the element's local name 
120:             * @param qName the element's qualified name
121:             * @throws SAXException if an SAX problem occurs during writing 
122:             * @since 0.5
123:             */
124:            protected void endElement(WriteContext context, String uri,
125:                    String localName, String qName) throws SAXException {
126:                contentHandler.endElement(uri, localName, qName);
127:            }
128:
129:            /** 
130:             * Express body text 
131:             * @param text the element body text 
132:             * @throws SAXException if the <code>ContentHandler</code> has a problem
133:             * @since 0.5
134:             */
135:            protected void bodyText(WriteContext context, String text)
136:                    throws SAXException {
137:                //TODO:
138:                // FIX ME
139:                // CHECK UNICODE->CHAR CONVERSION!
140:                // THIS WILL QUITE POSSIBLY BREAK FOR NON-ROMAN
141:                char[] body = text.toCharArray();
142:                contentHandler.characters(body, 0, body.length);
143:            }
144:
145:            /**
146:             * This will announce the start of the document
147:             * to the contenthandler.
148:             * 
149:             * @see org.apache.commons.betwixt.io.AbstractBeanWriter#end()
150:             */
151:            public void start() throws SAXException {
152:                if (callDocumentEvents) {
153:                    contentHandler.startDocument();
154:                }
155:            }
156:
157:            /**
158:             * This method will announce the end of the document to
159:             * the contenthandler.
160:             * 
161:             * @see org.apache.commons.betwixt.io.AbstractBeanWriter#start()
162:             */
163:            public void end() throws SAXException {
164:                if (callDocumentEvents) {
165:                    contentHandler.endDocument();
166:                }
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.