Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.NodeList;

public class Main {
    public static NodeList check1Most(NodeList node, String tag, boolean required) {
        if (node.getLength() == 0) {
            if (!required) {
                return null;
            }
            throw new RuntimeException("Tag " + tag + " is required in configuration file");
        } else if (node.getLength() > 1) {
            throw new RuntimeException("Only one tag " + tag + " is required in configuration file");
        }
        return node.item(0).getChildNodes();
    }
}