Java XML Attribute Get getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute, double[] defaultValue)

Here you can find the source of getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute, double[] defaultValue)

Description

get Double Array Tag Attribute

License

Open Source License

Declaration

public static double[] getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute,
            double[] defaultValue) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Weasis Team and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from w  ww .  ja v a2s . c o m
 *     Nicolas Roduit - initial API and implementation
 *******************************************************************************/

import javax.xml.stream.XMLStreamReader;

public class Main {
    public static double[] getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute,
            double[] defaultValue) {
        return getDoubleArrayTagAttribute(xmler, attribute, defaultValue, "\\"); //$NON-NLS-1$
    }

    public static double[] getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute,
            double[] defaultValue, String separator) {
        if (attribute != null) {
            String val = xmler.getAttributeValue(null, attribute);
            if (val != null) {
                String[] strs = val.split(separator);
                double[] vals = new double[strs.length];
                for (int i = 0; i < strs.length; i++) {
                    vals[i] = Double.parseDouble(strs[0]);
                }
                return vals;
            }
        }
        return defaultValue;
    }
}

Related

  1. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  2. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  3. getCurrentLevelAttributeTextValue(Element ele, String attribute)
  4. getDirectAttribute(Node node, String name)
  5. getDivHeadAttr(Element annotU, String attrName)
  6. getDoubleAttribute(Element element, String name)
  7. getDoubleAttribute(Node n, String s)
  8. getDoubleAttribute(String name, Element el)
  9. getDoubleAttributeValue(Element element, String attribute)