本文整理了Java中org.jdom.output.Format.getCompactFormat()
方法的一些代码示例,展示了Format.getCompactFormat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.getCompactFormat()
方法的具体详情如下:
包路径:org.jdom.output.Format
类名称:Format
方法名:getCompactFormat
[英]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.
[中]返回一个新的Format对象,该对象执行空白规范化,使用UTF-8编码,不展开空元素,包括声明和编码,并使用默认的实体转义策略。可以对返回的格式实例进行调整,而不会影响其他实例。
代码示例来源:origin: org.commonjava.rwx/rwx-core
public JDomRenderer()
{
outputter = new XMLOutputter( Format.getCompactFormat() );
}
代码示例来源:origin: org.commonjava.rwx/rwx-bindings
public ReflectionUnbindery( final Map<Class<?>, Mapping<?>> recipes, BindingConfiguration configuration )
{
this.recipes = recipes;
this.configuration = configuration;
outputter = new XMLOutputter( Format.getCompactFormat() );
}
代码示例来源:origin: org.commonjava.rwx/rwx-bindings
public ReflectionUnbindery( final Map<Class<?>, Mapping<?>> recipes, final XMLOutputter outputter, BindingConfiguration configuration )
{
this.recipes = recipes;
this.outputter = outputter == null ? new XMLOutputter( Format.getCompactFormat() ) : outputter;
this.configuration = configuration;
}
代码示例来源:origin: uk.org.mygrid.remotetaverna/taverna-engine
@Override
public void run() {
XMLOutputter xmlOutputter = new XMLOutputter(Format
.getCompactFormat());
try {
xmlOutputter.output(doc, outputStream);
} catch (IOException e) {
logger.warn("Could not output XML document", e);
}
}
};
代码示例来源:origin: jericks/geoserver-shell
public static String toString(Element element) {
XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
return xmlOutputter.outputString(element);
}
}
代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common
public static String compactXML(InputStream input) throws Exception {
Document doc = new SAXBuilder().build(input);
XMLOutputter xo = new XMLOutputter();
xo.setFormat(Format.getCompactFormat().setOmitDeclaration(true));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xo.output(doc, baos);
return new String(baos.toByteArray()).trim();
}
}
代码示例来源:origin: wildfly-extras/wildfly-camel
public static String compactXML(InputStream input) throws Exception {
Document doc = new SAXBuilder().build(input);
XMLOutputter xo = new XMLOutputter();
xo.setFormat(Format.getCompactFormat().setOmitDeclaration(true));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xo.output(doc, baos);
return new String(baos.toByteArray()).trim();
}
}
代码示例来源:origin: com.mockrunner/mockrunner-jdbc
protected XMLOutputter createJDOMXMLCompareOutputter()
{
Format format = Format.getCompactFormat();
format.setOmitDeclaration(true);
format.setOmitEncoding(true);
return new XMLOutputter(format);
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
public static boolean login(HTTPUtils connection, String serviceURL, String username, String password) {
Element request = new Element("request");
request.addContent(new Element("username").setText(username));
request.addContent(new Element("password").setText(password));
XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String xml = outputter.outputString(request);
String loginURL = serviceURL+"/srv/en/xml.user.login";
String out = connection.postXml(loginURL, xml);
return connection.getLastHttpStatus() == HttpStatus.SC_OK;
}
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPost(HTTPUtils connection, String serviceURL, final Element gnRequest) {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String s = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
String res = connection.postXml(serviceURL, s);
// if(LOGGER.isInfoEnabled())
// LOGGER.info(serviceURL + " returned --> " + res);
return res;
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPost(HTTPUtils connection, String serviceURL, final Element gnRequest) {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String xmlReq = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
return connection.postXml(serviceURL, xmlReq);
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPut(HTTPUtils connection, String serviceURL, final Element gnRequest) {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String s = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
String res = connection.postXml(serviceURL, s);
// if(LOGGER.isInfoEnabled())
// LOGGER.info(serviceURL + " returned --> " + res);
return res;
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPost(HTTPUtils connection, String serviceURL, final Element gnRequest) throws GNLibException, GNServerException {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String s = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
String res = connection.postXml(serviceURL, s);
// if(LOGGER.isInfoEnabled())
// LOGGER.info(serviceURL + " returned --> " + res);
return res;
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPost(HTTPUtils connection, String serviceURL, final Element gnRequest) {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String xmlReq = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
return connection.postXml(serviceURL, xmlReq);
}
代码示例来源:origin: it.geosolutions/geonetwork-manager
private static String gnPut(HTTPUtils connection, String serviceURL, final Element gnRequest) throws GNLibException, GNServerException {
final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String s = outputter.outputString(gnRequest);
connection.setIgnoreResponseContentOnSuccess(false);
String res = connection.postXml(serviceURL, s);
// if(LOGGER.isInfoEnabled())
// LOGGER.info(serviceURL + " returned --> " + res);
return res;
}
代码示例来源:origin: DSpace/DSpace
protected DataCiteResponse sendMetadataPostRequest(String doi, Element metadataRoot)
throws DOIIdentifierException {
Format format = Format.getCompactFormat();
format.setEncoding("UTF-8");
XMLOutputter xout = new XMLOutputter(format);
return sendMetadataPostRequest(doi, xout.outputString(new Document(metadataRoot)));
}
代码示例来源:origin: rome/rome
/**
* 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);
}
代码示例来源:origin: rome/rome
/**
* 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);
}
代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication
/**
* 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);
}
代码示例来源:origin: org.compass-project/compass
/**
* Converts the {@link org.compass.core.xml.XmlObject} (assumes it is a {@link org.compass.core.xml.jdom.JDomXmlObject}) into
* an xml string. Uses JDOM <code>XmlOutputter</code> and <code>Format</code>
* (in a compact mode) to perform it.
*
* @param xmlObject The xml object to convert into an xml string (must be a {@link org.compass.core.xml.jdom.JDomXmlObject} implementation).
* @return An xml string representation of the xml object
* @throws org.compass.core.converter.ConversionException
* Should not really happne...
*/
public String toXml(XmlObject xmlObject) throws ConversionException {
JDomXmlObject jDomXmlObject = (JDomXmlObject) xmlObject;
XMLOutputter outp = new XMLOutputter();
if (compact) {
outp.setFormat(Format.getCompactFormat());
}
StringBuilderWriter stringWriter = StringBuilderWriter.Cached.cached();
try {
outp.output(jDomXmlObject.getElement(), stringWriter);
} catch (IOException e) {
throw new ConversionException("This should not happen", e);
}
return stringWriter.toString();
}
}
内容来源于网络,如有侵权,请联系作者删除!