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