Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Helium - a set of useful stuff for java.
 * 
 * Helium is free software: you can redistribute it and/or modify
 * it under the terms of the New BSD license as published by
 * Invenzzia Group.
 *
 * Helium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the new BSD license
 * along with Helium. If not, see <http://invenzzia.org/license/new-bsd>.
 */

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Main {
    /**
     * A helper method for quick property saving/modification. If the property element does not exist, it is automatically created.
     *
     * @param element The parent element.
     * @param name The property name.
     * @param value The property value
     * @return
     */
    public static void quickPropertyWrite(Element element, String name, String value) {
        NodeList nodeList = element.getElementsByTagName(name);
        if (nodeList.getLength() == 1) {
            nodeList.item(0).setTextContent(value);
        } else {
            Element newProp = element.getOwnerDocument().createElement(name);
            newProp.setTextContent(value);
            element.appendChild(newProp);
        }
    }
}