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

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

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

Format.getIndent介绍

[英]Returns the indent string in use.
[中]返回正在使用的缩进字符串。

代码示例

代码示例来源:origin: org.jdom/jdom

/**
 * Creates a new FormatStack seeded with the specified Format
 * 
 * @param format
 *        the Format instance to seed the stack with.
 */
public FormatStack(Format format) {
  indent = format.getIndent();
  lineSeparator = format.getLineSeparator();
  encoding = format.getEncoding();
  omitDeclaration = format.getOmitDeclaration();
  omitEncoding = format.getOmitEncoding();
  expandEmptyElements = format.getExpandEmptyElements();
  escapeStrategy = format.getEscapeStrategy();
  defaultMode = format.getTextMode();
  specifiedAttributesOnly = format.isSpecifiedAttributesOnly();
  levelIndent[depth] = format.getIndent() == null
      ? null : "";
  levelEOL[depth] = format.getLineSeparator();
  levelEOLIndent[depth] = levelIndent[depth] == null ?  
      null : levelEOL[depth];
  termEOLIndent[depth] = levelEOLIndent[depth];
  
  ignoreTrAXEscapingPIs[depth] = format.getIgnoreTrAXEscapingPIs();
  mode[depth] = format.getTextMode();
  escapeOutput[depth] = true;
}

代码示例来源:origin: org.opencadc/cadc-util

private void indent(PrintWriter pw, int amt)
  {
    
    if (fmt != null)
    {
      pw.print(fmt.getLineSeparator());
      for (int i=0; i<amt; i++)
        pw.print(fmt.getIndent());
    }
    else
      pw.print(" ");
  }
}

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

static public void prettyPrint() throws IOException {
 org.jdom2.Document doc;
 try {
  SAXBuilder builder = new SAXBuilder();
  doc = builder.build("C:/docs/bufr/wmo/Code-FlagTables-11-2007.xml");
  Format pretty = Format.getPrettyFormat();
  String sep = pretty.getLineSeparator();
  String ind = pretty.getIndent();
  String mine = "\r\n";
  pretty.setLineSeparator(mine);
  // wierd - cant pretty print ??!!
  XMLOutputter fmt = new XMLOutputter(pretty);
  Writer pw = new FileWriter("C:/docs/bufr/wmo/wordNice.txt");
  fmt.output(doc, pw);
 } catch (JDOMException e) {
  throw new IOException(e.getMessage());
 }
}

相关文章