Java XML Node Parse parseOptionNode(Node node)

Here you can find the source of parseOptionNode(Node node)

Description

parse Option Node

License

Open Source License

Declaration

public static Node parseOptionNode(Node node) 

Method Source Code

//package com.java2s;

import java.util.Objects;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static Node parseOptionNode(Node node) {
        Objects.requireNonNull(node);

        if (!(node instanceof Element)
                || !node.getNodeName().equalsIgnoreCase("option")) {
            throw new IllegalArgumentException("Node is not option: "
                    + node);//  w w  w.ja v a2 s. co m
        }

        Element e = (Element) node;
        if (e.hasAttribute("val")) {
            String val = e.getAttribute("val");
            if (val.equalsIgnoreCase("some")) {
                if (!e.hasChildNodes()) {
                    throw new IllegalArgumentException(
                            "Doesn't have children: " + e);
                }
                return e.getFirstChild();
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}

Related

  1. parseDictionary(final Node dictionary)
  2. parseInt(Node node)
  3. parseIntervals(Node intervals)
  4. parseList(Node node)
  5. parseModule(Node module, PrintWriter out)
  6. parseOptionString(Node node)
  7. parsePairFirst(Node node)
  8. parseProperties(Node doc)
  9. parseProtoypes(Node module, Node iFace, PrintWriter out)