Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 26ac014cc20cbb6e100dca1062fde59bb7e651d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*******************************************************************************
 * Copyright (c) 2013 Florian Thienel and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 * 		Florian Thienel - initial API and implementation
 *******************************************************************************/
package org.eclipse.vex.core.dom;

/**
 * A representation of one node in the XML structure. A node is associated to a range of the textual content.
 * <p>
 * This is the base for all representatives of the XML structure in the document object model (DOM).
 * 
 * @author Florian Thienel
 */
public interface INode {

	/**
	 * @see IParent
	 * @return the parent of this node, maybe null if this node has no parent
	 */
	IParent getParent();

	/**
	 * The ancestors axis contains all subsequent parents of this node.
	 * 
	 * @return the ancestors axis of this node
	 * @see IAxis
	 */
	IAxis<IParent> ancestors();

	/**
	 * @return if this node is associated to content
	 */
	boolean isAssociated();

	/**
	 * @return the content to which this node is associated or null if this node is not associated to any content yet
	 */
	IContent getContent();

	/**
	 * The start offset of this node, which eventually also includes the position of a tag marker.
	 * 
	 * @return the start offset of this node within the textual content
	 */
	int getStartOffset();

	/**
	 * The end offset of this node, which eventually also includes the position of a tag marker.
	 * 
	 * @return the end offset of this node within the textual content
	 */
	int getEndOffset();

	/**
	 * @return the range in the content to which this node is associated, eventually including tag markers
	 */
	ContentRange getRange();

	/**
	 * Indicate whether this node has no content beside its tag markers. If this node is not associated with textual
	 * content, this method returns false.
	 * 
	 * @return true if this node has no content beside its tag markers
	 */
	boolean isEmpty();

	/**
	 * Indicate whether the given offset is within the boundaries of this node. If this node is not associated with
	 * textual content, this method returns false.
	 * 
	 * @param offset
	 *            the offset
	 * @return true if the given offset is withing [startOffset; endOffset], or false if not associated
	 */
	boolean containsOffset(int offset);

	/**
	 * Indicate whether this node is fully within the given range. If this node is not associated with textual content,
	 * this method returns false.
	 * 
	 * @param range
	 *            the range
	 * @return true if this node is fully within the given range
	 */
	boolean isInRange(ContentRange range);

	/**
	 * @return the textual content of this node, not including any tag markers
	 */
	String getText();

	/**
	 * The textual content in the given range, not including any element markers.
	 * 
	 * @param range
	 *            the range of the textual content
	 * @return the textual content in the given range
	 */
	String getText(ContentRange range);

	/**
	 * @return the document to which this node belongs, or null if this node does not belong to any document
	 */
	IDocument getDocument();

	/**
	 * Indicate whether this and the given node are of the same kind (e.g. elements with the same qualified name).
	 * 
	 * @return true if this and the given node are of the same kind
	 */
	boolean isKindOf(INode node);

	/**
	 * The xml:base attribute re-defines the base URI for a part of an XML document, according to the XML Base
	 * Recommendation.
	 * 
	 * @see http://www.w3.org/TR/xmlbase/
	 * @return the base URI of this node
	 */
	String getBaseURI();

	/**
	 * Accept the given visitor.
	 * 
	 * @see INodeVisitor
	 * @param visitor
	 *            the visitor
	 */
	void accept(INodeVisitor visitor);

	/**
	 * Accept the given visitor.
	 * 
	 * @see INodeVisitorWithResult
	 * @param visitor
	 *            the visitor
	 */
	<T> T accept(INodeVisitorWithResult<T> visitor);

}

Back to the top