本文整理了Java中org.jdom.output.Format.getPrettyFormat()
方法的一些代码示例,展示了Format.getPrettyFormat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.getPrettyFormat()
方法的具体详情如下:
包路径:org.jdom.output.Format
类名称:Format
方法名:getPrettyFormat
[英]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. Tweaks can be made to the returned Format instance without affecting other instances.
[中]返回一个新的Format对象,该对象使用两个空格缩进执行空格美化,使用UTF-8编码,不展开空元素,包括声明和编码,并使用默认的实体转义策略。可以对返回的格式实例进行调整,而不会影响其他实例。
代码示例来源:origin: voldemort/voldemort
public String writeStoreList(List<StoreDefinition> stores) {
Element root = new Element(STORES_ELMT);
for(StoreDefinition def: stores) {
if(def.isView())
root.addContent(viewToElement(def));
else
root.addContent(storeToElement(def));
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(root);
}
代码示例来源:origin: voldemort/voldemort
public String writeCluster(Cluster cluster) {
Document doc = new Document(new Element(CLUSTER_ELMT));
doc.getRootElement().addContent(new Element(CLUSTER_NAME_ELMT).setText(cluster.getName()));
boolean displayZones = cluster.getZones().size() > 1;
if(displayZones) {
for(Zone n: cluster.getZones())
doc.getRootElement().addContent(mapZone(n));
}
for(Node n: cluster.getNodes())
doc.getRootElement().addContent(mapServer(n, displayZones));
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(doc.getRootElement());
}
代码示例来源:origin: kiegroup/optaplanner
@Override
public void writeSolution(Solution_ solution, File outputFile) {
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) {
Document document = new Document();
XmlOutputBuilder<Solution_> xmlOutputBuilder = createXmlOutputBuilder();
xmlOutputBuilder.setDocument(document);
xmlOutputBuilder.setSolution(solution);
xmlOutputBuilder.writeSolution();
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
outputter.output(document, out);
logger.info("Exported: {}", outputFile);
} catch (IOException e) {
throw new IllegalArgumentException("Could not write the file (" + outputFile.getName() + ").", e);
} catch (JDOMException e) {
throw new IllegalArgumentException("Could not format the XML file (" + outputFile.getName() + ").", e);
}
}
代码示例来源:origin: voldemort/voldemort
/**
* Given a storedefinition, constructs the xml string to be sent out in
* response to a "schemata" fetch request
*
* @param storeDefinition
* @return serialized store definition
*/
public static String constructSerializerInfoXml(StoreDefinition storeDefinition) {
Element store = new Element(StoreDefinitionsMapper.STORE_ELMT);
store.addContent(new Element(StoreDefinitionsMapper.STORE_NAME_ELMT).setText(storeDefinition.getName()));
Element keySerializer = new Element(StoreDefinitionsMapper.STORE_KEY_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(keySerializer, storeDefinition.getKeySerializer());
store.addContent(keySerializer);
Element valueSerializer = new Element(StoreDefinitionsMapper.STORE_VALUE_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(valueSerializer, storeDefinition.getValueSerializer());
store.addContent(valueSerializer);
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(store);
}
代码示例来源:origin: voldemort/voldemort
public String writeStore(StoreDefinition store) {
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
if(store.isView())
return serializer.outputString(viewToElement(store));
else
return serializer.outputString(storeToElement(store));
}
代码示例来源:origin: DSpace/DSpace
/**
* Return entire METS document as an inputStream
*
* @return entire METS document as a stream
*/
public InputStream getMetsAsStream() {
XMLOutputter outputPretty = new XMLOutputter(Format.getPrettyFormat());
return new ByteArrayInputStream(
outputPretty.outputString(mets).getBytes());
}
}
代码示例来源:origin: uk.org.mygrid.taverna.scufl/scufl-ui-api
public String getText() {
if (rootElement != null) {
XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
return xo.outputString(rootElement);
} else {
return "";
}
}
代码示例来源:origin: org.codehaus.xfire/xfire-core
protected void printNode(Element node)
throws Exception
{
XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
writer.output(node, System.out);
}
代码示例来源:origin: net.sf.taverna.t2.ui-api/perspective-core
public InputStream getLayoutInputStream() {
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
String xml = outputter.outputString(layoutElement.getChild("basepane"));
return new ByteArrayInputStream(xml.getBytes());
}
代码示例来源:origin: org.codehaus.xfire/xfire-generator
private void writeDocument(GenerationContext context, Document doc, File location) throws Exception
{
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
location.createNewFile();
outputter.output(doc, new FileOutputStream(location));
}
}
代码示例来源:origin: org.codehaus.xfire/xfire-core
protected void printNode(Document node)
throws Exception
{
XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
writer.output(node, System.out);
}
代码示例来源:origin: org.zaproxy/zap-clientapi
private static void writeAlertsToFile(File outputFile, Document doc) {
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
try {
xmlOutput.output(doc, new FileWriter(outputFile));
System.out.println("alert xml report saved to: " + outputFile.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: uk.org.mygrid.taverna.baclava/baclava-core
private static void printDocument(Element e) {
try {
Document doc = new Document(e);
XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
System.out.println(xo.outputString(doc));
} catch (Exception ex) {
//
}
}
代码示例来源:origin: edu.washington.cs.knowitall/nlp
/***
* Pretty formatted XML output.
*
* @return
*/
public String toMultilineXMLString() {
final XMLOutputter xmlout = new XMLOutputter(Format.getPrettyFormat());
return xmlout.outputString(this.toXmlElement());
}
代码示例来源:origin: locationtech/geowave
public static void writeElementToStreamPretty(final Element e, final OutputStream os) {
try {
final BufferedOutputStream bos = new BufferedOutputStream(os);
final Document document = new Document((Element) e.clone());
final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
outputter.output(document, bos);
bos.flush();
} catch (final IOException ioe) {
LOGGER.info("write error", ioe);
}
}
代码示例来源:origin: org.biomoby/taverna-biomoby
public static String createMobyDataElementWrapper(String xml,
String queryID, Element serviceNotes) throws MobyException {
if (xml == null)
return null;
Element element = createMobyDataElementWrapper(getDOMDocument(xml)
.getRootElement(), queryID, serviceNotes);
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
return (element == null ? null : outputter.outputString(element));
}
代码示例来源:origin: info.magnolia/magnolia-core
public DocumentViewOutputter() {
final Format format = Format.getPrettyFormat();
format.setTextMode(Format.TextMode.NORMALIZE);
format.setOmitDeclaration(true);
setFormat(format);
}
代码示例来源:origin: com.ebmwebsourcing.easyviper/core-impl
@Override
public String toString() {
String res = null;
if(this.getContent() != null) {
final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
res = outputter.outputString((Element)this.getContent());
} else {
res = super.toString();
}
return res;
}
}
代码示例来源:origin: org.entando.entando/entando-core-engine
public String getXMLDocument(){
XMLOutputter out = new XMLOutputter();
Format format = Format.getPrettyFormat();
format.setIndent("");
out.setFormat(format);
return out.outputString(this.getDoc());
}
代码示例来源:origin: info.magnolia/magnolia-core
public JcrExportCommand() {
final org.jdom.output.Format format = org.jdom.output.Format.getPrettyFormat();
format.setTextMode(org.jdom.output.Format.TextMode.PRESERVE);
format.setLineSeparator("\n");
getOutputter().setFormat(format);
}
内容来源于网络,如有侵权,请联系作者删除!