Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    /**
     * Append text value node.
     *
     * @param baseNode
     *            the base node
     * @param tagName
     *            the tag name
     * @param tagValue
     *            the tag value
     * @return the element
     */
    public static Element appendTextValueNode(Node baseNode, String tagName, int tagValue) {
        return appendTextValueNode(baseNode, tagName, Integer.toString(tagValue));
    }

    /**
     * Append text value node.
     *
     * @param baseNode
     *            the base node
     * @param tagName
     *            the tag name
     * @param tagValue
     *            the tag value
     * @return the element
     */
    public static Element appendTextValueNode(Node baseNode, String tagName, double tagValue) {
        return appendTextValueNode(baseNode, tagName, Double.toString(tagValue));
    }

    /**
     * Append text value node.
     *
     * @param baseNode
     *            the base node
     * @param tagName
     *            the tag name
     * @param tagValue
     *            the tag value
     * @return the element
     */
    public static Element appendTextValueNode(Node baseNode, String tagName, String tagValue) {
        Element newNode = appendNode(baseNode, tagName);
        if (tagValue == null) {
            newNode.appendChild(baseNode.getOwnerDocument().createTextNode("<null>"));
        } else {
            newNode.appendChild(baseNode.getOwnerDocument().createTextNode(tagValue));
        }
        return newNode;
    }

    /**
     * Append node.
     *
     * @param baseNode
     *            the base node
     * @param tagName
     *            the tag name
     * @return the element
     */
    public static Element appendNode(Node baseNode, String tagName) {
        Element newNode = baseNode.getOwnerDocument().createElement(tagName);
        baseNode.appendChild(newNode);
        return newNode;
    }
}