Java XML Attribute Set setPropertyIfAttributePresent( BeanDefinitionBuilder builder, Element element, String attributeName)

Here you can find the source of setPropertyIfAttributePresent( BeanDefinitionBuilder builder, Element element, String attributeName)

Description

set Property If Attribute Present

License

Apache License

Declaration

public static void setPropertyIfAttributePresent(
            BeanDefinitionBuilder builder, Element element,
            String attributeName) 

Method Source Code

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

import org.springframework.beans.factory.config.TypedStringValue;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;

import org.springframework.core.Conventions;
import org.springframework.util.StringUtils;

import org.w3c.dom.Element;

public class Main {
    public static void setPropertyIfAttributePresent(
            BeanDefinitionBuilder builder, Element element,
            String attributeName) {
        String attributeValue = element.getAttribute(attributeName);
        if (StringUtils.hasText(attributeValue)) {
            builder.addPropertyValue(/*from ww  w  .j  a  va 2 s  . c  o m*/
                    Conventions.attributeNameToPropertyName(attributeName),
                    new TypedStringValue(attributeValue));
        }
    }
}

Related

  1. setAttributeValue(Element element, String attribute, String value)
  2. setAttributeValue(final Element target, final String attributeName, final String value)
  3. setAttributeValue(Node node, String attName, String attValue)
  4. setAttributeValue(Node node, String attribute, String value)
  5. setAttributeValue(Node sNode, String attribName, String val)
  6. setPropertyReference(BeanDefinitionBuilder builder, Element element, String attribute, String property)