Debian Codegraph @

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