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

/**
 * ? ??  Data setting (data class : PDFMetadataDefinition)
 * /* ww w.j  a va 2s. c  o m*/
 * @param root
 * @param rootData
 * @param upload
 * @throws Exception
 */
public static void setDynamicSection(Element root, PDFMetadataDefinition rootData, Upload upload)
        throws Exception {

    List<Element> childs = new ArrayList<Element>();
    AnalyzeDefinition data = rootData.getEarDefinition();

    setDynamicSection(root, data, upload);

    for (Element e : root.getChildren()) {

        if (e.getName().equals("section")) {
            if (e.getChild("war_child_deploy") != null) {
                //ear  Web Applications 
                childs = setChildDeployData(rootData, upload, "war");
            } else if (e.getChild("jar_child_deploy") != null) {
                //ear  EJB Applications 
                childs = setChildDeployData(rootData, upload, "jar");
            } else if (e.getChild("trans_application_xml_info") != null) {
                //??  - application Deployment Descriptor 
                childs = setTransXmlData(rootData, upload, "application");
            } else if (e.getChild("trans_web_xml_info") != null) {
                //??  - Web Deployment Descriptor 
                childs = setTransXmlData(rootData, upload, "web");
            } else if (e.getChild("trans_ejb_xml_info") != null) {
                //??  - EJB Deployment Descriptor 
                childs = setTransXmlData(rootData, upload, "ejb");
            }
        }

        for (Element child : childs) {
            e.addContent(child);
        }
        childs = new ArrayList<Element>();
    }

    //??  ?   start(chapter ? ?? section? ?  )
    for (Element e : root.getChildren()) {
        if (e.getName().equals("exception_info")) {
            childs = setExceptionData(rootData, upload);
        }
    }
    for (Element child : childs) {
        root.addContent(child);
    }
    childs = new ArrayList<Element>();
    //??  ?   end
}

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

License:Apache License

/**
 * ? ??  Data setting (data class : AnalyzeDefinition)
 * /*from www  . j  av  a  2 s  .co m*/
 * @param root
 * @param data
 * @param upload
 */
public static void setDynamicSection(Element root, AnalyzeDefinition data, Upload upload) {

    List<Element> childs = new ArrayList<Element>();
    int index = 0;
    for (Element e : root.getChildren()) {
        if (e.getName().equals("section")) {
            //   Section ?   
            setDynamicSection(e, data, upload);
        } else if (e.getName().equals("file_summary")) {
            //  ? 
            childs = setFileSummary(data);
        } else if (e.getName().equals("pattern_servlet")) {
            // Servlet ?? ?
            childs = setPatternData(data, "servlet");
        } else if (e.getName().equals("pattern_ejb")) {
            // EJB ?? ?
            childs = setPatternData(data, "ejb");
        } else if (e.getName().equals("dependency_java")) {
            // Java ?
            childs = setDependencyData(data, "java");
        } else if (e.getName().equals("dependency_jsp")) {
            // jsp ?
            childs = setDependencyData(data, "jsp");
        } else if (e.getName().equals("dependency_property")) {
            // Properties ?
            childs = setDependencyData(data, "property");
        } else if (e.getName().equals("dependency_class")) {
            // Class ?
            childs = setDependencyData(data, "class");
        } else if (e.getName().equals("jsp_analyze_result")) {
            // JSP  ? ? 
            childs = setJspAnalyzeData(data, upload);
        } else if (e.getName().equals("deploy_application_text")) {
            // ? ? 
            childs = setDeployApplicationText(data, upload);
            index = 1;
        } else if (e.getName().equals("web_xml_info")) {
            //  ? ? 
            childs = setApplicationData(data, upload);
        } else if (e.getName().equals("jar_xml_info")) {
            // EJB ? ? 
            childs = setApplicationData(data, upload);
        } else if (e.getName().equals("lib_list")) {
            // lib  
            childs = setLibData(data, upload, "");
        } else if (e.getName().equals("delete_lib_list")) {
            // ? lib  
            childs = setLibData(data, upload, "D");
        } else if (e.getName().equals("class_info")) {
            // classes  
            childs = setClassData(data, upload);
        } else if (e.getName().equals("application_list")) {
            // ?? ? ? ?
            childs = setApplicationListData(data, upload);
            index = 2;
        } else if (e.getName().equals("application_info")) {
            // ?? ? ? 
            childs = setApplicationData(data, upload);
        } else if (e.getName().equals("ejb_application_list")) {
            // ?? ?? EJB   
            childs = setEjbApplicationData(data, upload);
        } else if (e.getName().equals("maven_dependency")) {
            // Maven Dependency 
            childs = setMavenDependencyList(data, upload);
        } else if (e.getName().equals("convert_encoding")) {
            //?  ? 
            childs = setConvertEncodingData(data, upload);
            index = 7;
        }
    }

    //index 0? ?    index ?   ? 
    if (index == 0) {
        root.addContent(childs);
    } else {
        root.addContent(index, childs);
        index = 0;
    }

}

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

License:Apache License

/**
 *  ?   ?/*  www.  java2s .  com*/
 * 
 * @param data
 * @return
 */
