Java XML Attribute Parse parseBoolean(String xmlAttributeValue, Boolean invalidValue)

Here you can find the source of parseBoolean(String xmlAttributeValue, Boolean invalidValue)

Description

parse Boolean

License

Apache License

Declaration

public static Boolean parseBoolean(String xmlAttributeValue,
            Boolean invalidValue) 

Method Source Code

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

import org.w3c.dom.*;

public class Main {
    public static Boolean parseBoolean(String xmlAttributeValue,
            Boolean invalidValue) {
        if (xmlAttributeValue == null)
            return invalidValue;

        if (xmlAttributeValue.equals(Boolean.TRUE.toString())) {
            return Boolean.TRUE;
        } else if (xmlAttributeValue.equals(Boolean.FALSE.toString())) {
            return Boolean.FALSE;
        } else {//ww  w .  j a  v  a2s. c o m
            return invalidValue;
        }
    }

    public static Boolean parseBoolean(Node xmlAttribute,
            boolean invalidValue) {
        if (xmlAttribute == null)
            return invalidValue ? Boolean.TRUE : Boolean.FALSE;
        return parseBoolean(xmlAttribute.getNodeValue(), invalidValue);
    }

    public static Boolean parseBoolean(Node xmlAttribute,
            Boolean invalidValue) {
        if (xmlAttribute == null)
            return invalidValue;
        return parseBoolean(xmlAttribute.getNodeValue(), invalidValue);
    }

    public static Boolean parseBoolean(String xmlAttributeValue,
            boolean invalidValue) {
        return parseBoolean(xmlAttributeValue, invalidValue ? Boolean.TRUE
                : Boolean.FALSE);
    }
}

Related

  1. mapOptionalBeanRefAttributes(Element element, BeanDefinitionBuilder builder, ParserContext parserContext, String... attrs)
  2. mapRequiredBeanRefAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, String... attrs)
  3. parseAttributeValuePairTags(Node parentNode)
  4. parseConfigAttr(NamedNodeMap attributes)
  5. parseElementAttributes(Element element)
  6. parseFloat(Node xmlAttribute, float invalidValue)
  7. parseFloat(String attributeName, NamedNodeMap map)