Source Code Cross Referenced for TextOverNodeInfo.java in  » XML » XPath-Saxon » net » sf » saxon » dom » 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 » XPath Saxon » net.sf.saxon.dom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.dom;
002:
003:        import net.sf.saxon.type.ComplexType;
004:        import net.sf.saxon.type.SchemaType;
005:        import net.sf.saxon.type.Type;
006:        import net.sf.saxon.value.Whitespace;
007:        import org.w3c.dom.Comment;
008:        import org.w3c.dom.DOMException;
009:        import org.w3c.dom.Text;
010:
011:        /**
012:         * This class is an implementation of the DOM Text and Comment interfaces that wraps a Saxon NodeInfo
013:         * representation of a text or comment node.
014:         */
015:
016:        public class TextOverNodeInfo extends NodeOverNodeInfo implements  Text,
017:                Comment {
018:
019:            /**
020:             * Get the character data of a Text or Comment node.
021:             * DOM method.
022:             */
023:
024:            public String getData() {
025:                return node.getStringValue();
026:            }
027:
028:            /**
029:             * Set the character data of a Text or Comment node.
030:             * DOM method: always fails, Saxon tree is immutable.
031:             */
032:
033:            public void setData(String data) throws DOMException {
034:                disallowUpdate();
035:            }
036:
037:            /**
038:             * Get the length of a Text or Comment node.
039:             * DOM method.
040:             */
041:
042:            public int getLength() {
043:                return node.getStringValue().length();
044:            }
045:
046:            /**
047:             * Extract a range of data from a Text or Comment node. DOM method.
048:             * @param offset  Start offset of substring to extract.
049:             * @param count  The number of 16-bit units to extract.
050:             * @return  The specified substring. If the sum of <code>offset</code> and
051:             *   <code>count</code> exceeds the <code>length</code> , then all 16-bit
052:             *   units to the end of the data are returned.
053:             * @exception org.w3c.dom.DOMException
054:             *    INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
055:             *   negative or greater than the number of 16-bit units in
056:             *   <code>data</code> , or if the specified <code>count</code> is
057:             *   negative.
058:             */
059:
060:            public String substringData(int offset, int count)
061:                    throws DOMException {
062:                try {
063:                    return node.getStringValue().substring(offset,
064:                            offset + count);
065:                } catch (IndexOutOfBoundsException err2) {
066:                    throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR,
067:                            "substringData: index out of bounds");
068:                }
069:            }
070:
071:            /**
072:             * Append the string to the end of the character data of the node.
073:             * DOM method: always fails.
074:             * @param arg  The <code>DOMString</code> to append.
075:             * @exception org.w3c.dom.DOMException
076:             *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
077:             */
078:
079:            public void appendData(String arg) throws DOMException {
080:                disallowUpdate();
081:            }
082:
083:            /**
084:             * Insert a string at the specified character offset.
085:             * DOM method: always fails.
086:             * @param offset  The character offset at which to insert.
087:             * @param arg  The <code>DOMString</code> to insert.
088:             * @exception org.w3c.dom.DOMException
089:             */
090:
091:            public void insertData(int offset, String arg) throws DOMException {
092:                disallowUpdate();
093:            }
094:
095:            /**
096:             * Remove a range of 16-bit units from the node.
097:             * DOM method: always fails.
098:             * @param offset  The offset from which to start removing.
099:             * @param count  The number of 16-bit units to delete.
100:             * @exception org.w3c.dom.DOMException
101:             */
102:
103:            public void deleteData(int offset, int count) throws DOMException {
104:                disallowUpdate();
105:            }
106:
107:            /**
108:             * Replace the characters starting at the specified 16-bit unit offset
109:             * with the specified string. DOM method: always fails.
110:             * @param offset  The offset from which to start replacing.
111:             * @param count  The number of 16-bit units to replace.
112:             * @param arg  The <code>DOMString</code> with which the range must be
113:             *   replaced.
114:             * @exception org.w3c.dom.DOMException
115:             *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
116:             */
117:
118:            public void replaceData(int offset, int count, String arg)
119:                    throws DOMException {
120:                disallowUpdate();
121:            }
122:
123:            /**
124:             * Break this node into two nodes at the specified offset,
125:             * keeping both in the tree as siblings. DOM method, always fails.
126:             * @param offset  The 16-bit unit offset at which to split, starting from 0.
127:             * @return  The new node, of the same type as this node.
128:             * @exception org.w3c.dom.DOMException
129:             */
130:
131:            public Text splitText(int offset) throws DOMException {
132:                disallowUpdate();
133:                return null;
134:            }
135:
136:            /**
137:             * Replaces the text of the current node and all logically-adjacent text
138:             * nodes with the specified text. All logically-adjacent text nodes are
139:             * removed including the current node unless it was the recipient of the
140:             * replacement text.
141:             * <br>This method returns the node which received the replacement text.
142:             * The returned node is:
143:             * <ul>
144:             * <li><code>null</code>, when the replacement text is
145:             * the empty string;
146:             * </li>
147:             * <li>the current node, except when the current node is
148:             * read-only;
149:             * </li>
150:             * <li> a new <code>Text</code> node of the same type (
151:             * <code>Text</code> or <code>CDATASection</code>) as the current node
152:             * inserted at the location of the replacement.
153:             * </li>
154:             * </ul>
155:             * <br>For instance, in the above example calling
156:             * <code>replaceWholeText</code> on the <code>Text</code> node that
157:             * contains "bar" with "yo" in argument results in the following:
158:             * <br>Where the nodes to be removed are read-only descendants of an
159:             * <code>EntityReference</code>, the <code>EntityReference</code> must
160:             * be removed instead of the read-only nodes. If any
161:             * <code>EntityReference</code> to be removed has descendants that are
162:             * not <code>EntityReference</code>, <code>Text</code>, or
163:             * <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
164:             * method must fail before performing any modification of the document,
165:             * raising a <code>DOMException</code> with the code
166:             * <code>NO_MODIFICATION_ALLOWED_ERR</code>.
167:             * <br>For instance, in the example below calling
168:             * <code>replaceWholeText</code> on the <code>Text</code> node that
169:             * contains "bar" fails, because the <code>EntityReference</code> node
170:             * "ent" contains an <code>Element</code> node which cannot be removed.
171:             *
172:             * @param content The content of the replacing <code>Text</code> node.
173:             * @return The <code>Text</code> node created with the specified content.
174:             * @throws org.w3c.dom.DOMException NO_MODIFICATION_ALLOWED_ERR: Raised if one of the <code>Text</code>
175:             *                                  nodes being replaced is readonly.
176:             * @since DOM Level 3
177:             */
178:            public Text replaceWholeText(String content) throws DOMException {
179:                disallowUpdate();
180:                return null;
181:            }
182:
183:            /**
184:             * Returns whether this text node contains <a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
185:             * element content whitespace</a>, often abusively called "ignorable whitespace". The text node is
186:             * determined to contain whitespace in element content during the load
187:             * of the document or if validation occurs while using
188:             * <code>Document.normalizeDocument()</code>.
189:             *
190:             * @since DOM Level 3
191:             */
192:            public boolean isElementContentWhitespace() {
193:                if (node.getNodeKind() != Type.TEXT) {
194:                    throw new UnsupportedOperationException(
195:                            "Method is defined only on text nodes");
196:                }
197:                int annotation = node.getParent().getTypeAnnotation();
198:                if (annotation == -1) {
199:                    return false;
200:                }
201:                if (!Whitespace.isWhite(node.getStringValue())) {
202:                    return false;
203:                }
204:                SchemaType type = node.getConfiguration().getSchemaType(
205:                        annotation);
206:                if (!type.isComplexType()) {
207:                    return false;
208:                }
209:                if (((ComplexType) type).isMixedContent()) {
210:                    return false;
211:                }
212:                return true;
213:            }
214:
215:            /**
216:             * Returns all text of <code>Text</code> nodes logically-adjacent text
217:             * nodes to this node, concatenated in document order.
218:             * <br>For instance, in the example below <code>wholeText</code> on the
219:             * <code>Text</code> node that contains "bar" returns "barfoo", while on
220:             * the <code>Text</code> node that contains "foo" it returns "barfoo".
221:             *
222:             * @since DOM Level 3
223:             */
224:            public String getWholeText() {
225:                if (node.getNodeKind() != Type.TEXT) {
226:                    throw new UnsupportedOperationException(
227:                            "Method is defined only on text nodes");
228:                }
229:                return node.getStringValue();
230:            }
231:
232:        }
233:
234:        //
235:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
236:        // you may not use this file except in compliance with the License. You may obtain a copy of the
237:        // License at http://www.mozilla.org/MPL/
238:        //
239:        // Software distributed under the License is distributed on an "AS IS" basis,
240:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
241:        // See the License for the specific language governing rights and limitations under the License.
242:        //
243:        // The Original Code is: all this file.
244:        //
245:        // The Initial Developer of the Original Code is Michael H. Kay.
246:        //
247:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
248:        //
249:        // Contributor(s): none.
250:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.