Example usage for org.dom4j Element add

List of usage examples for org.dom4j Element add

Introduction

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

Prototype

void add(Namespace namespace);

Source Link

Document

Adds the given Namespace to this element.

Usage

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

License:Apache License

private void addConfigurationPoints(Element module) {
    List configurationPoints = _md.getConfigurationPoints();

    if (configurationPoints != null) {
        for (Iterator i = configurationPoints.iterator(); i.hasNext();) {
            ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor) i.next();

            Element configurationPoint = getConfigurationPointElement(cpd);

            module.add(configurationPoint);

            SchemaImpl s = (SchemaImpl) cpd.getContributionsSchema();

            if (s != null && s.getId() != null)
                addSchema(module, s, "schema");
        }/*from   w  w  w .j  a v  a2s  .c  o  m*/
    }
}

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

License:Apache License

private void addContributions(Element module) {
    List contributions = _md.getContributions();

    if (contributions != null) {
        for (Iterator i = contributions.iterator(); i.hasNext();) {
            ContributionDescriptor cd = (ContributionDescriptor) i.next();

            Element contribution = getContributionElement(cd);

            module.add(contribution);
        }/*  w ww. java  2  s.  com*/
    }
}

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

License:Apache License

private void addImplementations(Element module) {
    List implementations = _md.getImplementations();

    if (implementations != null) {
        for (Iterator i = implementations.iterator(); i.hasNext();) {
            ImplementationDescriptor id = (ImplementationDescriptor) i.next();

            Element implementation = getImplementationElement(id);

            module.add(implementation);
        }/*from w  ww . j  a va 2s.c  o  m*/
    }
}

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

License:Apache License

private void addSubModules(Element module) {
    List subModules = _md.getSubModules();

    if (subModules != null) {
        for (Iterator i = subModules.iterator(); i.hasNext();) {
            SubModuleDescriptor smd = (SubModuleDescriptor) i.next();

            Element subModule = getSubModuleElement(smd);

            module.add(subModule);
        }/*from  w ww .j av  a 2s . c  o  m*/
    }
}

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 w w  w .ja v  a  2 s.c om*/

    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 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  a va 2  s  . c  o  m
    }

    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());
    }/*from w  w  w.j  a va  2s  .  c  om*/

    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 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  w w  w.  j ava2s  .c om*/
        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 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 ww . ja va2  s.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;
}

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

License:Apache License

private void addSchema(Element container, SchemaImpl s, String elementName) {
    if (_processedSchemas.contains(s))
        return;/*from w  w w  .j av  a  2  s .  c  o m*/

    Element schema = DocumentHelper.createElement(elementName);

    if (s.getId() != null)
        schema.addAttribute("id", qualify(s.getId()));

    if (s.getVisibility() == Visibility.PRIVATE)
        schema.addAttribute("visibility", "private");

    if (s.getAnnotation() != null) {
        schema.addText(s.getAnnotation());
    }

    for (Iterator j = s.getElementModel().iterator(); j.hasNext();) {
        ElementModel em = (ElementModel) j.next();

        Element element = getElementElement(em);

        schema.add(element);
    }

    container.add(schema);

    _processedSchemas.add(s);
}