Java XML Attribute Set attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue)

Here you can find the source of attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue)

Description

Sets an attribute on the specified element with the specified name if the specified value is different from the specified default value.

License

Open Source License

Parameter

Parameter Description
base the Element to set the attribute on
name the attribute name
value the value that attribute should be set to
defaultValue the default value of the attribute

Declaration

public static void attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue) 

Method Source Code

//package com.java2s;
/* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under
 * the Apache 2.0 License, see http://coconut.codehaus.org/license.
 *///from   ww  w.  j a v a 2s.c  om

import org.w3c.dom.Element;

public class Main {
    /**
     * Sets an attribute on the specified element with the specified name if the specified
     * value is different from the specified default value.
     *
     * @param base
     *            the Element to set the attribute on
     * @param name
     *            the attribute name
     * @param value
     *            the value that attribute should be set to
     * @param defaultValue
     *            the default value of the attribute
     */
    public static void attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue) {
        if (value != defaultValue) {
            base.setAttribute(name, Boolean.toString(value));
        }
    }
}

Related

  1. attr(Element element, String name)
  2. attrbiuteToMap( NamedNodeMap attributes)
  3. attribute(Element element, String attrName)
  4. attribute(Node node, String... attributes)
  5. attributeBooleanGet(Element e, String name, boolean defaultValue)
  6. attributeBoolValue(Element e, String attr)
  7. attributeFloat(Node node, String attributeName)
  8. attributeIntValue(Element e, String attr)
  9. attributeMap(Element element)