1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.util.xml;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.xml.Element;
19  import com.liferay.portal.kernel.xml.Namespace;
20  import com.liferay.portal.kernel.xml.QName;
21  import com.liferay.portal.kernel.xml.SAXReaderUtil;
22  
23  /**
24   * <a href="DocUtil.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class DocUtil {
29  
30      public static void add(Element element, String name, boolean text) {
31          add(element, name, String.valueOf(text));
32      }
33  
34      public static void add(Element element, String name, double text) {
35          add(element, name, String.valueOf(text));
36      }
37  
38      public static void add(Element element, String name, float text) {
39          add(element, name, String.valueOf(text));
40      }
41  
42      public static void add(Element element, String name, int text) {
43          add(element, name, String.valueOf(text));
44      }
45  
46      public static void add(Element element, String name, long text) {
47          add(element, name, String.valueOf(text));
48      }
49  
50      public static Element add(
51          Element element, String name, Namespace namespace) {
52  
53          QName qName = SAXReaderUtil.createQName(name, namespace);
54  
55          return element.addElement(qName);
56      }
57  
58      public static void add(
59          Element element, String name, Namespace namespace, boolean text) {
60  
61          add(element, name, namespace, String.valueOf(text));
62      }
63  
64      public static void add(
65          Element element, String name, Namespace namespace, double text) {
66  
67          add(element, name, namespace, String.valueOf(text));
68      }
69  
70      public static void add(
71          Element element, String name, Namespace namespace, float text) {
72  
73          add(element, name, namespace, String.valueOf(text));
74      }
75  
76      public static void add(
77          Element element, String name, Namespace namespace, int text) {
78  
79          add(element, name, namespace, String.valueOf(text));
80      }
81  
82      public static void add(
83          Element element, String name, Namespace namespace, long text) {
84  
85          add(element, name, namespace, String.valueOf(text));
86      }
87  
88      public static void add(
89          Element element, String name, Namespace namespace, Object text) {
90  
91          add(element, name, namespace, String.valueOf(text));
92      }
93  
94      public static void add(
95          Element element, String name, Namespace namespace, short text) {
96  
97          add(element, name, namespace, String.valueOf(text));
98      }
99  
100     public static void add(
101         Element element, String name, Namespace namespace, String text) {
102 
103         QName qName = SAXReaderUtil.createQName(name, namespace);
104 
105         Element childElement = element.addElement(qName);
106 
107         childElement.addText(GetterUtil.getString(text));
108     }
109 
110     public static void add(Element element, String name, Object text) {
111         add(element, name, String.valueOf(text));
112     }
113 
114     public static void add(Element element, String name, short text) {
115         add(element, name, String.valueOf(text));
116     }
117 
118     public static void add(Element element, String name, String text) {
119         Element childElement = element.addElement(name);
120 
121         childElement.addText(GetterUtil.getString(text));
122     }
123 
124     /**
125      * @deprecated
126      */
127     public static void add(
128         org.dom4j.Element element, String name, boolean text) {
129 
130         add(element, name, String.valueOf(text));
131     }
132 
133     /**
134      * @deprecated
135      */
136     public static void add(
137         org.dom4j.Element element, String name, double text) {
138 
139         add(element, name, String.valueOf(text));
140     }
141 
142     /**
143      * @deprecated
144      */
145     public static void add(org.dom4j.Element element, String name, float text) {
146         add(element, name, String.valueOf(text));
147     }
148 
149     /**
150      * @deprecated
151      */
152     public static void add(org.dom4j.Element element, String name, int text) {
153         add(element, name, String.valueOf(text));
154     }
155 
156     /**
157      * @deprecated
158      */
159     public static void add(org.dom4j.Element element, String name, long text) {
160         add(element, name, String.valueOf(text));
161     }
162 
163     /**
164      * @deprecated
165      */
166     public static void add(
167         org.dom4j.Element element, String name, Object text) {
168 
169         add(element, name, String.valueOf(text));
170     }
171 
172     /**
173      * @deprecated
174      */
175     public static org.dom4j.Element add(
176         org.dom4j.Element element, String name, org.dom4j.Namespace namespace) {
177 
178         org.dom4j.QName qName = new org.dom4j.QName(name, namespace);
179 
180         return element.addElement(qName);
181     }
182 
183     /**
184      * @deprecated
185      */
186     public static void add(
187         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
188         boolean text) {
189 
190         add(element, name, namespace, String.valueOf(text));
191     }
192 
193     /**
194      * @deprecated
195      */
196     public static void add(
197         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
198         double text) {
199 
200         add(element, name, namespace, String.valueOf(text));
201     }
202 
203     /**
204      * @deprecated
205      */
206     public static void add(
207         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
208         float text) {
209 
210         add(element, name, namespace, String.valueOf(text));
211     }
212 
213     /**
214      * @deprecated
215      */
216     public static void add(
217         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
218         int text) {
219 
220         add(element, name, namespace, String.valueOf(text));
221     }
222 
223     /**
224      * @deprecated
225      */
226     public static void add(
227         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
228         long text) {
229 
230         add(element, name, namespace, String.valueOf(text));
231     }
232 
233     /**
234      * @deprecated
235      */
236     public static void add(
237         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
238         Object text) {
239 
240         add(element, name, namespace, String.valueOf(text));
241     }
242 
243     /**
244      * @deprecated
245      */
246     public static void add(
247         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
248         short text) {
249 
250         add(element, name, namespace, String.valueOf(text));
251     }
252 
253     /**
254      * @deprecated
255      */
256     public static void add(
257         org.dom4j.Element element, String name, org.dom4j.Namespace namespace,
258         String text) {
259 
260         org.dom4j.QName qName = new org.dom4j.QName(name, namespace);
261 
262         org.dom4j.Element childElement = element.addElement(qName);
263 
264         childElement.addText(GetterUtil.getString(text));
265     }
266 
267     /**
268      * @deprecated
269      */
270     public static void add(org.dom4j.Element element, String name, short text) {
271         add(element, name, String.valueOf(text));
272     }
273 
274     /**
275      * @deprecated
276      */
277     public static void add(
278         org.dom4j.Element element, String name, String text) {
279 
280         org.dom4j.Element childElement = element.addElement(name);
281 
282         childElement.addText(GetterUtil.getString(text));
283     }
284 
285 }