Example usage for org.jdom2 Element Element

List of usage examples for org.jdom2 Element Element

Introduction

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

Prototype

public Element(final String name) 

Source Link

Document

Create a new element with the supplied (local) name and no namespace.

Usage

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

License:Apache License

/**
 * ? ?  ?// www  . j ava2  s. c om
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setDeployApplicationText(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    String fileName = upload.getDeploySrc().getFileItem().getName().replaceAll("\\\\", "/");
    fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
    childs.add(new Element("text")
            .setText(MessageUtil.getMessage("pdf.message.deploy_application.info.text", fileName)));
    return childs;

}

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

License:Apache License

/**
 * lib   ?//  w ww  .j  ava 2s. c  om
 * (type : D - ? lib  )
 * 
 * @param data
 * @param upload
 * @param type
 * @return
 */
public static List<Element> setLibData(AnalyzeDefinition data, Upload upload, String type) {

    List<Element> childs = new ArrayList<Element>();
    List<String> dataList;
    if (type.equals("D"))
        dataList = data.getDeleteLibraryList();
    else
        dataList = data.getLibraryList();

    if (dataList.size() > 0) {
        Element child = new Element("table");
        Element childE1 = new Element("header");
        Element childE2 = new Element("row");

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

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

        for (String text : dataList) {
            childE2.addContent(new Element("col").setText(text));
        }
        child.addContent(childE1);
        child.addContent(childE2);

        childs.add(child);
    }

    return childs;
}

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

License:Apache License

/**
 * classes   ?/*from   w w w .  ja  va 2 s . c o  m*/
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setClassData(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    List<ClassAnalyze> dataList = data.getClassesConstList();

    if (dataList.size() > 0) {

        Element child, childE1, childE2, col, text;
        for (ClassAnalyze comm : dataList) {

            text = new Element("text");
            text.setText(
                    MessageUtil.getMessage("pdf.message.class_summary.label.class_name") + comm.getClassName());
            childs.add(text);

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

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

            col = new Element("col");
            col.setAttribute("width", "100");
            childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.subject")));

            col = new Element("col");
            col.setAttribute("width", "300");
            childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.contents")));

            childE2.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.supper_class")));
            childE2.addContent(new Element("col").setText(comm.getSuperClassesStr()));
            childE2.addContent(
                    new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.interfaces")));
            childE2.addContent(new Element("col").setText(comm.getInterfacesStr()));
            childE2.addContent(new Element("col")
                    .setText(MessageUtil.getMessage("pdf.message.table.header.class_modifier")));
            childE2.addContent(new Element("col").setText(comm.getClassModifier()));
            childE2.addContent(
                    new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.final_class")));
            childE2.addContent(new Element("col")
                    .setText(comm.isFinalClass() == null ? "" : String.valueOf(comm.isFinalClass())));
            childE2.addContent(
                    new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.fields")));
            childE2.addContent(new Element("col").setText(comm.getFiledListStr()));
            childE2.addContent(
                    new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.methods")));
            childE2.addContent(new Element("col").setText(comm.getMethodListStr()));

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

            childs.add(child);
        }
    }

    return childs;
}

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

License:Apache License

/**
 * ?? ? ? ? ?//from  w w  w .ja va 2s  .c om
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setApplicationListData(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    List<CommonAnalyze> dataList = data.getDescripterList();

    if (dataList.size() > 0) {
        Element child = new Element("table");
        Element childE1 = new Element("header");
        Element childE2 = new Element("row");

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

        Element col = new Element("col");
        col.setAttribute("width", "150");
        childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.file_name")));

        col = new Element("col");
        col.setAttribute("width", "300");
        childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.location")));

        for (CommonAnalyze comm : dataList) {
            childE2.addContent(new Element("col").setText(comm.getItem()));
            childE2.addContent(
                    new Element("col").setText(comm.getLocation() + File.separator + comm.getItem()));
        }
        child.addContent(childE1);
        child.addContent(childE2);

        childs.add(child);
    }

    return childs;
}

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

License:Apache License

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

    List<Element> childs = new ArrayList<Element>();
    List<CommonAnalyze> dataList = data.getDescripterList();

    if (dataList.size() > 0) {

        Element text;
        for (CommonAnalyze comm : dataList) {
            text = new Element("text");
            text.setText(comm.getItem());
            text.setAttribute("padding", "23");
            childs.add(text);
            childs.add(new Element("box").setText(comm.getContents() + "\n"));
        }

    }
    return childs;
}

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

License:Apache License

/**
 * ?? ?? EJB    ?//  w w w.  j  a  v a  2 s  . com
 * 
 * @param data
 * @param upload
 * @return
 */
public static List<Element> setEjbApplicationData(AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    Iterator iterator = data.getEjbApplicationMap().entrySet().iterator();

    while (iterator.hasNext()) {
        Entry entry = (Entry) iterator.next();

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

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

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

        col = new Element("col");
        col.setAttribute("width", "150");
        childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.contents")));

        col = new Element("col");
        col.setAttribute("width", "300");
        childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.type")));

        List<CommonAnalyze> dataList = (List<CommonAnalyze>) entry.getValue();
        for (CommonAnalyze comm : dataList) {
            childE2.addContent(new Element("col").setText(comm.getItem()));
            childE2.addContent(new Element("col").setText(comm.getContents()));
        }

        child.addContent(childE1);
        child.addContent(childE2);
        section.addContent(new Element("text").setText(MessageUtil
                .getMessage("pdf.message.ejb_application.info.text", String.valueOf(entry.getKey()))));
        section.addContent(child);
        childs.add(section);
    }

    return childs;
}

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

License:Apache License

/**
 * ??  Deployment Descriptor  ?//from w  w  w  .ja v  a  2  s. c om
 * (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.  jav  a 2  s .c o 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  ?//w w w .j a  v  a 2 s  .  c  om
 * 
 * @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

/**
 * ?  ? // w  w w  .j  a v a2s.c  o  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;
}