Example usage for org.jdom2.output Format getPrettyFormat

List of usage examples for org.jdom2.output Format getPrettyFormat

Introduction

In this page you can find the example usage for org.jdom2.output Format getPrettyFormat.

Prototype

public static Format getPrettyFormat() 

Source Link

Document

Returns a new Format object that performs whitespace beautification with 2-space indents, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy.

Usage

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Write to root Element to a writer./*from   www  .  jav  a  2 s  .  com*/
 *
 * @param root Root Element to write.
 * @param writer Writer to write to.
 * @throws IOException if the writer fails to write.
 */
protected void writeDocument(Element root, Writer writer) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document(root);
    outputter.output(document, writer);
}

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Write the job list to our streaming xml writer.
 *
 * @param jobs//from  ww  w. j  a v  a  2  s  .co  m
 * @param writer Writer to write to.
 * @throws IOException if the writer fails to write.
 */
public void write(Iterator<JobRef> jobs, Writer writer) throws IOException {
    Element root = getRootElement(jobs);
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document(root);
    outputter.output(document, writer);
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Write the job to a writer.//ww w.  j  a  v a2s  .  c  o m
 *
 * @param job
 * @param writer Writer to write to.
 * @throws IOException if the writer fails to write.
 */
public void write(Job job, Writer writer) throws IOException {
    Element root = getRootElement(job);
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document(root);
    outputter.output(document, writer);
}

From source file:ca.nrc.cadc.uws.web.restlet.representation.JDOMRepresentation.java

License:Open Source License

/**
 * Write the Document to the OutputStream.
 * //w  ww . j  a  v  a 2 s.com
 * @param out The OutputStream to write to.
 * @throws IOException if there is a problem writing the Document.
 */
@Override
public void write(OutputStream out) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    outputter.output(document, out);
}

From source file:ca.nrc.cadc.vodml.VOModelWriter.java

License:Open Source License

public void write(Document doc, Writer out) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    if (prettyPrint) {
        outputter.setFormat(Format.getPrettyFormat());
    } else {//w  w  w.j a v  a 2  s .  c o m
        outputter.setFormat(Format.getCompactFormat());
    }
    outputter.output(doc, out);
}

From source file:ca.nrc.cadc.vos.client.VOSClientUtil.java

License:Open Source License

public static String xmlString(Document doc) {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    return outputter.outputString(doc);
}

From source file:ca.nrc.cadc.vos.JsonNodeWriter.java

License:Open Source License

@Override
protected void write(Element root, Writer writer) throws IOException {
    JsonOutputter outputter = new JsonOutputter();
    outputter.getListElementNames().add("nodes");
    outputter.getListElementNames().add("properties");
    outputter.getListElementNames().add("accepts");
    outputter.getListElementNames().add("provides");

    // WebRT 72612
    // Treat all property values as Strings.
    // jenkinsd 2016.01.20
    outputter.getStringElementNames().add("property");

    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document(root);
    outputter.output(document, writer);/*from w w  w.  jav a 2  s.  c  o  m*/
}

From source file:ca.nrc.cadc.vos.server.RssView.java

License:Open Source License

/**
 * Write to root Element to a writer.//w w  w .java2s . co  m
 *
 * @param root Root Element to write.
 * @param writer Writer to write to.
 * @throws IOException if the writer fails to write.
 */
protected void write(Element root, Writer writer) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document();
    root.detach();
    document.setRootElement(root);
    outputter.output(document, writer);
}

From source file:ca.nrc.cadc.vos.TransferWriter.java

License:Open Source License

/**
 * Write to root Element to a writer./*from w w  w. ja va2  s  .  co m*/
 *
 * @param root Root Element to write.
 * @param writer Writer to write to.
 * @throws IOException if the writer fails to write.
 */
@SuppressWarnings("unchecked")
protected void write(Element root, Writer writer) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(Format.getPrettyFormat());
    Document document = new Document(root);
    outputter.output(document, writer);
}

From source file:ca.nrc.cadc.vosi.TableSetWriter.java

License:Open Source License

public void write(TapSchema ts, Writer writer) throws IOException {
    TableSet tset = new TableSet(ts);
    Document doc = tset.getDocument();
    XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
    out.output(doc, writer);/*from w w w  .  j a  v a  2  s . c  om*/
}