public static List<Element> setFileSummary(AnalyzeDefinition data) {

    List<Element> childs = new ArrayList<Element>();
    if (data.getFileSummaryMap() != null) {
        Element child1 = new Element("table");
        Element child2 = new Element("chart");
        child2.setAttribute("title", MessageUtil.getMessage("pdf.message.chart.title.file_count"));

        Element childE1 = new Element("header");
        Element childE2 = new Element("row");
        Element childE3;

        child1.setAttribute("size", "4");

        childE1.addContent(
                new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.extension")));
        childE1.addContent(
                new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.file_count")));
        childE1.addContent(
                new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.source_encoding")));
        childE1.addContent(
                new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.target_encoding")));

        for (FileType fileType : FileType.values()) {
            FileSummary summary = data.getFileSummaryMap().get(fileType);
            if (summary != null) {
                childE2.addContent(new Element("col").setText(fileType.toString()));
                childE2.addContent(new Element("col").setText(String.valueOf(summary.getFileCount())));
                childE2.addContent(new Element("col").setText(summary.getSourceEncoding()));
                childE2.addContent(new Element("col").setText(summary.getTargetEncoding()));

                childE3 = new Element("data");
                childE3.addContent(new Element("column").setText(fileType.toString()));
                childE3.addContent(new Element("value").setText(String.valueOf(summary.getFileCount())));
                child2.addContent(childE3);
            }
        }

        child1.addContent(childE1);
        child1.addContent(childE2);

        childs.add(child1);
        childs.add(child2);
    }
    return childs;
}

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

License:Apache License

/**
 * ?? ?  ?//from w w  w  .j  av  a2 s.c  om
 * (type : servlet, ejb)
 * 
 * @param data
 * @param type
 * @return
 */
public static List<Element> setPatternData(AnalyzeDefinition data, String type) {

    List<Element> childs = new ArrayList<Element>();
    List<CommonAnalyze> dataList = new ArrayList<CommonAnalyze>();
    if (type.equals("servlet"))
        dataList = data.getServletExtendsList();
    else if (type.equals("ejb"))
        dataList = data.getEjbExtendsList();

    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()));
        }

        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 www  . j ava  2  s .  c o  m
 * (type : java, jsp, property, class)
 * 
 * @param data
 * @param type
 * @return
 */
public static List<Element> setDependencyData(AnalyzeDefinition data, String type) {

    List<Element> childs = new ArrayList<Element>();
    List<Dependency> dataList = new ArrayList<Dependency>();
    if (type.equals("java"))
        dataList = data.getJavaDependencyList();
    else if (type.equals("jsp"))
        dataList = data.getJspDependencyList();
    else if (type.equals("property"))
        dataList = data.getPropertyDependencyList();
    else if (type.equals("class"))
        dataList = data.getClassDependencyList();

    if (dataList.size() > 0) {

        Element text;
        for (Dependency comm : dataList) {

            if (comm.getDependencyStrMap().entrySet().iterator().hasNext()
                    || comm.getOthersStrMap().entrySet().iterator().hasNext()) {

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

                Element box = new Element("box");
                box.setAttribute("option", "other");
                Iterator iterator = comm.getDependencyStrMap().entrySet().iterator();
                StringBuffer buf = new StringBuffer();
                while (iterator.hasNext()) {
                    Entry entry = (Entry) iterator.next();
                    buf.append(entry.getKey() + " " + entry.getValue() + "\n");
                }
                box.addContent(
                        new Element("text").setAttribute("type", "default").setText(buf.toString() + "\n"));

                if (type.equals("java") || type.equals("jsp") || type.equals("property")) {
                    iterator = comm.getOthersStrMap().entrySet().iterator();
                    if (iterator.hasNext()) {
                        box.addContent(new Element("text").setAttribute("type", "red")
                                .setText(" ?" + "\n"));

                        buf = new StringBuffer();
                        while (iterator.hasNext()) {
                            Entry entry = (Entry) iterator.next();
                            buf.append(entry.getKey() + " " + entry.getValue() + "\n");
                        }
                        box.addContent(new Element("text").setAttribute("type", "default")
                                .setText(buf.toString() + "\n"));
                    }
                }
                childs.add(box);
            }
        }

    }

    return childs;
}

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

License:Apache License

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

    List<Element> childs = new ArrayList<Element>();
    Map<String, Integer> dataMap = data.getJspDirectiveMap();

    if (dataMap != null) {
        int jspFileCount = 0;
        if (data.getFileSummaryMap() != null)
            jspFileCount = ((FileSummary) data.getFileSummaryMap().get(FileType.JSP)).getFileCount();

        childs.add(new Element("text").setText(MessageUtil.getMessage("pdf.message.jsp_summary.info.text",
                upload.getProjectNm(), String.valueOf(jspFileCount))));
        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", "330");
        childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.directive")));

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

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

            childE2.addContent(new Element("col").setText(String.valueOf(entry.getKey())));
            childE2.addContent(new Element("col").setText(String.valueOf(entry.getValue())));

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

        childs.add(child);
    }

    return childs;
}

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

License:Apache License

/**
 * lib   ?//w w w .j  a  va  2s  .  c  o  m
 * (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  ww . j av a  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  2 s  .  c o m
 * 
 * @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

/**
 * ?? ?? EJB    ?/*from w  w  w. ja v a 2 s.  c  om*/
 * 
 * @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;
}