本文整理汇总了Java中org.jdom.output.Format.getRawFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Format.getRawFormat方法的具体用法?Java Format.getRawFormat怎么用?Java Format.getRawFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.output.Format
的用法示例。
在下文中一共展示了Format.getRawFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: export
import org.jdom.output.Format; //导入方法依赖的package包/类
public byte[] export(ExportDataSet dataSet) {
if (dataSet == null) {
throw new IllegalArgumentException("Xml Exporter cannot handle NULL data.");
}
Element rootElement = new Element(DATA_ELEMENT, WORKFLOW_NAMESPACE);
rootElement.addNamespaceDeclaration(SCHEMA_NAMESPACE);
rootElement.setAttribute(SCHEMA_LOCATION_ATTR, WORKFLOW_SCHEMA_LOCATION, SCHEMA_NAMESPACE);
Document document = new Document(rootElement);
boolean shouldPrettyPrint = true;
for (XmlExporter exporter : xmlImpexRegistry.getExporters()) {
Element exportedElement = exporter.export(dataSet);
if (exportedElement != null) {
if (!exporter.supportPrettyPrint()) {
shouldPrettyPrint = false;
}
appendIfNotEmpty(rootElement, exportedElement);
}
}
// TODO: KULRICE-4420 - this needs cleanup
Format f;
if (!shouldPrettyPrint) {
f = Format.getRawFormat();
f.setExpandEmptyElements(false);
f.setTextMode(Format.TextMode.PRESERVE);
} else {
f = Format.getPrettyFormat();
}
XMLOutputter outputer = new XMLOutputter(f);
StringWriter writer = new StringWriter();
try {
outputer.output(document, writer);
} catch (IOException e) {
throw new WorkflowRuntimeException("Could not write XML data export.", e);
}
return writer.toString().getBytes();
}
示例2: write
import org.jdom.output.Format; //导入方法依赖的package包/类
/**
* Write out the (possibly modified) GAPP file to its new location.
*
* @throws IOException if an I/O error occurs.
*/
public void write() throws IOException {
finish();
File newGappFile = Files.fileFromURL(gappFileURL);
FileOutputStream fos = new FileOutputStream(newGappFile);
BufferedOutputStream out = new BufferedOutputStream(fos);
XMLOutputter outputter = new XMLOutputter(Format.getRawFormat());
outputter.output(gappDocument, out);
}
示例3: JPFClasspathFixProcessor
import org.jdom.output.Format; //导入方法依赖的package包/类
public JPFClasspathFixProcessor()
{
super();
sax = new SAXBuilder();
sax.setValidation(false);
sax.setReuseParser(true);
sax.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Format format = Format.getRawFormat();
format.setOmitEncoding(true);
format.setOmitDeclaration(true);
format.setLineSeparator("\n");
format.setEncoding("UTF-8");
xmlOut = new XMLOutputter(format);
}
示例4: write
import org.jdom.output.Format; //导入方法依赖的package包/类
/**
* Method write
*
* @param project
* @param writer
* @param document
*/
public void write( Model project, Document document, OutputStreamWriter writer )
throws java.io.IOException
{
Format format = Format.getRawFormat();
format.setEncoding( writer.getEncoding() ).setLineSeparator( System.getProperty( "line.separator" ) );
write( project, document, writer, format );
}
示例5: getJdomFormat
import org.jdom.output.Format; //导入方法依赖的package包/类
/**
* Internal function to choose a format based on a boolean flag.
*
* @param indent whether to use indented or raw format
* @return The format
*/
private static Format getJdomFormat(boolean indent) {
return indent ? Format.getPrettyFormat() : Format.getRawFormat();
}