Search in sources :

Example 1 with Format

use of org.jdom.output.Format in project intellij-community by JetBrains.

the class EditorColorSchemeTestCase method assertXmlOutputEquals.

protected static void assertXmlOutputEquals(String expected, Element root) throws IOException {
    StringWriter writer = new StringWriter();
    Format format = Format.getPrettyFormat();
    format.setLineSeparator("\n");
    new XMLOutputter(format).output(root, writer);
    String actual = writer.toString();
    assertEquals(expected, actual);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) StringWriter(java.io.StringWriter)

Example 2 with Format

use of org.jdom.output.Format in project intellij-community by JetBrains.

the class JDOMUtil method createOutputter.

@NotNull
public static XMLOutputter createOutputter(String lineSeparator) {
    XMLOutputter xmlOutputter = new MyXMLOutputter();
    Format format = Format.getCompactFormat().setIndent("  ").setTextMode(Format.TextMode.TRIM).setEncoding(CharsetToolkit.UTF8).setOmitEncoding(false).setOmitDeclaration(false).setLineSeparator(lineSeparator);
    xmlOutputter.setFormat(format);
    return xmlOutputter;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Format

use of org.jdom.output.Format in project intellij-community by JetBrains.

the class XMLOutputterTest method printElement.

private String printElement(Element root) throws IOException {
    XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n");
    final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true);
    xmlOutputter.setFormat(format);
    CharArrayWriter writer = new CharArrayWriter();
    xmlOutputter.output(root, writer);
    String res = new String(writer.toCharArray());
    return res;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) CharArrayWriter(java.io.CharArrayWriter)

Example 4 with Format

use of org.jdom.output.Format in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method assertXmlOutputEquals.

private static void assertXmlOutputEquals(String expected, Element root) throws IOException {
    StringWriter writer = new StringWriter();
    Format format = Format.getPrettyFormat();
    format.setLineSeparator("\n");
    new XMLOutputter(format).output(root, writer);
    String actual = writer.toString();
    assertEquals(expected, actual);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) StringWriter(java.io.StringWriter)

Example 5 with Format

use of org.jdom.output.Format in project intellij-community by JetBrains.

the class SerializableSchemeExporter method writeToStream.

private static void writeToStream(@NotNull OutputStream outputStream, @NotNull Element element) throws IOException {
    OutputStreamWriter writer = new OutputStreamWriter(outputStream);
    Format format = Format.getPrettyFormat();
    format.setLineSeparator("\n");
    new XMLOutputter(format).output(element, writer);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) OutputStreamWriter(java.io.OutputStreamWriter)

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