本文整理匯總了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);
}