本文整理了Java中org.jdom.output.Format.setTextMode()
方法的一些代码示例,展示了Format.setTextMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.setTextMode()
方法的具体详情如下:
包路径:org.jdom.output.Format
类名称:Format
方法名:setTextMode
[英]This sets the text output style. Options are available as static TextMode instances. The default is TextMode#PRESERVE.
[中]这将设置文本输出样式。选项作为静态TextMode实例提供。默认设置为TextMode#PRESERVE。
代码示例来源:origin: org.jdom/jdom-legacy
/**
* Returns a new Format object that performs whitespace normalization, 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.
*
* @return a Format with whitespace normalization
*/
public static Format getCompactFormat() {
Format f = new Format();
f.setTextMode(TextMode.NORMALIZE);
return f;
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* 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.
*
* @return a Format with whitespace beautification
*/
public static Format getPrettyFormat() {
Format f = new Format();
f.setIndent(STANDARD_INDENT);
f.setTextMode(TextMode.TRIM);
return f;
}
代码示例来源:origin: info.magnolia/magnolia-core
public DocumentViewOutputter() {
final Format format = Format.getPrettyFormat();
format.setTextMode(Format.TextMode.NORMALIZE);
format.setOmitDeclaration(true);
setFormat(format);
}
代码示例来源:origin: org.kathrynhuxtable.maven.plugins/htmlfilter-site-maven-plugin
/**
* Get the element contents as a String.
*
* @param element the element.
*
* @return the element contents.
*/
private String getElementContentsAsText(Element element) {
StringBuilder text = new StringBuilder();
HTMLOutputter writer = new HTMLOutputter(Format.getPrettyFormat().setTextMode(Format.TextMode.TRIM_FULL_WHITE)
.setExpandEmptyElements(true));
List<Element> children = getChildren(element);
if (children.size() == 0) {
return element.getText();
}
for (Element child : children) {
StringWriter sw = new StringWriter();
try {
writer.output(child, sw);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
text.append(sw);
}
return text.toString();
}
代码示例来源: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);
}
代码示例来源:origin: bcdev/beam
private static String toXMLString(Element metadataElement) {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(false);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(metadataElement);
return xml;
}
}
代码示例来源:origin: org.jfrog.buildinfo/build-info-extractor-maven3
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
代码示例来源:origin: bcdev/beam
public String getAsXML() {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(true);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
return xmlOutputter.outputString(createRootTree("class name list template"));
}
代码示例来源:origin: bcdev/beam
private static String getXML(Element metadataElement) {
// following lines uses the old JDOM jar
// xmlOutputter.setIndent(true);
// xmlOutputter.setIndent(" ");
// xmlOutputter.setNewlines(true);
// xmlOutputter.setExpandEmptyElements(false);
// xmlOutputter.setOmitEncoding(true);
// xmlOutputter.setOmitDeclaration(true);
// xmlOutputter.setTextNormalize(false);
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.PRESERVE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(metadataElement);
return xml;
}
代码示例来源:origin: bcdev/beam
@SuppressWarnings({"UnusedDeclaration"})
private void printDocument(Document document) {
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(false);
prettyFormat.setOmitEncoding(true);
prettyFormat.setOmitDeclaration(true);
prettyFormat.setTextMode(Format.TextMode.NORMALIZE);
final XMLOutputter xmlOutputter = new XMLOutputter(prettyFormat);
final String xml = xmlOutputter.outputString(document);
System.out.println(xml);
}
代码示例来源:origin: net.sourceforge.ondex.core/workflow-base
public static void saveToFile(File file, WorkflowDescription td) throws IOException {
Format format = Format.getPrettyFormat();
format.setTextMode(TextMode.PRESERVE);
XMLOutputter outputter = new XMLOutputter(format);
Element rootElement = new Element("Ondex");
内容来源于网络,如有侵权,请联系作者删除!