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

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

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

  1. /**
  2. * Creates a new FormatStack seeded with the specified Format
  3. *
  4. * @param format
  5. * the Format instance to seed the stack with.
  6. */
  7. public FormatStack(Format format) {
  8. indent = format.getIndent();
  9. lineSeparator = format.getLineSeparator();
  10. encoding = format.getEncoding();
  11. omitDeclaration = format.getOmitDeclaration();
  12. omitEncoding = format.getOmitEncoding();
  13. expandEmptyElements = format.getExpandEmptyElements();
  14. escapeStrategy = format.getEscapeStrategy();
  15. defaultMode = format.getTextMode();
  16. specifiedAttributesOnly = format.isSpecifiedAttributesOnly();
  17. levelIndent[depth] = format.getIndent() == null
  18. ? null : "";
  19. levelEOL[depth] = format.getLineSeparator();
  20. levelEOLIndent[depth] = levelIndent[depth] == null ?
  21. null : levelEOL[depth];
  22. termEOLIndent[depth] = levelEOLIndent[depth];
  23. ignoreTrAXEscapingPIs[depth] = format.getIgnoreTrAXEscapingPIs();
  24. mode[depth] = format.getTextMode();
  25. escapeOutput[depth] = true;
  26. }

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

  1. private void indent(PrintWriter pw, int amt)
  2. {
  3. if (fmt != null)
  4. {
  5. pw.print(fmt.getLineSeparator());
  6. for (int i=0; i<amt; i++)
  7. pw.print(fmt.getIndent());
  8. }
  9. else
  10. pw.print(" ");
  11. }
  12. }

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

  1. static public void prettyPrint() throws IOException {
  2. org.jdom2.Document doc;
  3. try {
  4. SAXBuilder builder = new SAXBuilder();
  5. doc = builder.build("C:/docs/bufr/wmo/Code-FlagTables-11-2007.xml");
  6. Format pretty = Format.getPrettyFormat();
  7. String sep = pretty.getLineSeparator();
  8. String ind = pretty.getIndent();
  9. String mine = "\r\n";
  10. pretty.setLineSeparator(mine);
  11. // wierd - cant pretty print ??!!
  12. XMLOutputter fmt = new XMLOutputter(pretty);
  13. Writer pw = new FileWriter("C:/docs/bufr/wmo/wordNice.txt");
  14. fmt.output(doc, pw);
  15. } catch (JDOMException e) {
  16. throw new IOException(e.getMessage());
  17. }
  18. }

相关文章