本文整理汇总了Java中org.jdom2.output.Format.getCompactFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Format.getCompactFormat方法的具体用法?Java Format.getCompactFormat怎么用?Java Format.getCompactFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom2.output.Format
的用法示例。
在下文中一共展示了Format.getCompactFormat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createXml
import org.jdom2.output.Format; //导入方法依赖的package包/类
private void createXml(ISendMessageCallback callback) {
Document generatedXml = new Document();
Stack<DocElement> parentStack = new Stack<DocElement>();
ArrayList<String> outboundPayload = new ArrayList<String>();
for (Message msg : messagesToProcess) {
processMsgEntities(parentStack, msg, generatedXml);
}
XMLOutputter xmlOutputter = new XMLOutputter();
Format format = null;
if (xmlFormat.equals(COMPACT_FORMAT)) {
format = Format.getCompactFormat();
} else if (xmlFormat.equals(RAW_FORMAT)) {
format = Format.getRawFormat();
} else {
format = Format.getPrettyFormat();
}
xmlOutputter.setFormat(format);
outboundPayload.add(xmlOutputter.outputString(generatedXml));
callback.sendTextMessage(null, outboundPayload);
}
示例2: canonicalElement
import org.jdom2.output.Format; //导入方法依赖的package包/类
private static Element canonicalElement(Parent e) throws IOException, SAXParseException {
XMLOutputter xout = new XMLOutputter(Format.getCompactFormat());
MCRByteArrayOutputStream bout = new MCRByteArrayOutputStream();
if (e instanceof Element) {
xout.output((Element) e, bout);
} else {
xout.output((Document) e, bout);
}
Document xml = MCRXMLParserFactory.getNonValidatingParser()
.parseXML(new MCRByteContent(bout.getBuffer(), 0, bout.size()));
return xml.getRootElement();
}
示例3: documentToStringDump
import org.jdom2.output.Format; //导入方法依赖的package包/类
/****************************************************************************/
public static String documentToStringDump(Document doc) {
if (doc == null) return null;
XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
return out.outputString(doc);
}
示例4: elementToStringDump
import org.jdom2.output.Format; //导入方法依赖的package包/类
/****************************************************************************/
public static String elementToStringDump(Element e) {
if (e == null) return null ;
XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
return out.outputString(e);
}
示例5: getTransformedXml
import org.jdom2.output.Format; //导入方法依赖的package包/类
public static String getTransformedXml(String inputXml, String stylesheetXml, String xmlFormat, boolean omitXmlDeclaration) {
StringWriter writer = new StringWriter();
SAXBuilder builder = new SAXBuilder();
builder.setXMLReaderFactory(XMLReaders.NONVALIDATING);
builder.setFeature("http://xml.org/sax/features/validation", false);
try {
Document inputDoc = builder.build(new StringReader(inputXml));
StringReader reader = new StringReader(stylesheetXml);
XSLTransformer transformer = new XSLTransformer(reader);
Document outputDoc = transformer.transform(inputDoc);
XMLOutputter xmlOutput = new XMLOutputter();
Format format = null;
if (xmlFormat.equals(COMPACT_FORMAT)) {
format = Format.getCompactFormat();
} else if (xmlFormat.equals(RAW_FORMAT)) {
format = Format.getRawFormat();
} else {
format = Format.getPrettyFormat();
}
format.setOmitDeclaration(omitXmlDeclaration);
xmlOutput.setFormat(format);
xmlOutput.output(outputDoc, writer);
writer.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
return writer.toString();
}
示例6: getFormat
import org.jdom2.output.Format; //导入方法依赖的package包/类
private Format getFormat(final boolean prettyPrint, final boolean showXmlDeclaration) {
final Format format = prettyPrint ? Format.getPrettyFormat().setIndent(INDENT) : Format.getCompactFormat();
return format.setOmitDeclaration(!showXmlDeclaration)
.setEncoding(UTF_8_ENCODING)
.setLineSeparator(NEW_LINE);
}
示例7: outputString
import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
* Creates a String with the XML representation for the given WireFeed.
* <p>
* If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
* the responsibility of the developer to ensure that if the String is written to a character
* stream the stream charset is the same as the feed encoding property.
* <p>
* NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
* <p>
*
* @param feed Abstract feed to create XML representation from. The type of the WireFeed must
* match the type given to the FeedOuptut constructor.
* @param prettyPrint pretty-print XML (true) oder collapsed
* @return a String with the XML representation for the given WireFeed.
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
* don't match.
* @throws FeedException thrown if the XML representation for the feed could not be created.
*
*/
public String outputString(final WireFeed feed, final boolean prettyPrint) throws IllegalArgumentException, FeedException {
final Document doc = outputJDom(feed);
final String encoding = feed.getEncoding();
Format format;
if (prettyPrint) {
format = Format.getPrettyFormat();
} else {
format = Format.getCompactFormat();
}
if (encoding != null) {
format.setEncoding(encoding);
}
final XMLOutputter outputter = new XMLOutputter(format);
return outputter.outputString(doc);
}
示例8: output
import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
* Writes to an Writer the XML representation for the given WireFeed.
* <p>
* If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
* the responsibility of the developer to ensure the Writer instance is using the same charset
* encoding.
* <p>
* NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
* <p>
*
* @param feed Abstract feed to create XML representation from. The type of the WireFeed must
* match the type given to the FeedOuptut constructor.
* @param writer Writer to write the XML representation for the given WireFeed.
* @param prettyPrint pretty-print XML (true) oder collapsed
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
* don't match.
* @throws IOException thrown if there was some problem writing to the Writer.
* @throws FeedException thrown if the XML representation for the feed could not be created.
*
*/
public void output(final WireFeed feed, final Writer writer, final boolean prettyPrint) throws IllegalArgumentException, IOException, FeedException {
final Document doc = outputJDom(feed);
final String encoding = feed.getEncoding();
Format format;
if (prettyPrint) {
format = Format.getPrettyFormat();
} else {
format = Format.getCompactFormat();
}
if (encoding != null) {
format.setEncoding(encoding);
}
final XMLOutputter outputter = new XMLOutputter(format);
outputter.output(doc, writer);
}
示例9: outputString
import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
* Creates a String with the XML representation for the given WireFeed.
* <p>
* If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
* of the developer to ensure that if the String is written to a character stream the stream charset is the same as
* the feed encoding property.
* <p>
* NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
* <p>
* @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
* the type given to the FeedOuptut constructor.
* @param prettyPrint pretty-print XML (true) oder collapsed
* @return a String with the XML representation for the given WireFeed.
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
* @throws FeedException thrown if the XML representation for the feed could not be created.
*
*/
public String outputString(WireFeed feed, boolean prettyPrint) throws IllegalArgumentException,FeedException {
Document doc = outputJDom(feed);
String encoding = feed.getEncoding();
Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
if (encoding!=null) {
format.setEncoding(encoding);
}
XMLOutputter outputter = new XMLOutputter(format);
return outputter.outputString(doc);
}
示例10: output
import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
* Writes to an Writer the XML representation for the given WireFeed.
* <p>
* If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
* of the developer to ensure the Writer instance is using the same charset encoding.
* <p>
* NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
* <p>
* @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
* the type given to the FeedOuptut constructor.
* @param writer Writer to write the XML representation for the given WireFeed.
* @param prettyPrint pretty-print XML (true) oder collapsed
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
* @throws IOException thrown if there was some problem writing to the Writer.
* @throws FeedException thrown if the XML representation for the feed could not be created.
*
*/
public void output(WireFeed feed,Writer writer,boolean prettyPrint) throws IllegalArgumentException,IOException, FeedException {
Document doc = outputJDom(feed);
String encoding = feed.getEncoding();
Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
if (encoding!=null) {
format.setEncoding(encoding);
}
XMLOutputter outputter = new XMLOutputter(format);
outputter.output(doc,writer);
}