1
19
20 package com.liferay.portal.xml;
21
22 import com.liferay.portal.kernel.xml.Document;
23 import com.liferay.portal.kernel.xml.Element;
24 import com.liferay.portal.kernel.xml.Node;
25
26 import java.io.IOException;
27 import java.io.Writer;
28
29 import java.util.List;
30
31
37 public class NodeImpl implements Node {
38
39 public NodeImpl(org.dom4j.Node node) {
40 _node = node;
41 }
42
43 public String asXML() {
44 return _node.asXML();
45 }
46
47 public Node asXPathResult(Element parent) {
48 ElementImpl parentImpl = (ElementImpl)parent;
49
50 org.dom4j.Node node = _node.asXPathResult(
51 parentImpl.getWrappedElement());
52
53 if (node == null) {
54 return null;
55 }
56 if (node instanceof org.dom4j.Element) {
57 return new ElementImpl((org.dom4j.Element)node);
58 }
59 else {
60 return new NodeImpl(node);
61 }
62 }
63
64 public Node detach() {
65 org.dom4j.Node node = _node.detach();
66
67 if (node == null) {
68 return null;
69 }
70 if (node instanceof org.dom4j.Element) {
71 return new ElementImpl((org.dom4j.Element)node);
72 }
73 else {
74 return new NodeImpl(node);
75 }
76 }
77
78 public boolean equals(Object obj) {
79 org.dom4j.Node node = ((NodeImpl)obj).getWrappedNode();
80
81 return _node.equals(node);
82 }
83
84 public Document getDocument() {
85 org.dom4j.Document document = _node.getDocument();
86
87 if (document == null) {
88 return null;
89 }
90 else {
91 return new DocumentImpl(document);
92 }
93 }
94
95 public String getName() {
96 return _node.getName();
97 }
98
99 public Element getParent() {
100 org.dom4j.Element element = _node.getParent();
101
102 if (element == null) {
103 return null;
104 }
105 else {
106 return new ElementImpl(element);
107 }
108 }
109
110 public String getPath() {
111 return _node.getPath();
112 }
113
114 public String getPath(Element context) {
115 ElementImpl contextImpl = (ElementImpl)context;
116
117 return _node.getPath(contextImpl.getWrappedElement());
118 }
119
120 public String getStringValue() {
121 return _node.getStringValue();
122 }
123
124 public String getText() {
125 return _node.getText();
126 }
127
128 public String getUniquePath() {
129 return _node.getUniquePath();
130 }
131
132 public String getUniquePath(Element context) {
133 ElementImpl contextImpl = (ElementImpl)context;
134
135 return _node.getUniquePath(contextImpl.getWrappedElement());
136 }
137
138 public org.dom4j.Node getWrappedNode() {
139 return _node;
140 }
141
142 public boolean hasContent() {
143 return _node.hasContent();
144 }
145
146 public int hashCode() {
147 return _node.hashCode();
148 }
149
150 public boolean isReadOnly() {
151 return _node.isReadOnly();
152 }
153
154 public boolean matches(String xpathExpression) {
155 return _node.matches(xpathExpression);
156 }
157
158 public Number numberValueOf(String xpathExpression) {
159 return _node.numberValueOf(xpathExpression);
160 }
161
162 public List<Node> selectNodes(String xpathExpression) {
163 return SAXReaderImpl.toNewNodes(_node.selectNodes(xpathExpression));
164 }
165
166 public List<Node> selectNodes(
167 String xpathExpression, String comparisonXPathExpression) {
168
169 return SAXReaderImpl.toNewNodes(
170 _node.selectNodes(xpathExpression, comparisonXPathExpression));
171 }
172
173 public List<Node> selectNodes(
174 String xpathExpression, String comparisonXPathExpression,
175 boolean removeDuplicates) {
176
177 return SAXReaderImpl.toNewNodes(
178 _node.selectNodes(
179 xpathExpression, comparisonXPathExpression, removeDuplicates));
180 }
181
182 public Object selectObject(String xpathExpression) {
183 Object obj = _node.selectObject(xpathExpression);
184
185 if (obj == null) {
186 return null;
187 }
188 else if (obj instanceof List) {
189 return SAXReaderImpl.toNewNodes((List<org.dom4j.Node>)obj);
190 }
191 else {
192 return obj;
193 }
194 }
195
196 public Node selectSingleNode(String xpathExpression) {
197 org.dom4j.Node node = _node.selectSingleNode(xpathExpression);
198
199 if (node == null) {
200 return null;
201 }
202 if (node instanceof org.dom4j.Element) {
203 return new ElementImpl((org.dom4j.Element)node);
204 }
205 else {
206 return new NodeImpl(node);
207 }
208 }
209
210 public void setName(String name) {
211 _node.setName(name);
212 }
213
214 public void setText(String text) {
215 _node.setText(text);
216 }
217
218 public boolean supportsParent() {
219 return _node.supportsParent();
220 }
221
222 public String valueOf(String xpathExpression) {
223 return _node.valueOf(xpathExpression);
224 }
225
226 public void write(Writer writer) throws IOException {
227 _node.write(writer);
228 }
229
230 private org.dom4j.Node _node;
231
232 }