1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.util.xml;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  
27  import org.dom4j.Element;
28  import org.dom4j.Namespace;
29  import org.dom4j.QName;
30  
31  /**
32   * <a href="DocUtil.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class DocUtil {
38  
39      public static void add(Element el, String name, boolean text) {
40          add(el, name, String.valueOf(text));
41      }
42  
43      public static void add(Element el, String name, double text) {
44          add(el, name, String.valueOf(text));
45      }
46  
47      public static void add(Element el, String name, float text) {
48          add(el, name, String.valueOf(text));
49      }
50  
51      public static void add(Element el, String name, int text) {
52          add(el, name, String.valueOf(text));
53      }
54  
55      public static void add(Element el, String name, long text) {
56          add(el, name, String.valueOf(text));
57      }
58  
59      public static void add(Element el, String name, short text) {
60          add(el, name, String.valueOf(text));
61      }
62  
63      public static void add(Element el, String name, Object text) {
64          add(el, name, String.valueOf(text));
65      }
66  
67      public static void add(Element el, String name, String text) {
68          el.addElement(name).addText(GetterUtil.getString(text));
69      }
70  
71      public static Element add(Element el, String name, Namespace ns) {
72          return el.addElement(new QName(name, ns));
73      }
74  
75      public static void add(
76          Element el, String name, Namespace ns, boolean text) {
77  
78          add(el, name, ns, String.valueOf(text));
79      }
80  
81      public static void add(Element el, String name, Namespace ns, double text) {
82          add(el, name, ns, String.valueOf(text));
83      }
84  
85      public static void add(Element el, String name, Namespace ns, float text) {
86          add(el, name, ns, String.valueOf(text));
87      }
88  
89      public static void add(Element el, String name, Namespace ns, int text) {
90          add(el, name, ns, String.valueOf(text));
91      }
92  
93      public static void add(Element el, String name, Namespace ns, long text) {
94          add(el, name, ns, String.valueOf(text));
95      }
96  
97      public static void add(Element el, String name, Namespace ns, short text) {
98          add(el, name, ns, String.valueOf(text));
99      }
100 
101     public static void add(Element el, String name, Namespace ns, Object text) {
102         add(el, name, ns, String.valueOf(text));
103     }
104 
105     public static void add(Element el, String name, Namespace ns, String text) {
106         el.addElement(new QName(name, ns)).addText(GetterUtil.getString(text));
107     }
108 
109 }