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.astronomy.project.Alignment.java

/**
 * //from w w  w  .  j a va 2 s . co  m
 * @return XML element
 */
public Element getXMLElement() {
    Element raiz = new Element("alineamiento");
    raiz.addContent(observatory.getElementoXML());
    raiz.addContent(foresight.getElementoXML());
    raiz.addContent(orientation.getXMLElement());
    raiz.addContent(description.getXMLElement());
    raiz.addContent(imagenPath.getXMLElement());
    raiz.addContent(getDeclination().getElementoXML());
    return raiz;
}

From source file:com.astronomy.project.Declination.java

/**
 * //from  w  w w . j  a  va 2 s .  co  m
 * @return XML element for declination
 */
public Element getElementoXML() {
    Element raiz = new Element("declinacion");
    raiz.setText(String.format("%.1f", this.getSignedValue()).replace(",", "."));
    return raiz;
}

From source file:com.astronomy.project.Orientation.java

/**
 * /*  w ww  . j a va  2 s  . c  o  m*/
 * @return XML element for orientation
 */
public Element getXMLElement() {
    Element raiz = new Element("direccion");
    Element acimutElemento = new Element("acimut");
    acimutElemento.setText(String.valueOf(getAzimuth().getSignedValue()));
    Element elevacionElemento = new Element("elevacion");
    elevacionElemento.setText(String.valueOf(getAltitude().getSignedValue()));
    raiz.addContent(acimutElemento);
    raiz.addContent(elevacionElemento);
    return raiz;
}

From source file:com.astronomy.project.Project.java

/**
 * Save project as XML file/*  w  w  w  . j a  v  a  2s  .  co m*/
 * @param file XML file
 * @throws FileNotFoundException File not found error
 * @throws IOException IO error
 * @throws NullPointerException Null pointer error 
 */
public void toXML(File file) throws FileNotFoundException, IOException, NullPointerException {
    Element estudioElemento = new Element("estudio");
    Document doc = new Document(estudioElemento);
    estudioElemento.setAttribute("nombre", name);
    Element aa = new Element("alineamientos");
    estudioElemento.addContent(aa);
    for (int i = 0; i < data.size(); i++) {
        Alignment ali = (Alignment) data.get(i);
        aa.addContent(ali.getXMLElement());
    }

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    FileOutputStream out = null;
    try {
        xmlOutput.output(doc, out = new FileOutputStream(file));
    } finally {
        out.close();
    }
}

From source file:com.astronomy.project.ReferencePoint.java

/**
 * //from w ww  .jav  a2 s.c  o m
 * @return Reference point as XML element
 */
public Element getElementoXML() {
    Element raiz = new Element("lugar");
    raiz.setAttribute("tipo", getType());
    Element nombreElemento = new Element("nombre");
    nombreElemento.setText(getName());
    raiz.addContent(nombreElemento);
    if (getCoordinates() != null) {
        Element coordenadasElemento = new Element("coordenadas");
        Element latitudElemento = new Element("latitud");
        Element longitudElemento = new Element("longitud");
        Element altitudElemento = new Element("altitud");
        latitudElemento.setText(getCoordinates().getLatitude().toString());
        longitudElemento.setText(getCoordinates().getLongitude().toString());
        altitudElemento.setText(String.valueOf(getCoordinates().getElevation()));
        coordenadasElemento.addContent(latitudElemento);
        coordenadasElemento.addContent(longitudElemento);
        coordenadasElemento.addContent(altitudElemento);
        raiz.addContent(coordenadasElemento);
    }
    return raiz;
}

From source file:com.astronomy.project.Tag.java

/**
 * /*from  w  ww .j  a  v a 2  s . co  m*/
 * @return XML element for tag
 */
public Element getXMLElement() {
    Element raiz = new Element(name);
    raiz.setText(value.get());
    return raiz;
}

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

License:Apache License

/**
 *  ?   ?/*from  w  w w . j av  a  2  s .c o  m*/
 * 
 * @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 www  . jav  a  2s  .co m
 * (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 ww w .  j av a2  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  va  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;
}