001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.util.xml;
022:
023: import com.liferay.portal.kernel.util.GetterUtil;
024:
025: import org.dom4j.Element;
026: import org.dom4j.Namespace;
027: import org.dom4j.QName;
028:
029: /**
030: * <a href="DocUtil.java.html"><b><i>View Source</i></b></a>
031: *
032: * @author Brian Wing Shun Chan
033: *
034: */
035: public class DocUtil {
036:
037: public static void add(Element el, String name, boolean text) {
038: add(el, name, String.valueOf(text));
039: }
040:
041: public static void add(Element el, String name, double text) {
042: add(el, name, String.valueOf(text));
043: }
044:
045: public static void add(Element el, String name, float text) {
046: add(el, name, String.valueOf(text));
047: }
048:
049: public static void add(Element el, String name, int text) {
050: add(el, name, String.valueOf(text));
051: }
052:
053: public static void add(Element el, String name, long text) {
054: add(el, name, String.valueOf(text));
055: }
056:
057: public static void add(Element el, String name, short text) {
058: add(el, name, String.valueOf(text));
059: }
060:
061: public static void add(Element el, String name, Object text) {
062: add(el, name, String.valueOf(text));
063: }
064:
065: public static void add(Element el, String name, String text) {
066: el.addElement(name).addText(GetterUtil.getString(text));
067: }
068:
069: public static Element add(Element el, String name, Namespace ns) {
070: return el.addElement(new QName(name, ns));
071: }
072:
073: public static void add(Element el, String name, Namespace ns,
074: boolean text) {
075:
076: add(el, name, ns, String.valueOf(text));
077: }
078:
079: public static void add(Element el, String name, Namespace ns,
080: double text) {
081: add(el, name, ns, String.valueOf(text));
082: }
083:
084: public static void add(Element el, String name, Namespace ns,
085: float text) {
086: add(el, name, ns, String.valueOf(text));
087: }
088:
089: public static void add(Element el, String name, Namespace ns,
090: int text) {
091: add(el, name, ns, String.valueOf(text));
092: }
093:
094: public static void add(Element el, String name, Namespace ns,
095: long text) {
096: add(el, name, ns, String.valueOf(text));
097: }
098:
099: public static void add(Element el, String name, Namespace ns,
100: short text) {
101: add(el, name, ns, String.valueOf(text));
102: }
103:
104: public static void add(Element el, String name, Namespace ns,
105: Object text) {
106: add(el, name, ns, String.valueOf(text));
107: }
108:
109: public static void add(Element el, String name, Namespace ns,
110: String text) {
111: el.addElement(new QName(name, ns)).addText(
112: GetterUtil.getString(text));
113: }
114:
115: }
|