Debian Codegraph @

net/sf/saxon/tree/linked/TextImpl.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.tree.linked;
9
10 import net.sf.saxon.event.Receiver;
11 import net.sf.saxon.expr.parser.Location;
12 import net.sf.saxon.trans.XPathException;
13 import net.sf.saxon.type.Type;
14
15 /**
16 * A node in the XML parse tree representing character content.
17 *
18 * @author Michael H. Kay
19 */
20
21 public class TextImpl extends NodeImpl {
22
23 private String content;
24
25 public TextImpl(String content) {
26 this.content = content;
27 }
28
29 /**
30 * Append to the content of the text node
31 *
32 * @param content the new content to be appended
33 */
34
35 public void appendStringValue(String content) {
36 this.content = this.content + content;
37 }
38
39 /**
40 * Return the character value of the node.
41 *
42 * @return the string value of the node
43 */
44
45 public String getStringValue() {
46 return content;
47 }
48
49 /**
50 * Return the type of node.
51 *
52 * @return Type.TEXT
53 */
54
55 public final int getNodeKind() {
56 return Type.TEXT;
57 }
58
59 /**
60 * Copy this node to a given outputter
61 */
62
63 public void copy(/*@NotNull*/ Receiver out, int copyOptions, Location locationId) throws XPathException {
64 out.characters(content, locationId, 0);
65 }
66
67
68 /**
69 * Replace the string-value of this node
70 *
71 * @param stringValue the new string value
72 */
73
74 public void replaceStringValue(/*@NotNull*/ CharSequence stringValue) {
75 if (stringValue.length() == 0) {
76 delete();
77 } else {
78 content = stringValue.toString();
79 }
80 }
81
82 }
83