Example usage for org.jdom2 Element addContent

List of usage examples for org.jdom2 Element addContent

Introduction

In this page you can find the example usage for org.jdom2 Element addContent.

Prototype

@Override
public Element addContent(final Collection<? extends Content> newContent) 

Source Link

Document

Appends all children in the given collection to the end of the content list.

Usage

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * ??  Deployment Descriptor  ?/*  w  w w. ja  va 2  s . co  m*/
 * (type : application, web, ejb)
 * 
 * @param data
 * @param upload
 * @param type
 * @return
 */
public static List<Element> setTransXmlData(PDFMetadataDefinition data, Upload upload, String type) {

    List<Element> childs = new ArrayList<Element>();
    List<EjbRecommend> dataList = null;
    List<String> transFileList = null;
    if (type.equals("application")) {
        dataList = data.getApplicationRecommendList();
        transFileList = data.getAppTransFileList();
    } else if (type.equals("web")) {
        dataList = data.getWebRecommendList();
        transFileList = data.getWebTransFileList();
    } else if (type.equals("ejb")) {
        dataList = data.getEjbRecommendList();
        transFileList = data.getEjbTransFileList();
    }

    Element section;
    for (EjbRecommend comm : dataList) {

        section = new Element("section");
        if (comm.isTransFlag())
            section.setAttribute("title",
                    MessageUtil.getMessage("pdf.message.advice.title.trans_complete_file", comm.getItem()));
        else {
            section.setAttribute("title",
                    MessageUtil.getMessage("pdf.message.advice.title.trans_target_file", comm.getItem()));
            section.addContent(new Element("textR").setText(
                    MessageUtil.getMessage("pdf.message.advice.trans_target_file.text", comm.getItem())));
        }
        section.addContent(new Element("text").setText(comm.getLocation() + File.separator + comm.getItem()));
        section.addContent(new Element("box").setText(comm.getContents()));

        childs.add(section);
    }

    childs.add(new Element("text").setAttribute("padding", "23")
            .setText(MessageUtil.getMessage("pdf.message.table.header.trans_target_file_list")));

    if (transFileList.size() > 0) {

        Element child, childE1, childE2;
        child = new Element("table");
        childE1 = new Element("header");
        childE2 = new Element("row");

        child.setAttribute("size", "1");

        childE1.addContent(
                new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.file_name")));

        for (String s : transFileList) {
            childE2.addContent(new Element("col").setText(s));
        }
        child.addContent(childE1);
        child.addContent(childE2);
        childs.add(child);
    }

    return childs;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * ear  Applications /*from  ww w.j  a v  a2 s.co  m*/
 * (type : war - Web, jar - EJB)
 * 
 * @param rootData
 * @param upload
 * @param type
 * @return
 * @throws Exception
 */
public static List<Element> setChildDeployData(PDFMetadataDefinition rootData, Upload upload, String type)
        throws Exception {

    List<Element> childs = new ArrayList<Element>();
    List<Element> childs2;
    Iterator iterator = null;
    if (type.equals("war")) {
        iterator = rootData.getWarDefinitionMap().entrySet().iterator();
    } else if (type.equals("jar")) {
        iterator = rootData.getJarDefinitionMap().entrySet().iterator();
    }

    Element section;
    File childXml = null;
    while (iterator.hasNext()) {
        childs2 = new ArrayList<Element>();
        Entry entry = (Entry) iterator.next();
        AnalyzeDefinition data = (AnalyzeDefinition) entry.getValue();

        if (type.equals("war")) {
            childXml = new File(PDFDocGenerator.class.getResource("/xml/war_application.xml").getFile());
        } else if (type.equals("jar")) {
            childXml = new File(PDFDocGenerator.class.getResource("/xml/jar_application.xml").getFile());
        }

        org.jdom2.Document chapterDoc = new SAXBuilder().build(childXml);

        Element root = chapterDoc.getRootElement();

        section = new Element("section");
        section.setAttribute("title", String.valueOf(entry.getKey()));

        for (Element e : root.getChildren()) {
            childs2.add(e.clone());
        }

        for (Element e : childs2) {
            section.addContent(e);
        }
        setDynamicSection(section, data, upload);

        childs.add(section);
    }

    return childs;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * Maven Dependency  ?//from   w ww  . ja  v  a  2s .  co m
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setMavenDependencyList(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    Element child, childE1, childE2;

    if (data.getMavenProjectList().size() > 0) {

        Element section = new Element("section");
        section.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.title"));
        section.addContent(new Element("text")
                .setText(MessageUtil.getMessage("pdf.message.maven_dependency.text", upload.getProjectNm())));

        Element cSection = new Element("section");
        cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.pom.title"));

        cSection.addContent(new Element("box").setText(data.getMavenProjectList().get(0).getContents()));
        section.addContent(cSection);

        if (data.getMavenDependencyList().size() > 0) {
            cSection = new Element("section");
            cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.lib.title"));

            cSection.addContent(
                    new Element("text").setText(MessageUtil.getMessage("pdf.message.maven_dependency.lib.title")
                            + MessageUtil.getMessage("pdf.message.maven_dependency.lib.ather_text")));

            child = new Element("table");
            childE1 = new Element("header");
            childE2 = new Element("row");

            child.setAttribute("size", "3");
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_artifactId")));
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_groupId")));
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_version")));

            for (MavenDependency comm : data.getMavenDependencyList()) {
                childE2.addContent(new Element("col").setText(comm.getArtifactId()));
                childE2.addContent(new Element("col").setText(comm.getGroupId()));
                childE2.addContent(new Element("col").setText(comm.getVersion()));
            }

            child.addContent(childE1);
            child.addContent(childE2);

            cSection.addContent(child);
            section.addContent(cSection);
        }

        if (data.getModifiedMavenDependencyList().size() > 0) {
            cSection = new Element("section");
            cSection.setAttribute("title",
                    MessageUtil.getMessage("pdf.message.maven_dependency.trans_lib.title"));

            cSection.addContent(new Element("text")
                    .setText(MessageUtil.getMessage("pdf.message.maven_dependency.trans_lib.text")));

            child = new Element("table");
            childE1 = new Element("header");
            childE2 = new Element("row");

            child.setAttribute("size", "4");
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_artifactId")));
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_groupId")));
            childE1.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.trans_version")));
            childE1.addContent(
                    new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.trans_scope")));

            for (MavenDependency comm : data.getModifiedMavenDependencyList()) {
                childE2.addContent(new Element("col").setText(comm.getArtifactId()));
                childE2.addContent(new Element("col").setText(comm.getGroupId()));
                childE2.addContent(new Element("col").setText(comm.getVersion()));
                childE2.addContent(new Element("col").setText(comm.getScope()));
            }

            child.addContent(childE1);
            child.addContent(childE2);

            cSection.addContent(child);
            section.addContent(cSection);
        }

        if (data.getMavenProjectList().size() > 1) {
            cSection = new Element("section");
            cSection.setAttribute("title",
                    MessageUtil.getMessage("pdf.message.maven_dependency.trans_pom.title"));

            cSection.addContent(new Element("box").setText(data.getMavenProjectList().get(1).getContents()));
            section.addContent(cSection);
        }

        childs.add(section);
    }

    return childs;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * ?  ? //from w  w  w.  j a  v a2s  . co  m
 * 
 * @param rootData
 * @param upload
 * @param type
 * @return
 * @throws Exception
 */
public static List<Element> setConvertEncodingData(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();

    boolean viewFlag = false;
    for (Dependency dependency : data.getJavaDependencyList()) {

        Iterator iterator = dependency.getEncodingStrMap().entrySet().iterator();
        if (iterator.hasNext()) {
            viewFlag = true;
            break;
        }
    }

    if (viewFlag) {
        Element section = new Element("section").setAttribute("title", "?  ?");

        section.addContent(new Element("text").setText(
                "? ? ?  ? ?  ?? ?? ."));

        Element text;
        for (Dependency comm : data.getJavaDependencyList()) {

            Iterator iterator = comm.getEncodingStrMap().entrySet().iterator();
            if (iterator.hasNext()) {

                text = new Element("text");
                text.setText(comm.getFileName());
                text.setAttribute("padding", "23");
                section.addContent(text);

                Element box = new Element("box");
                StringBuffer buf = new StringBuffer();
                while (iterator.hasNext()) {
                    Entry entry = (Entry) iterator.next();
                    buf.append(entry.getKey() + " " + entry.getValue() + "\n");
                }
                box.setText(buf.toString() + "\n");

                section.addContent(box);
            }

        }

        childs.add(section);

    }

    return childs;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * ??  ?   ?//from  w ww .ja  v a 2  s.  c o  m
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setExceptionData(PDFMetadataDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();

    Element section;
    for (ExceptionInfo comm : data.getExceptionInfoList()) {
        section = new Element("section");
        section.setAttribute("title", comm.getLocation());

        if (comm.getComments() != null && comm.getComments().length() > 0)
            section.addContent(new Element("text").setText(comm.getComments()));

        section.addContent(new Element("box").setText(comm.getStackTrace()));

        childs.add(section);
    }

    return childs;
}

From source file:com.bc.ceres.nbmgen.NbmGenTool.java

License:Open Source License

private static void addPluginElement(Element pluginsElement, String groupId, String artifactId,
        Map<String, String> configuration, Namespace ns) {
    Element pluginElement = new Element("plugin", ns);
    Element groupIdElement = new Element("groupId", ns);
    groupIdElement.setText(groupId);//  w ww .java 2  s  .c  o  m
    pluginElement.addContent(groupIdElement);
    Element artifactIdElement = new Element("artifactId", ns);
    artifactIdElement.setText(artifactId);
    pluginElement.addContent(artifactIdElement);
    Element configurationElement = new Element("configuration", ns);
    for (Map.Entry<String, String> entry : configuration.entrySet()) {
        Element keyElement = new Element(entry.getKey(), ns);
        keyElement.setText(entry.getValue());
        configurationElement.addContent(keyElement);
    }
    pluginElement.addContent(configurationElement);
    pluginsElement.addContent(pluginElement);
}

From source file:com.bc.fiduceo.reader.airs.EosCoreMetaParser.java

License:Open Source License

private Element startGroup(Element parent, String line) {
    StringTokenizer stoke = new StringTokenizer(line, "=");
    String toke = stoke.nextToken();
    assert toke.equals("GROUP");
    String name = stoke.nextToken();
    Element group = new Element(name);
    parent.addContent(group);
    return group;
}

From source file:com.bc.fiduceo.reader.airs.EosCoreMetaParser.java

License:Open Source License

private Element startObject(Element parent, String line) {
    StringTokenizer stoke = new StringTokenizer(line, "=");
    String toke = stoke.nextToken();
    assert toke.equals("OBJECT");
    String name = stoke.nextToken();
    Element obj = new Element(name);
    parent.addContent(obj);
    return obj;/*w  w w .ja  v  a 2  s.com*/
}

From source file:com.bc.fiduceo.reader.airs.EosCoreMetaParser.java

License:Open Source License

private void addField(Element parent, String line) {
    StringTokenizer stoke = new StringTokenizer(line, "=");
    String name = stoke.nextToken();
    if (stoke.hasMoreTokens()) {
        Element field = new Element(name);
        parent.addContent(field);
        String value = stoke.nextToken();
        if (value.startsWith("(")) {
            this.parseValueCollection(field, value);
            return;
        }//from  w  w w . ja  v a 2 s .c o  m
        value = this.stripQuotes(value);
        field.addContent(value);
    }
}

From source file:com.bc.fiduceo.reader.airs.EosCoreMetaParser.java

License:Open Source License

private void parseValueCollection(Element field, String value) {
    if (value.startsWith("(")) {
        value = value.substring(1);/*from   w w  w .  j a  v  a 2  s  . c  om*/
    }

    if (value.endsWith(")")) {
        value = value.substring(0, value.length() - 1);
    }

    StringTokenizer stoke = new StringTokenizer(value, "\",");

    while (stoke.hasMoreTokens()) {
        field.addContent((new Element("value")).addContent(this.stripQuotes(stoke.nextToken())));
    }

}