Example usage for org.dom4j Element addAttribute

List of usage examples for org.dom4j Element addAttribute

Introduction

In this page you can find the example usage for org.dom4j Element addAttribute.

Prototype

Element addAttribute(QName qName, String value);

Source Link

Document

Adds the attribute value of the given fully qualified name.

Usage

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getModuleElement(ModuleDescriptor md) {
    Element module = DocumentHelper.createElement("module");

    module.addAttribute("id", md.getModuleId());
    module.addAttribute("version", md.getVersion());
    module.addAttribute("package", md.getPackageName());

    if (md.getAnnotation() != null) {
        module.addText(md.getAnnotation());
    }/*from   w  w  w  .  j a v a2 s  .  com*/

    addDependencies(module);

    addServicePoints(module);

    addConfigurationPoints(module);

    addContributions(module);

    addImplementations(module);

    addSchemas(module);

    addSubModules(module);

    return module;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getDependencyElement(DependencyDescriptor dd) {

    Element dependency = DocumentHelper.createElement("dependency");

    dependency.addAttribute("module-id", dd.getModuleId());
    dependency.addAttribute("version", dd.getVersion());

    return dependency;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getServicePointElement(ServicePointDescriptor spd) {
    Element servicePoint = DocumentHelper.createElement("service-point");

    servicePoint.addAttribute("id", qualify(spd.getId()));
    servicePoint.addAttribute("interface", spd.getInterfaceClassName());
    if (spd.getVisibility() == Visibility.PRIVATE)
        servicePoint.addAttribute("visibility", "private");
    if (spd.getParametersCount() != Occurances.REQUIRED)
        servicePoint.addAttribute("parameters-occurs", spd.getParametersCount().getName().toLowerCase());

    if (spd.getAnnotation() != null) {
        servicePoint.addText(spd.getAnnotation());
    }//from   ww w .  ja v a  2 s. c o m

    if (spd.getParametersSchema() != null)
        addSchema(servicePoint, (SchemaImpl) spd.getParametersSchema(), "parameters-schema");
    else if (spd.getParametersSchemaId() != null)
        servicePoint.addAttribute("parameters-schema-id", qualify(spd.getParametersSchemaId()));

    InstanceBuilder ib = spd.getInstanceBuilder();

    if (ib != null) {
        Element instanceBuilder = getInstanceBuilderElement(ib);

        servicePoint.add(instanceBuilder);
    }

    List interceptors = spd.getInterceptors();

    if (interceptors != null) {
        for (Iterator i = interceptors.iterator(); i.hasNext();) {
            InterceptorDescriptor icd = (InterceptorDescriptor) i.next();

            Element interceptor = getInterceptorElement(icd);

            servicePoint.add(interceptor);
        }
    }

    return servicePoint;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getConfigurationPointElement(ConfigurationPointDescriptor cpd) {
    Element configurationPoint = DocumentHelper.createElement("configuration-point");

    configurationPoint.addAttribute("id", qualify(cpd.getId()));
    if (cpd.getVisibility() == Visibility.PRIVATE)
        configurationPoint.addAttribute("visibility", "private");

    if (cpd.getAnnotation() != null) {
        configurationPoint.addText(cpd.getAnnotation());
    }/*w  w  w .  j  av a 2  s  .  c o m*/
    if (cpd.getContributionsSchema() != null)
        addSchema(configurationPoint, (SchemaImpl) cpd.getContributionsSchema(), "schema");
    else if (cpd.getContributionsSchemaId() != null)
        configurationPoint.addAttribute("schema-id", qualify(cpd.getContributionsSchemaId()));

    return configurationPoint;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getContributionElement(ContributionDescriptor cd) {
    Element contribution = DocumentHelper.createElement("contribution");

    contribution.addAttribute("configuration-id", qualify(cd.getConfigurationId()));

    if (cd.getConditionalExpression() != null)
        contribution.addAttribute("if", cd.getConditionalExpression());

    List parameters = cd.getElements();

    if (parameters != null) {
        for (Iterator i = parameters.iterator(); i.hasNext();) {
            org.apache.hivemind.Element parameter = (org.apache.hivemind.Element) i.next();

            Element element = getParamterElement(parameter);

            contribution.add(element);/*from   w  ww  . j  av a 2  s  .com*/
        }
    }

    if (cd.getAnnotation() != null) {
        contribution.addText(cd.getAnnotation());
    }

    return contribution;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getImplementationElement(ImplementationDescriptor id) {
    Element implementation = DocumentHelper.createElement("implementation");

    implementation.addAttribute("service-id", qualify(id.getServiceId()));

    if (id.getConditionalExpression() != null)
        implementation.addAttribute("if", id.getConditionalExpression());

    if (id.getAnnotation() != null) {
        implementation.addText(id.getAnnotation());
    }//w w  w.  ja v a2s  . c o m

    InstanceBuilder ib = id.getInstanceBuilder();

    if (ib != null) {
        Element instanceBuilder = getInstanceBuilderElement(ib);

        implementation.add(instanceBuilder);
    }

    List interceptors = id.getInterceptors();

    if (interceptors != null) {
        for (Iterator i = interceptors.iterator(); i.hasNext();) {
            InterceptorDescriptor icd = (InterceptorDescriptor) i.next();

            Element interceptor = getInterceptorElement(icd);

            implementation.add(interceptor);
        }
    }

    return implementation;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getSubModuleElement(SubModuleDescriptor smd) {
    Element subModule = DocumentHelper.createElement("sub-module");

    subModule.addAttribute("descriptor", smd.getDescriptor().getPath());

    return subModule;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getInstanceBuilderElement(InstanceBuilder ib) {
    Element instanceBuilder;

    if (ib instanceof CreateInstanceDescriptor) {
        CreateInstanceDescriptor cid = (CreateInstanceDescriptor) ib;
        instanceBuilder = DocumentHelper.createElement("create-instance");

        instanceBuilder.addAttribute("class", cid.getInstanceClassName());
        if (!cid.getServiceModel().equals("singleton"))
            instanceBuilder.addAttribute("model", cid.getServiceModel());
    } else {//from  ww  w .  jav a2s . c o  m
        InvokeFactoryDescriptor ifd = (InvokeFactoryDescriptor) ib;
        instanceBuilder = DocumentHelper.createElement("invoke-factory");

        if (!ifd.getFactoryServiceId().equals("hivemind.BuilderFactory"))
            instanceBuilder.addAttribute("service-id", qualify(ifd.getFactoryServiceId()));
        if (ifd.getServiceModel() != null)
            instanceBuilder.addAttribute("model", ifd.getServiceModel());

        List parameters = ifd.getParameters();

        if (parameters != null) {
            for (Iterator i = parameters.iterator(); i.hasNext();) {
                org.apache.hivemind.Element parameter = (org.apache.hivemind.Element) i.next();

                Element element = getParamterElement(parameter);

                instanceBuilder.add(element);
            }
        }
    }

    return instanceBuilder;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getInterceptorElement(InterceptorDescriptor icd) {
    Element interceptor = DocumentHelper.createElement("interceptor");

    interceptor.addAttribute("service-id", qualify(icd.getFactoryServiceId()));
    if (icd.getBefore() != null)
        interceptor.addAttribute("before", icd.getBefore());
    if (icd.getAfter() != null)
        interceptor.addAttribute("after", icd.getAfter());
    return interceptor;
}

From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java

License:Apache License

private Element getParamterElement(org.apache.hivemind.Element parameter) {
    Element element = DocumentHelper.createElement(parameter.getElementName());

    List attributes = parameter.getAttributes();

    for (Iterator i = attributes.iterator(); i.hasNext();) {
        Attribute attribute = (Attribute) i.next();

        element.addAttribute(attribute.getName(), attribute.getValue());
    }/*from   w  w  w . j  a va 2s. co  m*/

    List elements = parameter.getElements();

    for (Iterator i = elements.iterator(); i.hasNext();) {
        org.apache.hivemind.Element nestedParameter = (org.apache.hivemind.Element) i.next();

        element.add(getParamterElement(nestedParameter));
    }

    return element;
}