Source Code Cross Referenced for CharacterEvent.java in  » 6.0-JDK-Modules » sjsxp » com » sun » xml » stream » 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 » 6.0 JDK Modules » sjsxp » com.sun.xml.stream.events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: CharacterEvent.java,v 1.2 2006/04/01 06:01:35 jeffsuttor Exp $
003:         */
004:
005:        /*
006:         * The contents of this file are subject to the terms
007:         * of the Common Development and Distribution License
008:         * (the License).  You may not use this file except in
009:         * compliance with the License.
010:         * 
011:         * You can obtain a copy of the license at
012:         * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013:         * See the License for the specific language governing
014:         * permissions and limitations under the License.
015:         * 
016:         * When distributing Covered Code, include this CDDL
017:         * Header Notice in each file and include the License file
018:         * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019:         * If applicable, add the following below the CDDL Header,
020:         * with the fields enclosed by brackets [] replaced by
021:         * you own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         * 
024:         * [Name of File] [ver.__] [Date]
025:         * 
026:         * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027:         */
028:
029:        package com.sun.xml.stream.events;
030:
031:        import javax.xml.stream.events.Characters;
032:        import java.io.Writer;
033:        import javax.xml.stream.events.XMLEvent;
034:        import com.sun.xml.stream.xerces.util.XMLChar;
035:
036:        /** Implementation of Character event.
037:         *
038:         *@author Neeraj Bajaj, Sun Microsystems
039:         *@author K.Venugopal, Sun Microsystems
040:         *
041:         */
042:
043:        public class CharacterEvent extends DummyEvent implements  Characters {
044:            /* data */
045:            private String fData;
046:            /*true if fData is CData */
047:            private boolean fIsCData;
048:            /* true if fData is ignorableWhitespace*/
049:            private boolean fIsIgnorableWhitespace;
050:            /* true if fData contet is whitespace*/
051:            private boolean fIsSpace = false;
052:            /*used to prevent scanning of  data multiple times */
053:            private boolean fCheckIfSpaceNeeded = true;
054:
055:            public CharacterEvent() {
056:                fIsCData = false;
057:                init();
058:            }
059:
060:            /**
061:             *
062:             * @param data Character Data.
063:             */
064:            public CharacterEvent(String data) {
065:                fIsCData = false;
066:                init();
067:                fData = data;
068:            }
069:
070:            /**
071:             *
072:             * @param data Character Data.
073:             * @param flag true if CData
074:             */
075:            public CharacterEvent(String data, boolean flag) {
076:                init();
077:                fData = data;
078:                fIsCData = flag;
079:            }
080:
081:            /**
082:             *
083:             * @param data Character Data.
084:             * @param flag true if CData
085:             * @param isIgnorableWhiteSpace true if data is ignorable whitespace.
086:             */
087:            public CharacterEvent(String data, boolean flag,
088:                    boolean isIgnorableWhiteSpace) {
089:                init();
090:                fData = data;
091:                fIsCData = flag;
092:                fIsIgnorableWhitespace = isIgnorableWhiteSpace;
093:            }
094:
095:            protected void init() {
096:                setEventType(XMLEvent.CHARACTERS);
097:            }
098:
099:            /**
100:             *
101:             * @return return data.
102:             */
103:            public String getData() {
104:                return fData;
105:            }
106:
107:            /**
108:             *
109:             * @param String data
110:             */
111:            public void setData(String data) {
112:                fData = data;
113:                fCheckIfSpaceNeeded = true;
114:            }
115:
116:            /**
117:             *
118:             * @return boolean returns true if the data is CData
119:             */
120:            public boolean isCData() {
121:                return fIsCData;
122:            }
123:
124:            /**
125:             *
126:             * @return String return the String representation of this event.
127:             */
128:            public String toString() {
129:                if (fIsCData)
130:                    return "<![CDATA[" + getData() + "]]>";
131:                else
132:                    return fData;
133:            }
134:
135:            /** This method will write the XMLEvent as per the XML 1.0 specification as Unicode characters.
136:             * No indentation or whitespace should be outputted.
137:             *
138:             * Any user defined event type SHALL have this method
139:             * called when being written to on an output stream.
140:             * Built in Event types MUST implement this method,
141:             * but implementations MAY choose not call these methods
142:             * for optimizations reasons when writing out built in
143:             * Events to an output stream.
144:             * The output generated MUST be equivalent in terms of the
145:             * infoset expressed.
146:             *
147:             * @param writer The writer that will output the data
148:             * @throws XMLStreamException if there is a fatal error writing the event
149:             */
150:            public void writeAsEncodedUnicode(Writer writer)
151:                    throws javax.xml.stream.XMLStreamException {
152:            }
153:
154:            /**
155:             * Return true if this is ignorableWhiteSpace.  If
156:             * this event is ignorableWhiteSpace its event type will
157:             * be SPACE.
158:             * @return
159:             */
160:            public boolean isIgnorableWhiteSpace() {
161:                return fIsIgnorableWhitespace;
162:            }
163:
164:            /**
165:             * Returns true if this set of Characters
166:             * is all whitespace.  Whitspace inside a document
167:             * is reported as CHARACTERS.  This method allows
168:             * checking of CHARACTERS events to see if they
169:             * are composed of only whitespace characters
170:             * @return
171:             */
172:            public boolean isWhiteSpace() {
173:                //no synchronization checks made.
174:                if (fCheckIfSpaceNeeded) {
175:                    checkWhiteSpace();
176:                    fCheckIfSpaceNeeded = false;
177:                }
178:                return fIsSpace;
179:            }
180:
181:            private void checkWhiteSpace() {
182:                //for now - remove dependancy of XMLChar
183:                if (fData != null && fData.length() > 0) {
184:                    fIsSpace = true;
185:                    for (int i = 0; i < fData.length(); i++) {
186:                        if (!XMLChar.isSpace(fData.charAt(i))) {
187:                            fIsSpace = false;
188:                            break;
189:                        }
190:                    }
191:                }
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.