Source Code Cross Referenced for AbstractXMLEvent.java in  » XML » stax-utils » javanet » staxutils » events » 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 » XML » stax utils » javanet.staxutils.events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AbstractXMLEvent.java,v 1.3 2004/07/15 02:11:02 cniles Exp $
003:         * 
004:         * Copyright (c) 2004, Christian Niles, unit12.net
005:         * All rights reserved.
006:         *
007:         * Redistribution and use in source and binary forms, with or without
008:         * modification, are permitted provided that the following conditions are met:
009:         * 
010:         *		*   Redistributions of source code must retain the above copyright
011:         *          notice, this list of conditions and the following disclaimer.
012:         * 
013:         *	    *	Redistributions in binary form must reproduce the above copyright
014:         *          notice, this list of conditions and the following disclaimer in the
015:         *          documentation and/or other materials provided with the distribution.
016:         * 
017:         *      *   Neither the name of Christian Niles, Unit12, nor the names of its
018:         *          contributors may be used to endorse or promote products derived from
019:         *          this software without specific prior written permission.
020:         *
021:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
022:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
023:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
024:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
025:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
026:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
027:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
028:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
029:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
030:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
031:         * POSSIBILITY OF SUCH DAMAGE.
032:         * 
033:         */
034:        package javanet.staxutils.events;
035:
036:        import java.io.IOException;
037:        import java.io.Serializable;
038:        import java.io.StringWriter;
039:        import java.io.Writer;
040:
041:        import javax.xml.namespace.QName;
042:        import javax.xml.stream.Location;
043:        import javax.xml.stream.XMLStreamException;
044:        import javax.xml.stream.XMLStreamWriter;
045:        import javax.xml.stream.events.Characters;
046:        import javax.xml.stream.events.EndElement;
047:        import javax.xml.stream.events.StartElement;
048:        import javax.xml.stream.events.XMLEvent;
049:
050:        import javanet.staxutils.helpers.EventMatcher;
051:        import javanet.staxutils.helpers.UnknownLocation;
052:        import javanet.staxutils.io.XMLWriterUtils;
053:
054:        /**
055:         * Abstract base class for {@link XMLEvent} implementations.
056:         * 
057:         * @author Christian Niles
058:         * @version $Revision: 1.3 $
059:         */
060:        public abstract class AbstractXMLEvent implements  ExtendedXMLEvent,
061:                Serializable, Cloneable {
062:
063:            /** The event location. */
064:            protected Location location;
065:
066:            /** The schema type. */
067:            protected QName schemaType;
068:
069:            public AbstractXMLEvent() {
070:
071:            }
072:
073:            public AbstractXMLEvent(Location location) {
074:
075:                this .location = location;
076:
077:            }
078:
079:            public AbstractXMLEvent(Location location, QName schemaType) {
080:
081:                this .location = location;
082:                this .schemaType = schemaType;
083:
084:            }
085:
086:            public AbstractXMLEvent(XMLEvent that) {
087:
088:                this .location = that.getLocation();
089:                this .schemaType = that.getSchemaType();
090:
091:            }
092:
093:            public Location getLocation() {
094:
095:                return (location == null ? UnknownLocation.INSTANCE : location);
096:
097:            }
098:
099:            public QName getSchemaType() {
100:
101:                return schemaType;
102:
103:            }
104:
105:            public Characters asCharacters() {
106:
107:                return (Characters) this ;
108:
109:            }
110:
111:            public EndElement asEndElement() {
112:
113:                return (EndElement) this ;
114:
115:            }
116:
117:            public StartElement asStartElement() {
118:
119:                return (StartElement) this ;
120:
121:            }
122:
123:            public boolean isAttribute() {
124:
125:                return getEventType() == ATTRIBUTE;
126:
127:            }
128:
129:            public boolean isCharacters() {
130:
131:                switch (getEventType()) {
132:
133:                case CHARACTERS:
134:                case SPACE:
135:                case CDATA:
136:                    return true;
137:
138:                default:
139:                    return false;
140:
141:                }
142:
143:            }
144:
145:            public boolean isEndDocument() {
146:
147:                return getEventType() == END_DOCUMENT;
148:
149:            }
150:
151:            public boolean isEndElement() {
152:
153:                return getEventType() == END_ELEMENT;
154:
155:            }
156:
157:            public boolean isEntityReference() {
158:
159:                return getEventType() == ENTITY_REFERENCE;
160:
161:            }
162:
163:            public boolean isNamespace() {
164:
165:                return getEventType() == NAMESPACE;
166:
167:            }
168:
169:            public boolean isProcessingInstruction() {
170:
171:                return getEventType() == PROCESSING_INSTRUCTION;
172:
173:            }
174:
175:            public boolean isStartDocument() {
176:
177:                return getEventType() == START_DOCUMENT;
178:
179:            }
180:
181:            public boolean isStartElement() {
182:
183:                return getEventType() == START_ELEMENT;
184:
185:            }
186:
187:            public Object clone() {
188:
189:                try {
190:
191:                    return super .clone();
192:
193:                } catch (CloneNotSupportedException e) {
194:
195:                    // should never happen since we implement Cloneable
196:                    throw new RuntimeException(
197:                            "Unexpected exception cloning XMLEvent", e);
198:
199:                }
200:
201:            }
202:
203:            public boolean matches(XMLEvent event) {
204:
205:                return EventMatcher.eventsMatch(this , event);
206:
207:            }
208:
209:            public void writeEvent(XMLStreamWriter writer)
210:                    throws XMLStreamException {
211:
212:                XMLWriterUtils.writeEvent(this , writer);
213:
214:            }
215:
216:            public void writeAsEncodedUnicode(Writer writer)
217:                    throws XMLStreamException {
218:
219:                try {
220:
221:                    XMLWriterUtils.writeEvent(this , writer);
222:
223:                } catch (IOException e) {
224:
225:                    throw new XMLStreamException(e);
226:
227:                }
228:
229:            }
230:
231:            public String toString() {
232:
233:                StringWriter writer = new StringWriter();
234:                try {
235:
236:                    this .writeAsEncodedUnicode(writer);
237:
238:                } catch (XMLStreamException e) {
239:                    // shouldn't happen?
240:                }
241:
242:                return writer.toString();
243:
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.