gpt4 book ai didi

com.puppycrawl.tools.checkstyle.XMLLogger.encode()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 21:41:40 26 4
gpt4 key购买 nike

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

XMLLogger.encode介绍

[英]Escape <, > & ' and " as their entities.
[中]逃逸<>&“和”作为他们的实体。

代码示例

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

/**
 * Prints the "file" opening tag with the given filename.
 * @param fileName The filename to output.
 */
private void writeFileOpeningTag(String fileName) {
  writer.println("<file name=\"" + encode(fileName) + "\">");
}

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

/**
 * Writes the exception event to the print writer.
 * @param throwable The
 */
private void writeException(Throwable throwable) {
  writer.println("<exception>");
  writer.println("<![CDATA[");
  final StringWriter stringWriter = new StringWriter();
  final PrintWriter printer = new PrintWriter(stringWriter);
  throwable.printStackTrace(printer);
  writer.println(encode(stringWriter.toString()));
  writer.println("]]>");
  writer.println("</exception>");
}

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

/**
 * Outputs the given event to the writer.
 * @param event An event to print.
 */
private void writeFileError(AuditEvent event) {
  writer.print("<error" + " line=\"" + event.getLine() + "\"");
  if (event.getColumn() > 0) {
    writer.print(" column=\"" + event.getColumn() + "\"");
  }
  writer.print(" severity=\""
      + event.getSeverityLevel().getName()
      + "\"");
  writer.print(" message=\""
      + encode(event.getMessage())
      + "\"");
  writer.print(" source=\"");
  if (event.getModuleId() == null) {
    writer.print(encode(event.getSourceName()));
  }
  else {
    writer.print(encode(event.getModuleId()));
  }
  writer.println("\"/>");
}

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

@Test
public void testEncode()
    throws IOException {
  final XMLLogger test = new XMLLogger(outStream, false);
  assertNotNull("should be able to create XMLLogger without issue", test);
  final String[][] encodings = {
    {"<", "&lt;"},
    {">", "&gt;"},
    {"'", "&apos;"},
    {"\"", "&quot;"},
    {"&", "&amp;"},
    {"&lt;", "&amp;lt;"},
    {"abc;", "abc;"},
    {"&#0;", "&amp;#0;"},
    {"&#0", "&amp;#0"},
    {"&#X0;", "&amp;#X0;"},
    {"\u0001", "#x1;"},
    {"\u0080", "#x80;"},
  };
  for (String[] encoding : encodings) {
    final String encoded = XMLLogger.encode(encoding[0]);
    assertEquals("\"" + encoding[0] + "\"", encoding[1], encoded);
  }
  outStream.close();
}

代码示例来源:origin: com.puppycrawl.tools/checkstyle

/**
 * Prints the "file" opening tag with the given filename.
 * @param fileName The filename to output.
 */
private void writeFileOpeningTag(String fileName) {
  writer.println("<file name=\"" + encode(fileName) + "\">");
}

代码示例来源:origin: com.puppycrawl.tools/checkstyle

/**
 * Writes the exception event to the print writer.
 * @param throwable The
 */
private void writeException(Throwable throwable) {
  writer.println("<exception>");
  writer.println("<![CDATA[");
  final StringWriter stringWriter = new StringWriter();
  final PrintWriter printer = new PrintWriter(stringWriter);
  throwable.printStackTrace(printer);
  writer.println(encode(stringWriter.toString()));
  writer.println("]]>");
  writer.println("</exception>");
}

代码示例来源:origin: com.puppycrawl.tools/checkstyle

/**
 * Outputs the given event to the writer.
 * @param event An event to print.
 */
private void writeFileError(AuditEvent event) {
  writer.print("<error" + " line=\"" + event.getLine() + "\"");
  if (event.getColumn() > 0) {
    writer.print(" column=\"" + event.getColumn() + "\"");
  }
  writer.print(" severity=\""
      + event.getSeverityLevel().getName()
      + "\"");
  writer.print(" message=\""
      + encode(event.getMessage())
      + "\"");
  writer.print(" source=\"");
  if (event.getModuleId() == null) {
    writer.print(encode(event.getSourceName()));
  }
  else {
    writer.print(encode(event.getModuleId()));
  }
  writer.println("\"/>");
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com