Search in sources :

Example 31 with Format

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

the class ShortcutDefDOM method getXMLDocument.

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

Example 32 with Format

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

the class UserShortcutConfigDOM method createUserConfigXml.

protected static String createUserConfigXml(String[] config) throws ApsSystemException {
    XMLOutputter out = new XMLOutputter();
    Document document = new Document();
    try {
        Element rootElement = new Element(ROOT_ELEMENT_NAME);
        document.setRootElement(rootElement);
        for (int i = 0; i < config.length; i++) {
            String shortcut = config[i];
            if (null != shortcut) {
                Element element = new Element(BOX_ELEMENT_NAME);
                element.setAttribute(POS_ATTRIBUTE_NAME, String.valueOf(i));
                element.setText(shortcut);
                rootElement.addContent(element);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error parsing user config", t);
        // ApsSystemUtils.logThrowable(t, UserShortcutConfigDOM.class, "extractUserShortcutConfig");
        throw new ApsSystemException("Error parsing user config", t);
    }
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(document);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) Element(org.jdom.Element) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Document(org.jdom.Document)

Example 33 with Format

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

the class EntityTypeDOM method getXml.

@Override
public String getXml(IApsEntity entityType) throws ApsSystemException {
    XMLOutputter out = new XMLOutputter();
    Document document = new Document();
    try {
        Element entityTypeElement = this.createTypeElement(entityType);
        document.setRootElement(entityTypeElement);
        Format format = Format.getPrettyFormat();
        format.setIndent("\t");
        out.setFormat(format);
    } catch (Throwable t) {
        _logger.error("Error building xml", t);
        throw new ApsSystemException("Error building xml", t);
    }
    return out.outputString(document);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) Element(org.jdom.Element) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Document(org.jdom.Document)

Example 34 with Format

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

the class EntityTypeDOM method getXml.

@Override
public String getXml(Map<String, IApsEntity> entityTypes) throws ApsSystemException {
    XMLOutputter out = new XMLOutputter();
    Document document = new Document();
    try {
        Element rootElement = new Element(this.getEntityTypesRootElementName());
        document.setRootElement(rootElement);
        List<String> entityTypeCodes = new ArrayList<>(entityTypes.keySet());
        Collections.sort(entityTypeCodes);
        for (String entityTypeCode : entityTypeCodes) {
            IApsEntity currentEntityType = entityTypes.get(entityTypeCode);
            Element entityTypeElement = this.createTypeElement(currentEntityType);
            rootElement.addContent(entityTypeElement);
        }
        Format format = Format.getPrettyFormat();
        format.setIndent("\t");
        out.setFormat(format);
    } catch (Throwable t) {
        _logger.error("Error building xml", t);
        throw new ApsSystemException("Error building xml", t);
    }
    return out.outputString(document);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) Element(org.jdom.Element) ArrayList(java.util.ArrayList) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Document(org.jdom.Document)

Example 35 with Format

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

the class PageExtraConfigDOM method getXMLDocument.

protected String getXMLDocument(Document doc) {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    out.setFormat(format);
    return out.outputString(doc);
}
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