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

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

本文整理了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

public void modifyOutputStream( JarOutputStream jos )
      throws IOException
  {
    jos.putNextEntry( new JarEntry( resource ) );

    new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos );

    doc = null;
  }
}

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

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

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

public void modifyOutputStream( JarOutputStream jos )
    throws IOException
  {
    jos.putNextEntry( new JarEntry( resource ) );

    new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos );

    doc = null;
  }
}

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

void showDoc(java.io.OutputStream out) {
 XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
 try {
  fmt.output(doc, out);
 } catch (IOException e) {
  e.printStackTrace();
 }
}

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

/**
 * Write the information as an XML document
 *
 * @param doc write XML for this Document
 * @param os  write to this output stream
 * @throws java.io.IOException on write error
 */
public void writeXML(Document doc, OutputStream os) throws IOException {
  XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
  fmt.output(doc, os);
}

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

/**
 *  Serializes the Element to a String. If <tt>pretty</tt> is true,
 *  uses a pretty whitespace format, otherwise a compact format.
 *
 * @param element  the element to serialize.
 * @param pretty   if true, use a pretty whitespace format.
 * @return the serialized Element.
 */
public static String serialize( Element element, boolean pretty ) {
  return serialize( element,pretty ? Format.getPrettyFormat() : Format.getCompactFormat() );
}

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

public void writeExceptionReport( PrintWriter pw )
     throws IOException
 {
  XMLOutputter xmlOutputter = new XMLOutputter( Format.getPrettyFormat() );
  xmlOutputter.output( exceptionReport, pw);
 }
}

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

public static void outputDocument( final Document document, final OutputStream outputStream )
    throws IOException
{
  final Format format = Format.getPrettyFormat();
  format.setEncoding( STORAGE_CHARSET.toString() );
  final XMLOutputter outputter = new XMLOutputter();
  outputter.setFormat( format );
  try ( Writer writer = new OutputStreamWriter( outputStream, STORAGE_CHARSET ) )
  {
    outputter.output( document, writer );
  }
}

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

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

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

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

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

/**
 * Write stationObsDataset XML document
 */
public String writeStationObsDatasetXML() {
 XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
 return fmt.outputString(makeStationObsDatasetDocument());
}

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

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

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

/**
 * Write the XML representaion to an OutputStream.
 *
 * @param out write to this OutputStream
 * @throws IOException on io error
 */
public void writeXML(OutputStream out) throws IOException {
 XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
 fmt.output(writeDocument(), out);
}

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

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

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

public String writeCapabilitiesReportAsString()
    throws WcsException
{
 XMLOutputter xmlOutputter = new XMLOutputter( org.jdom2.output.Format.getPrettyFormat() );
 return xmlOutputter.outputString( getCapabilitiesReport() );
}

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

public void writeGetCoverageDoc( PrintWriter pw )
    throws IOException
{
 XMLOutputter xmlOutputter = new XMLOutputter( Format.getPrettyFormat() );
 xmlOutputter.output( getGetCoverageDoc(), pw );
}

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

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

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

private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
 Element rootElem = new Element("dc", defNS);
 Document doc = new Document(rootElem);
 writeDataset( ds, rootElem);
 rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
 // rootElem.setAttribute("schemaLocation", schemaLocation, XMLEntityResolver.xsiNS);
 rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
 // Output the document, use standard formatter
 //XMLOutputter fmt = new XMLOutputter("  ", true);
 XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
 fmt.output( doc, out);
}

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

private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
 Element rootElem = new Element("dc", defNS);
 Document doc = new Document(rootElem);
 writeDataset( ds, rootElem);
 rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
 // rootElem.setAttribute("schemaLocation", schemaLocation, XMLEntityResolver.xsiNS);
 rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
 // Output the document, use standard formatter
 //XMLOutputter fmt = new XMLOutputter("  ", true);
 XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
 fmt.output( doc, out);
}

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

private void writeOneItem( InvDataset ds, OutputStream out) throws IOException {
 Element rootElem = new Element("itemRecord", defNS);
 Document doc = new Document(rootElem);
 writeDataset( ds, rootElem);
 rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS);
 // rootElem.setAttribute("schemaLocation", schemaLocationLocal, XMLEntityResolver.xsiNS);
 rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS);
 // Output the document, use standard formatter
 //XMLOutputter fmt = new XMLOutputter("  ", true);
 XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat());
 fmt.output( doc, out);
}

相关文章