Java XML Attribute Parse parseFloat(Node xmlAttribute, float invalidValue)

Here you can find the source of parseFloat(Node xmlAttribute, float invalidValue)

Description

parse Float

License

Apache License

Declaration

public static float parseFloat(Node xmlAttribute, float invalidValue) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.*;

public class Main {
    public static float parseFloat(Node xmlAttribute, float invalidValue) {
        if (xmlAttribute == null)
            return invalidValue;
        return parseFloat(xmlAttribute.getNodeValue(), invalidValue);
    }//w  w w.  j  av a  2  s .  c o m

    public static float parseFloat(String xmlAttributeValue,
            float invalidValue) {
        if (xmlAttributeValue == null)
            return invalidValue;

        try {
            return Double.valueOf(xmlAttributeValue).floatValue();
        } catch (NumberFormatException ex) {
            return invalidValue;
        }
    }
}

Related

  1. mapRequiredBeanRefAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, String... attrs)
  2. parseAttributeValuePairTags(Node parentNode)
  3. parseBoolean(String xmlAttributeValue, Boolean invalidValue)
  4. parseConfigAttr(NamedNodeMap attributes)
  5. parseElementAttributes(Element element)
  6. parseFloat(String attributeName, NamedNodeMap map)
  7. parseProtoypes(Node module, Node iFace, PrintWriter out, boolean onlyAttributes)
  8. parseString(final Element parent, final String attrName)
  9. parseString(String xmlAttributeValue, String invalidValue)