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 else {
57 return new NodeImpl(node);
58 }
59 }
60
61 public Node detach() {
62 org.dom4j.Node node = _node.detach();
63
64 if (node == null) {
65 return null;
66 }
67 else {
68 return new NodeImpl(node);
69 }
70 }
71
72 public boolean equals(Object obj) {
73 org.dom4j.Node node = ((NodeImpl)obj).getWrappedNode();
74
75 return _node.equals(node);
76 }
77
78 public Document getDocument() {
79 org.dom4j.Document document = _node.getDocument();
80
81 if (document == null) {
82 return null;
83 }
84 else {
85 return new DocumentImpl(document);
86 }
87 }
88
89 public String getName() {
90 return _node.getName();
91 }
92
93 public Element getParent() {
94 org.dom4j.Element element = _node.getParent();
95
96 if (element == null) {
97 return null;
98 }
99 else {
100 return new ElementImpl(element);
101 }
102 }
103
104 public String getPath() {
105 return _node.getPath();
106 }
107
108 public String getPath(Element context) {
109 ElementImpl contextImpl = (ElementImpl)context;
110
111 return _node.getPath(contextImpl.getWrappedElement());
112 }
113
114 public String getStringValue() {
115 return _node.getStringValue();
116 }
117
118 public String getText() {
119 return _node.getText();
120 }
121
122 public String getUniquePath() {
123 return _node.getUniquePath();
124 }
125
126 public String getUniquePath(Element context) {
127 ElementImpl contextImpl = (ElementImpl)context;
128
129 return _node.getUniquePath(contextImpl.getWrappedElement());
130 }
131
132 public org.dom4j.Node getWrappedNode() {
133 return _node;
134 }
135
136 public boolean hasContent() {
137 return _node.hasContent();
138 }
139
140 public int hashCode() {
141 return _node.hashCode();
142 }
143
144 public boolean isReadOnly() {
145 return _node.isReadOnly();
146 }
147
148 public boolean matches(String xpathExpression) {
149 return _node.matches(xpathExpression);
150 }
151
152 public Number numberValueOf(String xpathExpression) {
153 return _node.numberValueOf(xpathExpression);
154 }
155
156 public List<Node> selectNodes(String xpathExpression) {
157 return SAXReaderImpl.toNewNodes(_node.selectNodes(xpathExpression));
158 }
159
160 public List<Node> selectNodes(
161 String xpathExpression, String comparisonXPathExpression) {
162
163 return SAXReaderImpl.toNewNodes(
164 _node.selectNodes(xpathExpression, comparisonXPathExpression));
165 }
166
167 public List<Node> selectNodes(
168 String xpathExpression, String comparisonXPathExpression,
169 boolean removeDuplicates) {
170
171 return SAXReaderImpl.toNewNodes(
172 _node.selectNodes(
173 xpathExpression, comparisonXPathExpression, removeDuplicates));
174 }
175
176 public Object selectObject(String xpathExpression) {
177 Object obj = _node.selectObject(xpathExpression);
178
179 if (obj == null) {
180 return null;
181 }
182 else if (obj instanceof List) {
183 return SAXReaderImpl.toNewNodes((List<org.dom4j.Node>)obj);
184 }
185 else {
186 return obj;
187 }
188 }
189
190 public Node selectSingleNode(String xpathExpression) {
191 org.dom4j.Node node = _node.selectSingleNode(xpathExpression);
192
193 if (node == null) {
194 return null;
195 }
196 else {
197 return new NodeImpl(node);
198 }
199 }
200
201 public void setName(String name) {
202 _node.setName(name);
203 }
204
205 public void setText(String text) {
206 _node.setText(text);
207 }
208
209 public boolean supportsParent() {
210 return _node.supportsParent();
211 }
212
213 public String valueOf(String xpathExpression) {
214 return _node.valueOf(xpathExpression);
215 }
216
217 public void write(Writer writer) throws IOException {
218 _node.write(writer);
219 }
220
221 private org.dom4j.Node _node;
222
223 }