org.jdom2.output.Format.getPrettyFormat()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(275)

本文整理了Java中org.jdom2.output.Format.getPrettyFormat()方法的一些代码示例,展示了Format.getPrettyFormat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.getPrettyFormat()方法的具体详情如下:
包路径:org.jdom2.output.Format
类名称:Format
方法名:getPrettyFormat

Format.getPrettyFormat介绍

[英]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.
[中]返回一个新的Format对象,该对象使用两个空格缩进执行空格美化,使用UTF-8编码,不展开空元素,包括声明和编码,并使用默认的实体转义策略。可以对返回的格式实例进行调整,而不会影响其他实例。

代码示例

代码示例来源:origin: simpligility/android-maven-plugin

  1. public void modifyOutputStream( JarOutputStream jos )
  2. throws IOException
  3. {
  4. jos.putNextEntry( new JarEntry( resource ) );
  5. new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos );
  6. doc = null;
  7. }
  8. }

代码示例来源:origin: gocd/gocd

  1. private static XMLOutputter xmlOutputer() {
  2. Format format = Format.getPrettyFormat().setEncoding("utf-8").setLineSeparator("\n");
  3. return new XMLOutputter(format);
  4. }

代码示例来源:origin: org.apache.maven.plugins/maven-shade-plugin

  1. public void modifyOutputStream( JarOutputStream jos )
  2. throws IOException
  3. {
  4. jos.putNextEntry( new JarEntry( resource ) );
  5. new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos );
  6. doc = null;
  7. }
  8. }

代码示例来源:origin: edu.ucar/netcdf

  1. void showDoc(java.io.OutputStream out) {
  2. XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
  3. try {
  4. fmt.output(doc, out);
  5. } catch (IOException e) {
  6. e.printStackTrace();
  7. }
  8. }

代码示例来源:origin: Unidata/thredds

  1. /**
  2. * Write the information as an XML document
  3. *
  4. * @param doc write XML for this Document
  5. * @param os write to this output stream
  6. * @throws java.io.IOException on write error
  7. */
  8. public void writeXML(Document doc, OutputStream os) throws IOException {
  9. XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
  10. fmt.output(doc, os);
  11. }

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

  1. /**
  2. * Serializes the Element to a String. If <tt>pretty</tt> is true,
  3. * uses a pretty whitespace format, otherwise a compact format.
  4. *
  5. * @param element the element to serialize.
  6. * @param pretty if true, use a pretty whitespace format.
  7. * @return the serialized Element.
  8. */
  9. public static String serialize( Element element, boolean pretty ) {
  10. return serialize( element,pretty ? Format.getPrettyFormat() : Format.getCompactFormat() );
  11. }

代码示例来源:origin: edu.ucar/netcdf

  1. public void writeExceptionReport( PrintWriter pw )
  2. throws IOException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( Format.getPrettyFormat() );
  5. xmlOutputter.output( exceptionReport, pw);
  6. }
  7. }

代码示例来源:origin: pwm-project/pwm

  1. public static void outputDocument( final Document document, final OutputStream outputStream )
  2. throws IOException
  3. {
  4. final Format format = Format.getPrettyFormat();
  5. format.setEncoding( STORAGE_CHARSET.toString() );
  6. final XMLOutputter outputter = new XMLOutputter();
  7. outputter.setFormat( format );
  8. try ( Writer writer = new OutputStreamWriter( outputStream, STORAGE_CHARSET ) )
  9. {
  10. outputter.output( document, writer );
  11. }
  12. }

代码示例来源:origin: dqeasycloud/easy-cloud

  1. private void doXmlOutputter(Document doc, File xmlFile) throws IOException {
  2. Format format = Format.getPrettyFormat();
  3. format.setIndent(" ");
  4. format.setEncoding("UTF-8");
  5. XMLOutputter out = new XMLOutputter(format);
  6. out.output(doc, new FileWriter(xmlFile)); // 写文件
  7. }

代码示例来源:origin: edu.ucar/netcdf

  1. public void writeCapabilitiesReport( PrintWriter pw )
  2. throws WcsException, IOException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( org.jdom2.output.Format.getPrettyFormat() );
  5. xmlOutputter.output( getCapabilitiesReport(), pw );
  6. }

