Debian Codegraph @

net/sf/saxon/tree/linked/ProcInstImpl.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.om.AtomicSequence;
13 import net.sf.saxon.om.NoNamespaceName;
14 import net.sf.saxon.om.NodeName;
15 import net.sf.saxon.trans.XPathException;
16 import net.sf.saxon.type.Type;
17 import net.sf.saxon.value.StringValue;
18
19 /**
20 * ProcInstImpl is an implementation of ProcInstInfo used by the Propagator to construct
21 * its trees.
22 *
23 * @author Michael H. Kay
24 */
25
26
27 public class ProcInstImpl extends NodeImpl {
28
29 String content;
30 String name;
31 String systemId;
32 int lineNumber = -1;
33 int columnNumber = -1;
34
35 public ProcInstImpl(String name, String content) {
36 this.name = name;
37 this.content = content;
38 }
39
40 /**
41 * Get the name of the node. Returns null for an unnamed node
42 *
43 * @return the name of the node
44 */
45 @Override
46 public NodeName getNodeName() {
47 return new NoNamespaceName(name);
48 }
49
50
51
52 public String getStringValue() {
53 return content;
54 }
55
56 /**
57 * Get the typed value of this node.
58 * Returns the string value, as an instance of xs:string
59 */
60
61 /*@NotNull*/
62 public AtomicSequence atomize() {
63 return new StringValue(getStringValue());
64 }
65
66 public final int getNodeKind() {
67 return Type.PROCESSING_INSTRUCTION;
68 }
69
70 /**
71 * Set the system ID and line number
72 *
73 * @param uri the system identifier
74 * @param lineNumber the line number
75 */
76
77 public void setLocation(String uri, int lineNumber, int columnNumber) {
78 this.systemId = uri;
79 this.lineNumber = lineNumber;
80 this.columnNumber = columnNumber;
81 }
82
83 /**
84 * Get the system ID for the entity containing this node.
85 *
86 * @return the system identifier
87 */
88
89 public String getSystemId() {
90 return systemId;
91 }
92
93 /**
94 * Get the line number of the node within its source entity
95 */
96
97 public int getLineNumber() {
98 return lineNumber;
99 }
100
101 /**
102 * Get the column number of the node within its source entity
103 */
104
105 public int getColumnNumber() {
106 return columnNumber;
107 }
108
109
110 /**
111 * Copy this node to a given outputter
112 */
113
114 public void copy(/*@NotNull*/ Receiver out, int copyOptions, Location locationId) throws XPathException {
115 out.processingInstruction(getLocalPart(), content, locationId, 0);
116 }
117
118 /**
119 * Rename this node
120 *
121 * @param newNameCode the new name
122 */
123
124 public void rename(NodeName newNameCode) {
125 name = newNameCode.getLocalPart();
126 }
127
128
129 /**
130 * Replace the string-value of this node
131 *
132 * @param stringValue the new string value
133 */
134
135 public void replaceStringValue(/*@NotNull*/ CharSequence stringValue) {
136 content = stringValue.toString();
137 }
138 }
139