Source Code Cross Referenced for Text.java in  » Web-Server » Rimfaxe-Web-Server » com » rimfaxe » xml » xmlreader » 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 Server » Rimfaxe Web Server » com.rimfaxe.xml.xmlreader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.rimfaxe.xml.xmlreader;
002:
003:        import java.io.IOException;
004:        import java.io.Writer;
005:        import java.util.Enumeration;
006:
007:        /**
008:         * A section of text in an element.  In XML this can be either CDATA or not:
009:         * the DOM model does not distinguish between the two encodings.
010:
011:         <blockquote><small> Copyright (C) 2002 Hewlett-Packard Company.
012:         This file is part of Sparta, an XML Parser, DOM, and XPath library.
013:         This library is free software; you can redistribute it and/or
014:         modify it under the terms of the GNU Lesser General Public License
015:         as published by the Free Software Foundation; either version 2.1 of
016:         the License, or (at your option) any later version.  This library
017:         is distributed in the hope that it will be useful, but WITHOUT ANY
018:         WARRANTY; without even the implied warranty of MERCHANTABILITY or
019:         FITNESS FOR A PARTICULAR PURPOSE. </small></blockquote>
020:         @see <a "href="doc-files/LGPL.txt">GNU Lesser General Public License</a>
021:         @version  $Date: 2002/12/13 23:09:24 $  $Revision: 1.3 $
022:         @author Eamonn O'Brien-Strain
023:         * @see org.w3c.dom.Text
024:         */
025:
026:        public class Text extends Node {
027:
028:            /**
029:             * Create with an initial character as its data.  This can be added to later.
030:             */
031:            public Text(String data) {
032:                text_ = new StringBuffer(data);
033:            }
034:
035:            /**
036:             * Create with an initial character as its data.  This can be added to later.
037:             */
038:            public Text(char ch) {
039:                text_ = new StringBuffer();
040:                text_.append(ch);
041:            }
042:
043:            /** Deep clone: returns Text node with copy of this ones data. */
044:            public Object clone() {
045:                Text result = (Text) super .clone();
046:                result.text_ = new StringBuffer(text_.toString());
047:                return result;
048:            }
049:
050:            public void appendData(String s) {
051:                text_.append(s);
052:                notifyObservers();
053:            }
054:
055:            public void appendData(char ch) {
056:                text_.append(ch);
057:                notifyObservers();
058:            }
059:
060:            /**
061:             * @param cbuf characters, some of which are to be appended to the text data
062:             * @param offset the first index in cbuf to copy
063:             * @param len the number of characters to copy
064:             */
065:            public void appendData(char[] cbuf, int offset, int len) {
066:                text_.append(cbuf, offset, len);
067:                notifyObservers();
068:            }
069:
070:            public String getData() {
071:                return text_.toString();
072:            }
073:
074:            public void setData(String data) {
075:                text_ = new StringBuffer(data);
076:                notifyObservers();
077:            }
078:
079:            void toXml(Writer writer) throws IOException {
080:                //System.out.println("Text.toXml "+text_.toString());
081:                String s = text_.toString();
082:                if (s.length() < 50)
083:                    //short
084:                    htmlEncode(writer, s);
085:                else {
086:                    //long
087:                    writer.write("<![CDATA[");
088:                    writer.write(s);
089:                    writer.write("]]>");
090:                }
091:            }
092:
093:            void toString(Writer writer) throws IOException {
094:                writer.write(text_.toString());
095:            }
096:
097:            /** Not implemented. */
098:            public Enumeration xpathSelectElements(String xpath) {
099:                throw new Error("Sorry, not implemented");
100:            }
101:
102:            /** Not implemented */
103:            public Enumeration xpathSelectStrings(String xpath) {
104:                throw new Error("Sorry, not implemented");
105:            }
106:
107:            /** Not implemented. */
108:            public Element xpathSelectElement(String xpath) {
109:                throw new Error("Sorry, not implemented");
110:            }
111:
112:            /** Not implemented. */
113:            public String xpathSelectString(String xpath) {
114:                throw new Error("Sorry, not implemented");
115:            }
116:
117:            /**   Text nodes can be equal even if they are in different documents,
118:             *    different parents, different siblings, or different annotations.
119:             *    They are equal IFF their string data is equal
120:             *     */
121:            public boolean equals(Object thatO) {
122:
123:                //Do cheap tests first
124:                if (this  == thatO)
125:                    return true;
126:                if (!(thatO instanceof  Text))
127:                    return false;
128:                Text that = (Text) thatO;
129:                return this .text_.toString().equals(that.text_.toString());
130:            }
131:
132:            private StringBuffer text_;
133:        }
134:
135:        // $Log: Text.java,v $
136:        // Revision 1.3  2002/12/13 23:09:24  eobrain
137:        // Fix javadoc.
138:        //
139:        // Revision 1.2  2002/11/06 02:57:59  eobrain
140:        // Organize imputs to removed unused imports.  Remove some unused local variables.
141:        //
142:        // Revision 1.1.1.1  2002/08/19 05:03:53  eobrain
143:        // import from HP Labs internal CVS
144:        //
145:        // Revision 1.11  2002/08/18 04:22:24  eob
146:        // Sparta no longer throws XPathException -- it throws ParseException
147:        // instead.  Remove deprecated constructors.
148:        //
149:        // Revision 1.10  2002/08/15 21:23:00  eob
150:        // Constructor no longer needs document.
151:        //
152:        // Revision 1.9  2002/08/15 05:09:22  eob
153:        // Notify observers.  CDATA
154:        //
155:        // Revision 1.8  2002/08/01 23:29:17  sermarti
156:        // Much faster Sparta parsing.
157:        // Has debug features enabled by default. Currently toggled
158:        // in ParseCharStream.java and recompiled.
159:        //
160:        // Revision 1.7  2002/06/14 19:37:51  eob
161:        // Make toString of Node do the same as in XSLT -- recursive
162:        // concatenation of all text in text nodes.
163:        //
164:        // Revision 1.6  2002/05/23 21:32:05  eob
165:        // Add appendData method for efficiency.  This optimization was done
166:        // because of what performance profiling showed.
167:        //
168:        // Revision 1.5  2002/05/11 00:10:53  eob
169:        // Add stubs for xpathSelect* methods.
170:        //
171:        // Revision 1.4  2002/05/10 21:38:06  eob
172:        // equals added
173:        //
174:        // Revision 1.3  2002/03/28 01:23:18  jrowson
175:        // fixed bugs related to client side caching
176:        //
177:        // Revision 1.2  2002/02/23 02:07:11  eob
178:        // Add clone method.  Tweak toXml API.
179:        //
180:        // Revision 1.1  2002/01/05 07:31:50  eob
181:        // initial
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.