use of org.jdom2.output.Format in project k-9 by k9mail.
the class SettingsExporterTest method exportPreferences_setsFormatTo1.
@Test
public void exportPreferences_setsFormatTo1() throws Exception {
Document document = exportPreferences(false, Collections.<String>emptySet());
assertEquals("1", document.getRootElement().getAttributeValue("format"));
}
use of org.jdom2.output.Format in project pcgen by PCGen.
the class DiceBagModel method saveToFile.
/**
* <p>Saves the dicebag to the specified file as a UTF-8 xml file, with the format
* specified above in {@code loadFromFile()}</p>
*
* @param file File to save to.
*/
void saveToFile(File file) {
try {
Document doc = new Document();
saveToDocument(doc);
XMLOutputter xmlOut = new XMLOutputter();
xmlOut.setFormat(Format.getPrettyFormat());
FileWriter fr = new FileWriter(file);
xmlOut.output(doc, fr);
fr.flush();
fr.close();
m_filePath = file.getPath();
m_changed = false;
} catch (Exception e) {
JOptionPane.showMessageDialog(GMGenSystem.inst, "File load error: " + file.getName());
Logging.errorPrint("File Load Error" + file.getName());
Logging.errorPrint(e.getMessage(), e);
}
}
use of org.jdom2.output.Format in project gocd by gocd.
the class GoControlLog method writeLogFile.
protected void writeLogFile(File file, Element element) throws IOException {
// Write the log file out, let jdom care about the encoding by using
// an OutputStream instead of a Writer.
OutputStream logStream = null;
try {
Format format = Format.getPrettyFormat();
XMLOutputter outputter = new XMLOutputter(format);
IO.mkdirFor(file);
file.setWritable(true);
logStream = new BufferedOutputStream(new FileOutputStream(file));
outputter.output(new Document(element), logStream);
} finally {
IO.close(logStream);
}
}
use of org.jdom2.output.Format in project archi by archimatetool.
the class JDOMUtils method write2XMLString.
/**
* Convert a JDOM Document to a String format
* @param doc The JDOM Document
* @return The resulting String
* @throws IOException
*/
public static String write2XMLString(Document doc) throws IOException {
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
StringWriter out = new StringWriter();
outputter.output(doc, out);
out.close();
return out.toString();
}
use of org.jdom2.output.Format in project JMRI by JMRI.
the class PaneProgFrameTest method setupDoc.
// provide a test document in the above static variables
void setupDoc() {
// create a JDOM tree with just some elements
root = new Element("programmer-config");
doc = new Document(root);
doc.setDocType(new DocType("programmer-config", "programmer-config.dtd"));
// add some elements
root.addContent(new Element("programmer").setAttribute("showFnLanelPane", "yes").setAttribute("showRosterMediaPane", "yes").addContent(new Element("pane").setAttribute("name", "Basic").addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Start voltage")).addContent(new Element("display").setAttribute("item", "Normal direction of motion"))).addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Normal direction of motion")).addContent(new Element("display").setAttribute("item", "Normal direction of motion").setAttribute("format", "checkbox")).addContent(new Element("display").setAttribute("item", "Normal direction of motion").setAttribute("format", "radiobuttons")))).addContent(new Element("pane").setAttribute("name", "CV").addContent(new Element("column").addContent(new Element("cvtable")))).addContent(new Element("pane").setAttribute("name", "Other").addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Normal direction of motion")))));
return;
}
Aggregations