Example usage for org.w3c.dom Element getAttribute

List of usage examples for org.w3c.dom Element getAttribute

Introduction

In this page you can find the example usage for org.w3c.dom Element getAttribute.

Prototype

public String getAttribute(String name);

Source Link

Document

Retrieves an attribute value by name.

Usage

From source file:org.brekka.stillingar.spring.config.ConfigurationServiceBeanDefinitionParser.java

/**
 * @param naming/* w  w  w  .ja v a  2s. c  o  m*/
 * @param string
 * @param prefix
 * @return
 */
protected static String attribute(Element elem, String attributeName, String defaultValue) {
    String value;
    if (elem.hasAttribute(attributeName)) {
        value = elem.getAttribute(attributeName);
    } else {
        value = defaultValue;
    }
    return value;
}

From source file:com.clican.pluto.fsm.spring.parser.DefaultStateParser.java

@SuppressWarnings("unchecked")
@Override// w  w w  . j a  va 2  s.c  o  m
public Class<? extends IState> getStateClass(Element element) {
    String clazz = element.getAttribute("clazz");
    if (StringUtils.isNotEmpty(clazz)) {
        try {
            return (Class<? extends IState>) Class.forName(clazz);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    } else {
        return DefaultStateImpl.class;
    }
}

From source file:net.phoenix.thrift.xml.ServerBeanDefinitionParser.java

@Override
protected String getBeanClassName(Element element) {
    return element.getAttribute("class");
}

From source file:com.clican.pluto.fsm.spring.parser.TaskStateParser.java

@SuppressWarnings("unchecked")
@Override/*from  w  w  w. ja v  a  2  s . com*/
public Class<? extends IState> getStateClass(Element element) {
    String clazz = element.getAttribute("clazz");
    if (StringUtils.isNotEmpty(clazz)) {
        try {
            return (Class<? extends IState>) Class.forName(clazz);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    } else {
        return TaskStateImpl.class;
    }
}

From source file:com.griddynamics.banshun.xml.ImportBeanDefinitionParser.java

@Override
protected String getBeanClassName(Element element) {
    return element.getAttribute(INTERFACE_ATTR);
}

From source file:MyCounter.java

public void incr(org.apache.xalan.extensions.XSLProcessorContext context, org.w3c.dom.Element elem) {
    String name = elem.getAttribute("name");
    Integer cval = (Integer) counters.get(name);
    int nval = (cval == null) ? 0 : (cval.intValue() + 1);
    counters.put(name, new Integer(nval));
}

From source file:org.springmodules.validation.bean.conf.loader.xml.handler.ExpressionClassValidationElementHandler.java

protected AbstractValidationRule createValidationRule(Element element) {
    String expression = element.getAttribute(CONDITION_ATTR);
    if (!StringUtils.hasText(expression)) {
        throw new ValidationConfigurationException(
                "Element '" + ELEMENT_NAME + "' must have a '" + CONDITION_ATTR + "' attribute");
    }//from ww w . ja  v a 2 s .com
    return new ExpressionValidationRule(getConditionExpressionParser(), expression);
}

From source file:org.springmodules.validation.bean.conf.loader.xml.handler.RegExpRuleElementHandler.java

protected AbstractValidationRule createValidationRule(Element element) {
    String expression = element.getAttribute(EXPRESSION_ATTR);
    if (!StringUtils.hasText(expression)) {
        throw new ValidationConfigurationException(
                "Element '" + ELEMENT_NAME + "' must have an 'expression' attribute");
    }//from   ww w .j a v a  2 s  .c  o  m
    return new RegExpValidationRule(expression);
}

From source file:DomUtils.java

/**
 * Get attribute value, returning <code>null</code> if unset.
 * <p/>/*from  ww  w. ja  v a 2  s . c  o  m*/
 * Some DOM implementations return an empty string for an unset
 * attribute.
 * @param element The DOM element.
 * @param attributeName The attribute to get.
 * @param namespaceURI Namespace URI of the required attribute, or null
 * to perform a non-namespaced get.
 * @return The attribute value, or <code>null</code> if unset.
 */
public static String getAttributeValue(Element element, String attributeName, String namespaceURI) {

    String attributeValue;

    if (namespaceURI == null) {
        attributeValue = element.getAttribute(attributeName);
    } else {
        attributeValue = element.getAttributeNS(namespaceURI, attributeName);
    }

    if (attributeValue.length() == 0 && !element.hasAttribute(attributeName)) {
        return null;
    }

    return attributeValue;
}

From source file:com.dangdang.ddframe.rdb.sharding.spring.namespace.parser.MasterSlaveDataSourceBeanDefinitionParser.java

private String parseId(final Element element) {
    return element.getAttribute(ID_ATTRIBUTE);
}