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:com.springcryptoutils.core.spring.signature.SignerBeanDefinitionParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addPropertyReference("privateKey", element.getAttribute("privateKey-ref"));
    bean.addPropertyValue("algorithm", element.getAttribute("algorithm"));
    bean.addPropertyValue("provider", element.getAttribute("provider"));
}

From source file:com.springcryptoutils.core.spring.signature.Base64EncodedVerifierBeanDefinitionParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addPropertyReference("publicKey", element.getAttribute("publicKey-ref"));
    bean.addPropertyValue("algorithm", element.getAttribute("algorithm"));
    bean.addPropertyValue("charsetName", element.getAttribute("charset"));
    bean.addPropertyValue("provider", element.getAttribute("provider"));
}

From source file:org.qi4j.library.spring.bootstrap.internal.service.Qi4jServiceBeanDefinitionParser.java

public final BeanDefinition parse(Element anElement, ParserContext aParserContext) {
    String serviceId = anElement.getAttribute(SERVICE_ID);

    // Service factory bean
    BeanDefinitionBuilder builder = rootBeanDefinition(ServiceFactoryBean.class);
    builder.addConstructorArgReference(BEAN_ID_QI4J_APPLICATION);
    builder.addConstructorArgValue(serviceId);
    AbstractBeanDefinition definition = builder.getBeanDefinition();

    // Register service factory bean
    BeanDefinitionRegistry definitionRegistry = aParserContext.getRegistry();
    definitionRegistry.registerBeanDefinition(serviceId, definition);

    return definition;
}

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

protected AbstractValidationRule createValidationRule(Element element) {

    String minText = element.getAttribute(MIN_ATTR);
    String maxText = element.getAttribute(MAX_ATTR);

    Integer min = (StringUtils.hasText(minText)) ? new Integer(minText) : null;
    Integer max = (StringUtils.hasText(maxText)) ? new Integer(maxText) : null;

    if (min != null && max != null) {
        return new LengthValidationRule(min.intValue(), max.intValue());
    }/*from  w w  w . ja  v a 2s.  co m*/

    if (min != null) {
        return new MinLengthValidationRule(min.intValue());
    }

    if (max != null) {
        return new MaxLengthValidationRule(max.intValue());
    }

    throw new ValidationConfigurationException(
            "Element '" + ELEMENT_NAME + "' must have either 'min' attribute, 'max' attribute, or both");
}

From source file:pl.chilldev.web.spring.config.AbstractMetaBeanDefinitionParser.java

/**
 * {@inheritDoc}//ww  w  .  ja va 2s . c  o m
 * @since 0.0.1
 */
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    String key = element.getAttribute(AbstractMetaBeanDefinitionParser.ATTRIBUTE_KEY);
    String value = DomUtils.getTextValue(element);

    this.logger.info("Adding \"{}\" with value \"{}\" as meta \"{}\".", key, value, element.getLocalName());
    this.meta.put(key, value);

    return null;
}

From source file:com.bstek.dorado.data.config.xml.PreloadDataTypeParser.java

@Override
protected Object doParse(Node node, ParseContext context) throws Exception {
    DataParseContext dataContext = (DataParseContext) context;
    Element element = ((Element) node);

    String name = element.getAttribute(XmlConstants.ATTRIBUTE_NAME);
    if (StringUtils.isEmpty(name)) {
        throw new XmlParseException("[" + XmlConstants.ATTRIBUTE_NAME + "] attribute can not be empty", element,
                context);/*from   w  w w  .ja v  a  2  s  .  co m*/
    }

    Map<String, NodeWrapper> configuredDataTypes = dataContext.getConfiguredDataTypes();
    if (configuredDataTypes.containsKey(name)) {
        boolean overwrite = BooleanUtils.toBoolean(element.getAttribute(DataXmlConstants.ATTRIBUTE_OVERWRITE));
        if (!overwrite) {
            throw new XmlParseException(DataXmlConstants.DATA_TYPE + " [" + name + "] is not unique!", element,
                    context);
        }
    }

    configuredDataTypes.put(name, new NodeWrapper(node, context.getResource()));
    return null;
}

From source file:com.springcryptoutils.core.spring.signature.VerifierWithChooserByPublicKeyIdBeanDefinitionParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addPropertyReference("publicKeyMap", element.getAttribute("publicKeyMap-ref"));
    bean.addPropertyValue("algorithm", element.getAttribute("algorithm"));
    bean.addPropertyValue("provider", element.getAttribute("provider"));
}

From source file:nz.co.senanque.madura.bundle.spring.BeanBeanDefinitionParser.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {
    String bundleManager = element.getAttribute("bundleManager");
    if (!StringUtils.hasText(bundleManager))
        bundleManager = "bundleManager";
    bean.addPropertyReference("bundleManager", bundleManager);

    String interfaceName = element.getAttribute("interface");
    if (StringUtils.hasText(interfaceName)) {
        bean.addPropertyValue("interface", interfaceName);
    }//  w  ww  .j av a 2 s. c o m
}

From source file:org.xacml4j.spring.repository.InMemoryPolicyRepositoryDefinitionParser.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addConstructorArgValue(element.getAttribute("id"));
    bean.addPropertyReference("policies", element.getAttribute("policies"));
    if (StringUtils.hasText(element.getAttribute("extensionFunctions"))) {
        bean.addPropertyReference("extensionFunctions", element.getAttribute("extensionFunctions"));
    }/*from  w  ww.j a  v a2 s .  c  om*/
    if (StringUtils.hasText(element.getAttribute("extensionCombiningAlgorithms"))) {
        bean.addPropertyReference("extensionCombiningAlgorithms",
                element.getAttribute("extensionCombiningAlgorithms"));
    }
}

From source file:com.bstek.dorado.data.config.xml.PreloadDataResolverParser.java

@Override
protected Object doParse(Node node, ParseContext context) throws Exception {
    DataParseContext dataContext = (DataParseContext) context;
    Element element = ((Element) node);

    String name = element.getAttribute(XmlConstants.ATTRIBUTE_NAME);
    if (StringUtils.isEmpty(name)) {
        throw new XmlParseException("[" + XmlConstants.ATTRIBUTE_NAME + "] attribute of ["
                + DataXmlConstants.DATA_RESOLVER + "] can not be empty - [" + dataContext.getResource() + "]",
                element, context);/*from  www  .  j  a  v a 2 s .  c o m*/
    }

    Map<String, NodeWrapper> configuredDataResolvers = dataContext.getConfiguredDataResolvers();
    if (configuredDataResolvers.containsKey(name)) {
        boolean overwrite = BooleanUtils.toBoolean(element.getAttribute(DataXmlConstants.ATTRIBUTE_OVERWRITE));
        if (!overwrite) {
            throw new XmlParseException(DataXmlConstants.DATA_RESOLVER + " [" + name + "] is not unique!",
                    element, context);
        }
    }

    configuredDataResolvers.put(name, new NodeWrapper(node, context.getResource()));
    return null;
}