Search in sources :

Example 6 with Format

use of org.jdom.output.Format in project yamcs-studio by yamcs.

the class XMLUtil method getXMLOutputter.

/**
 * Create and configure an XMLOutputter object.
 *
 * @param prettyFormat
 * @return the XMLOutputter
 */
private static XMLOutputter getXMLOutputter(boolean prettyFormat) {
    Format format = Format.getRawFormat();
    if (prettyFormat)
        // $NON-NLS-1$
        format.setIndent("  ");
    // Always use Unix-style line endings.
    format.setLineSeparator("\n");
    XMLOutputter xmlOutputter = new XMLOutputter();
    xmlOutputter.setFormat(format);
    return xmlOutputter;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 7 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class PageModelDOM method getXMLDocument.

public String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(this._doc);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 8 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class WidgetTypeDOM method getXMLDocument.

public String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("");
    out.setFormat(format);
    return out.outputString(this.getDoc());
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 9 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class DataSourceDumpReport method toXml.

public String toXml() {
    try {
        Document doc = new Document();
        Element rootElement = new Element(ROOT_ELEMENT);
        this.addElement(DATE_ELEMENT, DateConverter.getFormattedDate(this.getDate(), DATE_FORMAT), rootElement);
        this.addElement(REQUIRED_TIME_ELEMENT, String.valueOf(this.getRequiredTime()), rootElement);
        this.addElement(SUBFOLDER_NAME_ELEMENT, this.getSubFolderName(), rootElement);
        Element components = new Element(COMPONENTS_HISTORY_ELEMENT);
        rootElement.addContent(components);
        List<ComponentInstallationReport> componentsHistory = this.getComponentsHistory();
        for (int i = 0; i < componentsHistory.size(); i++) {
            ComponentInstallationReport componentHistory = componentsHistory.get(i);
            Element element = componentHistory.toJdomElement();
            components.addContent(element);
        }
        List<String> dataSourceNames = new ArrayList<String>();
        dataSourceNames.addAll(this.getDataSourcesReports().keySet());
        for (int i = 0; i < dataSourceNames.size(); i++) {
            String dataSourceName = dataSourceNames.get(i);
            Element dataSourceElement = new Element(DATASOURCE_ELEMENT);
            rootElement.addContent(dataSourceElement);
            dataSourceElement.setAttribute(NAME_ATTRIBUTE, dataSourceName);
            List<TableDumpReport> tableReports = this.getDataSourcesReports().get(dataSourceName);
            BeanComparator comparator = new BeanComparator("tableName");
            Collections.sort(tableReports, comparator);
            for (int j = 0; j < tableReports.size(); j++) {
                TableDumpReport tableDumpReport = tableReports.get(j);
                dataSourceElement.addContent(tableDumpReport.toJdomElement());
            }
        }
        doc.setRootElement(rootElement);
        XMLOutputter out = new XMLOutputter();
        Format format = Format.getPrettyFormat();
        format.setIndent("\t");
        out.setFormat(format);
        return out.outputString(doc);
    } catch (Throwable t) {
        _logger.error("Error creating XML", t);
        throw new RuntimeException("Error creating XML", t);
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Element(org.jdom.Element) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) Document(org.jdom.Document) Format(org.jdom.output.Format)

Example 10 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class LangDOM method getXMLDocument.

/**
 * Restutuisce l'xml del documento.
 * @return L'xml del documento.
 */
public String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    out.setFormat(format);
    String xml = out.outputString(this.doc);
    return xml;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Aggregations

Format (org.jdom.output.Format)45 XMLOutputter (org.jdom.output.XMLOutputter)40 Document (org.jdom.Document)20 Element (org.jdom.Element)20 StringWriter (java.io.StringWriter)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)6 Namespace (org.jdom.Namespace)6 Writer (java.io.Writer)5 SAXBuilder (org.jdom.input.SAXBuilder)5 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 JDOMException (org.jdom.JDOMException)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 File (java.io.File)3 FileWriter (java.io.FileWriter)3 StringReader (java.io.StringReader)3 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3