Java XML Node Parse parseIntervals(Node intervals)

Here you can find the source of parseIntervals(Node intervals)

Description

parse Intervals

License

Open Source License

Declaration

private static Integer[] parseIntervals(Node intervals) 

Method Source Code

//package com.java2s;
/*//from   w  w  w  . ja v  a  2s.  c  o  m
 * $Id$
 *
 * Copyright 1998,1999,2000,2001 by Rockhopper Technologies, Inc.,
 * 75 Trueman Ave., Haddonfield, New Jersey, 08033-2529, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Rockhopper Technologies, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with RTI.
 */

import java.util.ArrayList;
import java.util.List;

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

public class Main {
    private static Integer[] parseIntervals(Node intervals) {
        NodeList sc = intervals.getChildNodes();
        int len = sc.getLength();
        int[] a = new int[len];
        List<Integer> list = new ArrayList<Integer>();

        for (int i = 0; i < len; i++) {
            Node nn = sc.item(i);
            if (nn.getNodeName().equalsIgnoreCase("interval")) {
                // System.out.println(nn.getTextContent());
                a[i] = Integer.parseInt(nn.getTextContent());
                list.add(Integer.parseInt(nn.getTextContent()));
            }
        }
        Integer[] array = new Integer[list.size()];
        return list.toArray(array);
    }
}

Related

  1. parseArray(final Node array)
  2. parseDictionary(final Node dictionary)
  3. parseInt(Node node)
  4. parseList(Node node)
  5. parseModule(Node module, PrintWriter out)
  6. parseOptionNode(Node node)
  7. parseOptionString(Node node)