Java Utililty Methods XML Attribute Add

List of utility methods to do XML Attribute Add

Description

The list of methods to do XML Attribute Add are organized into topic(s).

Method

voidaddOptionalPropertyReference(BeanDefinitionBuilder builder, String propertyName, Attr attribute, String defaultValue)
Convenience method delegating to #addProperty(BeanDefinitionBuilder,String,String,String,boolean,boolean) .
addProperty(builder, propertyName, attribute.getValue(), defaultValue, false, true);
voidaddOrUpdateAttribute(Element element, String name, String value)
Update an attribute for an Element with the provided value.
NamedNodeMap measureAttrs = element.getAttributes();
Node attrNode = measureAttrs.getNamedItem(name);
if (attrNode != null) {
    attrNode.setNodeValue(value);
} else {
    element.setAttribute(name, value);
voidaddPropertyReferenceIfNeeded(BeanDefinitionBuilder bdb, Element element, String attributeName)
Add property reference to BeanDefinitionBuilder if needed, following the naming Conventions
if (element.hasAttribute(attributeName))
    bdb.addPropertyReference(Conventions.attributeNameToPropertyName(attributeName),
            element.getAttribute(attributeName));
voidaddRequiredPropertyValue(BeanDefinitionBuilder builder, String propertyName, Element element, String attributeName)
Convenience method delegating to #addProperty(BeanDefinitionBuilder,String,String,String,boolean,boolean) .
addProperty(builder, propertyName, element.getAttribute(attributeName), null, true, false);
ElementaddTextElement(Node parent, String name, String value, Attr[] attrs)
add Text Element
Element element;
if (parent instanceof Document) {
    element = ((Document) parent).createElement(name);
} else {
    element = parent.getOwnerDocument().createElement(name);
if (attrs != null && attrs.length > 0) {
    for (Attr attr : attrs) {
...
voidaddTypeAttribute(Element element, String type)
Adds a type attribute to an element as required by the RPC/Encoded binding.
if (type != null) {
    element.setAttribute("xsi:type", type);
doublereadDoubleAttr(Element element, String attributeName, double defaultValue)
read Double Attr
String attributeValue = element.getAttribute(attributeName);
try {
    return Double.parseDouble(attributeValue);
} catch (NumberFormatException e) {
    return defaultValue;