Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * JLib - Publicitas Java library.
 *
 * Copyright (c) 2005, 2006, 2007, 2008 Publicitas SA.
 * Licensed under LGPL (LGPL-LICENSE.txt) license.
 */

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    static public void SetNodeText(Node node, String value) {
        NodeList node_;
        Node x;
        int n, nnode;
        if (value == null)
            value = "";
        if (node.getNodeType() == Node.TEXT_NODE)
            node.setNodeValue(value);
        else {
            node_ = node.getChildNodes();
            nnode = node_.getLength();
            if (nnode == 0) {
                x = (Node) node.getOwnerDocument().createTextNode(value);
                node.appendChild(x);
            } else {
                for (n = 0; n < nnode; n++) {
                    x = (Node) node_.item(n);
                    if (x == null)
                        continue;
                    if (x.getNodeType() == Node.TEXT_NODE) {
                        x.setNodeValue(value);
                        break;
                    }
                }
            }
        }
    }
}