|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
TextImpl.java | - | 26.3% | 50% | 34.5% |
|
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | * | |
17 | * $Id: TextImpl.java 571948 2007-09-02 10:51:37Z vgritsenko $ | |
18 | */ | |
19 | ||
20 | package org.apache.xindice.xml.dom; | |
21 | ||
22 | import org.w3c.dom.DOMException; | |
23 | import org.w3c.dom.Node; | |
24 | import org.w3c.dom.Text; | |
25 | ||
26 | /** | |
27 | * TextImpl | |
28 | * | |
29 | * @version $Revision: 571948 $, $Date: 2007-09-02 03:51:37 -0700 (Sun, 02 Sep 2007) $ | |
30 | */ | |
31 | public class TextImpl extends CharacterDataImpl | |
32 | implements Text { | |
33 | ||
34 | 0 | public TextImpl() { |
35 | } | |
36 | ||
37 | 173083 | public TextImpl(NodeImpl parent, byte[] data, int pos, int len) { |
38 | 173083 | super(parent, data, pos, len); |
39 | } | |
40 | ||
41 | 218009 | public TextImpl(NodeImpl parent, boolean dirty) { |
42 | 218009 | super(parent, dirty); |
43 | } | |
44 | ||
45 | 120687 | public TextImpl(NodeImpl parent, String nodeValue) { |
46 | 120687 | super(parent, nodeValue); |
47 | } | |
48 | ||
49 | 2616635 | public short getNodeType() { |
50 | 2616635 | return Node.TEXT_NODE; |
51 | } | |
52 | ||
53 | 278 | public String getNodeName() { |
54 | 278 | return "#text"; |
55 | } | |
56 | ||
57 | /** | |
58 | * Breaks this <code>Text</code> node into two Text nodes at the specified | |
59 | * offset, keeping both in the tree as siblings. This node then only | |
60 | * contains all the content up to the <code>offset</code> point. And a new | |
61 | * <code>Text</code> node, which is inserted as the next sibling of this | |
62 | * node, contains all the content at and after the <code>offset</code> | |
63 | * point. | |
64 | * @param offset The offset at which to split, starting from 0. | |
65 | * @return The new <code>Text</code> node. | |
66 | * @exception DOMException | |
67 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater | |
68 | * than the number of characters in <code>data</code>. | |
69 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
70 | */ | |
71 | 0 | public final Text splitText(int offset) throws DOMException { |
72 | 0 | String value = getNodeValue(); |
73 | 0 | checkReadOnly(); |
74 | 0 | try { |
75 | 0 | String newValue = value.substring(0, offset); |
76 | 0 | String oldValue = value.substring(offset + 1); |
77 | 0 | Text text = getOwnerDocument().createTextNode(newValue); |
78 | 0 | setNodeValue(oldValue); |
79 | 0 | getParentNode().insertBefore(text, this); |
80 | 0 | setDirty(); |
81 | 0 | return text; |
82 | } catch (Exception e) { | |
83 | 0 | throw EX_INDEX_SIZE; |
84 | } | |
85 | } | |
86 | ||
87 | /** | |
88 | * @since DOM Level 3 | |
89 | */ | |
90 | 0 | public boolean isElementContentWhitespace() { |
91 | 0 | return false; |
92 | } | |
93 | ||
94 | /** | |
95 | * @since DOM Level 3 | |
96 | */ | |
97 | 0 | public String getWholeText() { |
98 | 0 | throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is not supported"); |
99 | } | |
100 | ||
101 | /** | |
102 | * @since DOM Level 3 | |
103 | */ | |
104 | 0 | public Text replaceWholeText(String content) throws DOMException { |
105 | 0 | throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is not supported"); |
106 | } | |
107 | } |
|