gpt4 book ai didi

org.sonar.api.utils.text.XmlWriter类的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 02:57:05 27 4
gpt4 key购买 nike

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

XmlWriter介绍

[英]TODO document that output is UTF-8
[中]TODO文件输出为UTF-8

代码示例

代码示例来源:origin: SonarSource/sonarqube

public XmlWriter prop(String nodeName, boolean value) {
 return begin(nodeName).value(value).end();
}

代码示例来源:origin: SonarSource/sonarqube

public static XmlWriter of(Writer writer) {
 return new XmlWriter(writer);
}

代码示例来源:origin: SonarSource/sonarqube

private void writeXml(DbSession dbSession, Writer writer, QProfileDto profile, Iterator<OrgActiveRuleDto> activeRules) {
 XmlWriter xml = XmlWriter.of(writer).declaration();
 xml.begin(ATTRIBUTE_PROFILE);
 xml.prop(ATTRIBUTE_NAME, profile.getName());
 xml.prop(ATTRIBUTE_LANGUAGE, profile.getLanguage());
 xml.begin(ATTRIBUTE_RULES);
 while (activeRules.hasNext()) {
  ActiveRuleDto activeRule = activeRules.next();
  xml.begin(ATTRIBUTE_RULE);
  xml.prop(ATTRIBUTE_REPOSITORY_KEY, activeRule.getRuleKey().repository());
  xml.prop(ATTRIBUTE_KEY, activeRule.getRuleKey().rule());
  xml.prop(ATTRIBUTE_PRIORITY, activeRule.getSeverityString());
  xml.begin(ATTRIBUTE_PARAMETERS);
  for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRule.getId())) {
   xml
    .begin(ATTRIBUTE_PARAMETER)
    .prop(ATTRIBUTE_PARAMETER_KEY, param.getKey())
    .prop(ATTRIBUTE_PARAMETER_VALUE, param.getValue())
    .end();
  }
  xml.end(ATTRIBUTE_PARAMETERS);
  xml.end(ATTRIBUTE_RULE);
 }
 xml.end(ATTRIBUTE_RULES).end(ATTRIBUTE_PROFILE).close();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void ignore_null_values() {
 writer.begin("root")
  .prop("nullNumber", (Number) null)
  .prop("nullString", (String) null)
  .end().close();
 expect("<root/>");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void declaration() {
 writer.declaration().begin("foo").end().close();
 expect("<?xml version='1.0' encoding='UTF-8'?><foo/>");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void end_with_unused_parameter() {
 writer.begin("foo").end("foo").close();
 expect("<foo/>");
}

代码示例来源:origin: SonarSource/sonarqube

public XmlWriter declaration() {
 try {
  stream.writeStartDocument();
  return this;
 } catch (XMLStreamException e) {
  throw rethrow(e);
 }
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Same as {@link #end()}. The parameter is unused. It's declared only to improve
 * readability :
 * <pre>
 *   xml.write("rules");
 *   xml.write("rule");
 *   // many other writes
 *   xml.end("rule");
 *   xml.end("rules");
 * </pre>
 */
public XmlWriter end(String unused) {
 return end();
}

代码示例来源:origin: stackoverflow.com

XmlWriter writer = new XmlWriter();
writer.writeHeader();
for (Item item : xmlitems) {
  writer.write(convert(item));
}
writer.close();

代码示例来源:origin: SonarSource/sonarqube

@Test
public void only_root_with_value() {
 writer.prop("foo", "bar").close();
 expect("<foo>bar</foo>");
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public XmlWriter newXmlWriter() {
 stream.setMediaType(MediaTypes.XML);
 return XmlWriter.of(new OutputStreamWriter(output, StandardCharsets.UTF_8));
}

代码示例来源:origin: stackoverflow.com

XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outstream, "UTF-8"));
entry.generate(xmlWriter, ep);
xmlWriter.flush();

代码示例来源:origin: stackoverflow.com

public void testSomething()
{
 Writer sw = new StringWriter();
 XmlWriter xw = new XmlWriter(sw);
 ...
 xw.writeString("foo");
 ...
 assertEquals("...<aTag>foo</aTag>...", sw.toString());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void fail_on_NaN_value() {
  thrown.expect(WriterException.class);
  thrown.expectMessage("Fail to write XML. Double value is not valid: NaN");
  writer.begin("root").prop("foo", Double.NaN).end().close();
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void only_root() {
 writer.begin("foo").end().close();
 expect("<foo/>");
}

代码示例来源:origin: SonarSource/sonarqube

public XmlWriter begin(String nodeName) {
 try {
  stream.writeStartElement(nodeName);
  return this;
 } catch (XMLStreamException e) {
  throw rethrow(e);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

/**
 * Same as {@link #end()}. The parameter is unused. It's declared only to improve
 * readability :
 * <pre>
 *   xml.write("rules");
 *   xml.write("rule");
 *   // many other writes
 *   xml.end("rule");
 *   xml.end("rules");
 * </pre>
 */
public XmlWriter end(String unused) {
 return end();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void escape_value() {
 writer.prop("foo", "1<2 & 2>=2").close();
 expect("<foo>1&lt;2 &amp; 2>=2</foo>");
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public XmlWriter newXmlWriter() {
 stream.setMediaType(XML);
 return XmlWriter.of(new OutputStreamWriter(stream.output(), UTF_8));
}

代码示例来源:origin: stackoverflow.com

XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outstream, "UTF-8"));
entry.generate(xmlWriter, ep);
xmlWriter.flush();

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