Source Code Cross Referenced for JDOMStreamWriter.java in  » Web-Services-apache-cxf-2.0.1 » databinding » org » apache » cxf » aegis » util » stax » 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 » Web Services apache cxf 2.0.1 » databinding » org.apache.cxf.aegis.util.stax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.aegis.util.stax;
019:
020:        import java.util.HashMap;
021:        import java.util.Map;
022:        import java.util.Stack;
023:
024:        import javax.xml.namespace.NamespaceContext;
025:        import javax.xml.stream.XMLStreamException;
026:        import javax.xml.stream.XMLStreamWriter;
027:
028:        import org.apache.cxf.aegis.util.NamespaceHelper;
029:        import org.jdom.Attribute;
030:        import org.jdom.CDATA;
031:        import org.jdom.Comment;
032:        import org.jdom.Document;
033:        import org.jdom.Element;
034:        import org.jdom.EntityRef;
035:        import org.jdom.Namespace;
036:
037:        public class JDOMStreamWriter implements  XMLStreamWriter {
038:            private Stack<Element> stack = new Stack<Element>();
039:
040:            private Document document;
041:
042:            private Element currentNode;
043:
044:            private NamespaceContext context;
045:
046:            private Map properties = new HashMap();
047:
048:            public JDOMStreamWriter() {
049:            }
050:
051:            public JDOMStreamWriter(Element e) {
052:                newChild(e);
053:            }
054:
055:            public void close() throws XMLStreamException {
056:            }
057:
058:            public void flush() throws XMLStreamException {
059:            }
060:
061:            public void writeStartElement(String local)
062:                    throws XMLStreamException {
063:                newChild(new Element(local));
064:            }
065:
066:            private void newChild(Element element) {
067:                if (currentNode != null) {
068:                    stack.push(currentNode);
069:                    currentNode.addContent(element);
070:                } else {
071:                    if (document != null) {
072:                        document.setRootElement(element);
073:                    }
074:                }
075:
076:                JDOMNamespaceContext ctx = new JDOMNamespaceContext();
077:                ctx.setElement(element);
078:                this .context = ctx;
079:
080:                currentNode = element;
081:            }
082:
083:            public void writeStartElement(String namespace, String local)
084:                    throws XMLStreamException {
085:                newChild(new Element(local, namespace));
086:            }
087:
088:            public void writeStartElement(String prefix, String local,
089:                    String namespace) throws XMLStreamException {
090:                if (prefix == null || prefix.equals("")) {
091:                    writeStartElement(namespace, local);
092:                } else {
093:                    newChild(new Element(local, prefix, namespace));
094:                }
095:            }
096:
097:            public void writeEmptyElement(String namespace, String local)
098:                    throws XMLStreamException {
099:                writeStartElement(namespace, local);
100:            }
101:
102:            public void writeEmptyElement(String prefix, String namespace,
103:                    String local) throws XMLStreamException {
104:                writeStartElement(prefix, namespace, local);
105:            }
106:
107:            public void writeEmptyElement(String local)
108:                    throws XMLStreamException {
109:                writeStartElement(local);
110:            }
111:
112:            public void writeEndElement() throws XMLStreamException {
113:                currentNode = stack.pop();
114:            }
115:
116:            public void writeEndDocument() throws XMLStreamException {
117:            }
118:
119:            public void writeAttribute(String local, String value)
120:                    throws XMLStreamException {
121:                currentNode.setAttribute(new Attribute(local, value));
122:            }
123:
124:            public void writeAttribute(String prefix, String namespace,
125:                    String local, String value) throws XMLStreamException {
126:                currentNode.setAttribute(new Attribute(local, value, Namespace
127:                        .getNamespace(prefix, namespace)));
128:            }
129:
130:            public void writeAttribute(String namespace, String local,
131:                    String value) throws XMLStreamException {
132:                currentNode.setAttribute(new Attribute(local, value, Namespace
133:                        .getNamespace(namespace)));
134:            }
135:
136:            public void writeNamespace(String prefix, String namespace)
137:                    throws XMLStreamException {
138:                Namespace decNS = currentNode.getNamespace(prefix);
139:
140:                if (decNS == null || !decNS.getURI().equals(namespace)) {
141:                    currentNode.addNamespaceDeclaration(Namespace.getNamespace(
142:                            prefix, namespace));
143:                }
144:            }
145:
146:            public void writeDefaultNamespace(String namespace)
147:                    throws XMLStreamException {
148:                currentNode.addNamespaceDeclaration(Namespace.getNamespace("",
149:                        namespace));
150:            }
151:
152:            public void writeComment(String value) throws XMLStreamException {
153:                currentNode.addContent(new Comment(value));
154:            }
155:
156:            public void writeProcessingInstruction(String arg0)
157:                    throws XMLStreamException {
158:            }
159:
160:            public void writeProcessingInstruction(String arg0, String arg1)
161:                    throws XMLStreamException {
162:            }
163:
164:            public void writeCData(String data) throws XMLStreamException {
165:                currentNode.addContent(new CDATA(data));
166:            }
167:
168:            public void writeDTD(String arg0) throws XMLStreamException {
169:
170:            }
171:
172:            public void writeEntityRef(String ref) throws XMLStreamException {
173:                currentNode.addContent(new EntityRef(ref));
174:            }
175:
176:            public void writeStartDocument() throws XMLStreamException {
177:                document = new Document(new Element("root"));
178:            }
179:
180:            public void writeStartDocument(String version)
181:                    throws XMLStreamException {
182:                writeStartDocument();
183:
184:                // TODO: set encoding/version
185:            }
186:
187:            public void writeStartDocument(String encoding, String version)
188:                    throws XMLStreamException {
189:                writeStartDocument();
190:
191:                // TODO: set encoding/version
192:            }
193:
194:            public void writeCharacters(String text) throws XMLStreamException {
195:                currentNode.addContent(text);
196:            }
197:
198:            public void writeCharacters(char[] text, int start, int len)
199:                    throws XMLStreamException {
200:                // TODO Auto-generated method stub
201:                currentNode.addContent(new String(text, start, len));
202:            }
203:
204:            public String getPrefix(String uri) throws XMLStreamException {
205:                return NamespaceHelper.getPrefix(currentNode, uri);
206:            }
207:
208:            public void setPrefix(String arg0, String arg1)
209:                    throws XMLStreamException {
210:            }
211:
212:            public void setDefaultNamespace(String arg0)
213:                    throws XMLStreamException {
214:            }
215:
216:            public void setNamespaceContext(NamespaceContext ctx)
217:                    throws XMLStreamException {
218:                this .context = ctx;
219:            }
220:
221:            public NamespaceContext getNamespaceContext() {
222:                return context;
223:            }
224:
225:            public Object getProperty(String prop)
226:                    throws IllegalArgumentException {
227:                return properties.get(prop);
228:            }
229:
230:            public Document getDocument() {
231:                return document;
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.