001
014
015 package com.liferay.util.xml;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.kernel.xml.Element;
019 import com.liferay.portal.kernel.xml.Namespace;
020 import com.liferay.portal.kernel.xml.QName;
021 import com.liferay.portal.kernel.xml.SAXReaderUtil;
022
023
026 public class DocUtil {
027
028 public static Element add(Element element, String name, boolean text) {
029 return add(element, name, String.valueOf(text));
030 }
031
032 public static Element add(Element element, String name, double text) {
033 return add(element, name, String.valueOf(text));
034 }
035
036 public static Element add(Element element, String name, float text) {
037 return add(element, name, String.valueOf(text));
038 }
039
040 public static Element add(Element element, String name, int text) {
041 return add(element, name, String.valueOf(text));
042 }
043
044 public static Element add(Element element, String name, long text) {
045 return add(element, name, String.valueOf(text));
046 }
047
048 public static Element add(
049 Element element, String name, Namespace namespace) {
050
051 QName qName = SAXReaderUtil.createQName(name, namespace);
052
053 return element.addElement(qName);
054 }
055
056 public static Element add(
057 Element element, String name, Namespace namespace, boolean text) {
058
059 return add(element, name, namespace, String.valueOf(text));
060 }
061
062 public static Element add(
063 Element element, String name, Namespace namespace, double text) {
064
065 return add(element, name, namespace, String.valueOf(text));
066 }
067
068 public static Element add(
069 Element element, String name, Namespace namespace, float text) {
070
071 return add(element, name, namespace, String.valueOf(text));
072 }
073
074 public static Element add(
075 Element element, String name, Namespace namespace, int text) {
076
077 return add(element, name, namespace, String.valueOf(text));
078 }
079
080 public static Element add(
081 Element element, String name, Namespace namespace, long text) {
082
083 return add(element, name, namespace, String.valueOf(text));
084 }
085
086 public static Element add(
087 Element element, String name, Namespace namespace, Object text) {
088
089 return add(element, name, namespace, String.valueOf(text));
090 }
091
092 public static Element add(
093 Element element, String name, Namespace namespace, short text) {
094
095 return add(element, name, namespace, String.valueOf(text));
096 }
097
098 public static Element add(
099 Element element, String name, Namespace namespace, String text) {
100
101 QName qName = SAXReaderUtil.createQName(name, namespace);
102
103 Element childElement = element.addElement(qName);
104
105 childElement.addText(GetterUtil.getString(text));
106
107 return childElement;
108 }
109
110 public static Element add(Element element, String name, Object text) {
111 return add(element, name, String.valueOf(text));
112 }
113
114 public static Element add(Element element, String name, short text) {
115 return add(element, name, String.valueOf(text));
116 }
117
118 public static Element add(Element element, String name, String text) {
119 Element childElement = element.addElement(name);
120
121 childElement.addText(GetterUtil.getString(text));
122
123 return childElement;
124 }
125
126 }