代码示例来源:origin: edu.ucar/netcdf

  1. /**
  2. * Write stationObsDataset XML document
  3. */
  4. public String writeStationObsDatasetXML() {
  5. XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
  6. return fmt.outputString(makeStationObsDatasetDocument());
  7. }

代码示例来源:origin: edu.ucar/netcdf

  1. public static void writeCoordRefSysAsGML( PrintWriter pw, ucar.nc2.dataset.CoordinateSystem coordSys )
  2. throws IOException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( org.jdom2.output.Format.getPrettyFormat() );
  5. xmlOutputter.output( genCoordRefSysAsGML( coordSys), pw );
  6. }

代码示例来源:origin: edu.ucar/netcdf

  1. /**
  2. * Write the XML representaion to an OutputStream.
  3. *
  4. * @param out write to this OutputStream
  5. * @throws IOException on io error
  6. */
  7. public void writeXML(OutputStream out) throws IOException {
  8. XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
  9. fmt.output(writeDocument(), out);
  10. }

代码示例来源:origin: edu.ucar/netcdf

  1. public void writeCapabilitiesReport( PrintWriter pw )
  2. throws WcsException, IOException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( org.jdom2.output.Format.getPrettyFormat() );
  5. xmlOutputter.output( getCapabilitiesReport(), pw );
  6. }

代码示例来源:origin: edu.ucar/netcdf

  1. public String writeCapabilitiesReportAsString()
  2. throws WcsException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( org.jdom2.output.Format.getPrettyFormat() );
  5. return xmlOutputter.outputString( getCapabilitiesReport() );
  6. }

代码示例来源:origin: edu.ucar/netcdf

  1. public void writeGetCoverageDoc( PrintWriter pw )
  2. throws IOException
  3. {
  4. XMLOutputter xmlOutputter = new XMLOutputter( Format.getPrettyFormat() );
  5. xmlOutputter.output( getGetCoverageDoc(), pw );
  6. }

代码示例来源:origin: eu.fbk.pikes/pikes-naflib

  1. /**
  2. * Returns a string containing the XML content of a KAFDocument object.
  3. */
  4. static String kafToStr(KAFDocument kaf) {
  5. XMLOutputter out = new XMLOutputter(Format.getPrettyFormat().setLineSeparator(LineSeparator.UNIX));
  6. // out.getFormat().setTextMode(Format.TextMode.PRESERVE);
  7. Document jdom = KAFToDOM(kaf);
  8. return out.outputString(jdom);
  9. }

代码示例来源:origin: edu.ucar/cdm

  1. private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
  2. Element rootElem = new Element("dc", defNS);
  3. Document doc = new Document(rootElem);
  4. writeDataset( ds, rootElem);
  5. rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
  6. // rootElem.setAttribute("schemaLocation", schemaLocation, XMLEntityResolver.xsiNS);
  7. rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
  8. // Output the document, use standard formatter
  9. //XMLOutputter fmt = new XMLOutputter(" ", true);
  10. XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
  11. fmt.output( doc, out);
  12. }

代码示例来源:origin: edu.ucar/netcdf

  1. private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
  2. Element rootElem = new Element("dc", defNS);
  3. Document doc = new Document(rootElem);
  4. writeDataset( ds, rootElem);
  5. rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
  6. // rootElem.setAttribute("schemaLocation", schemaLocation, XMLEntityResolver.xsiNS);
  7. rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
  8. // Output the document, use standard formatter
  9. //XMLOutputter fmt = new XMLOutputter(" ", true);
  10. XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
  11. fmt.output( doc, out);
  12. }

代码示例来源:origin: edu.ucar/cdm

  1. private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
  2. Element rootElem = new Element("itemRecord", defNS);
  3. Document doc = new Document(rootElem);
  4. writeDataset( ds, rootElem);
  5. rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
  6. // rootElem.setAttribute("schemaLocation", schemaLocationLocal, XMLEntityResolver.xsiNS);
  7. rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
  8. // Output the document, use standard formatter
  9. //XMLOutputter fmt = new XMLOutputter(" ", true);
  10. XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
  11. fmt.output( doc, out);
  12. }

相关文章