当前位置: 首页>>代码示例>>Java>>正文


Java JsonWriter.beginObject方法代码示例

本文整理汇总了Java中org.sonar.api.utils.text.JsonWriter.beginObject方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.beginObject方法的具体用法?Java JsonWriter.beginObject怎么用?Java JsonWriter.beginObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.utils.text.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.beginObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeIssues

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
private void writeIssues(JsonWriter json) {
  json.name("issues");
  json.beginArray();
  for (Issue issue : analyzerResult.issues()) {
    json.beginObject();
    json.prop("rule", issue.getRuleKey());
    json.prop("severity", issue.getSeverity());
    json.prop("message", issue.getMessage());
    json.prop("type", issue.getType());

    json.name("textRange")
      .beginObject()
      .prop("startLine", issue.getStartLine())
      .prop("endLine", issue.getEndLine())
      .prop("startOffset", issue.getStartLineOffset())
      .prop("endOffset", issue.getEndLineOffset())
      .endObject();

    json.endObject();
  }
  json.endArray();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:23,代码来源:ResponseMessage.java

示例2: writeSymbolRefs

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
private void writeSymbolRefs(JsonWriter json) {
  json.name("symbolRefs");
  json.beginArray();
  for (Map.Entry<TextRange, Set<TextRange>> entry : analyzerResult.symbolRefs().entrySet()) {
    json.beginObject();

    json.name("symbol").beginObject();
    appendRange(json, entry.getKey());
    json.endObject();

    json.name("locations").beginArray();
    for (TextRange range : entry.getValue()) {
      json.beginObject();
      appendRange(json, range);
      json.endObject();
    }
    json.endArray();

    json.endObject();
  }
  json.endArray();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:23,代码来源:ResponseMessage.java

示例3: writeIssue

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
private void writeIssue(final JsonWriter writer, final Issue issue, List<Component> components) {
	writer.beginObject();

	final IssueKey key = IssueKey.fromIssue(issue, components);
	key.write(writer);

	final IssueData data = IssueData.fromIssue(issue);
	data.write(writer);

	writer.endObject();
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:12,代码来源:ExportAction.java

示例4: write

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
public void write(final JsonWriter writer) {
	writer.beginObject();
	writer.prop("preview", preview);
	writer.prop("issues", issues);
	writer.prop("duplicateKeys", duplicateKeys);
	writer.prop("matchedIssues", matchedIssues);
	writer.name("matchFailures");
	writer.beginArray();
	writer.values(matchFailures);
	writer.endArray();		
	writer.prop("transitionedIssues", transitionedIssues);
	writer.name("transitionFailures");
	writer.beginArray();
	writer.values(transitionFailures);
	writer.endArray();
	writer.prop("assignedIssues", assignedIssues);
	writer.name("assignFailures");
	writer.beginArray();
	writer.values(assignFailures);
	writer.endArray();
	writer.prop("commentedIssues", commentedIssues);
	writer.name("commentFailures");
	writer.beginArray();
	writer.values(commentFailures);
	writer.endArray();
	writer.endObject();
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:28,代码来源:ImportResult.java

示例5: test

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	final Issue issue = ReflectionTestUtils.build(Issue.class, "status_", "RESOLVED", "resolution_", "FALSE-POSITIVE",
			"assignee_", "admin", "comments_",
			ReflectionTestUtils.build(Comments.class, "comments_",
					Arrays.asList(ReflectionTestUtils.build(Comment.class, "markdown_", "Comment one"),
							ReflectionTestUtils.build(Comment.class, "markdown_", "Comment two"))));

	final IssueData data = IssueData.fromIssue(issue);
	Assert.assertEquals("RESOLVED", data.getStatus());
	Assert.assertEquals("FALSE-POSITIVE", data.getResolution());
	Assert.assertEquals("admin", data.getAssignee());
	Assert.assertEquals(Arrays.asList("Comment one", "Comment two"), data.getComments());

	final String json;
	try (final StringWriter writer = new StringWriter()) {
		final JsonWriter jsonWriter = JsonWriter.of(writer);
		jsonWriter.beginObject();
		data.write(jsonWriter);
		jsonWriter.endObject();
		jsonWriter.close();

		json = writer.toString();
	}
	Assert.assertEquals("{\"status\":\"RESOLVED\",\"resolution\":\"FALSE-POSITIVE\",\"assignee\":\"admin\",\"comments\":[\"Comment one\",\"Comment two\"]}", json);

	final IssueData readData;
	try (final ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes("UTF-8"));
			final JsonReader reader = new JsonReader(bais)) {
		reader.beginObject();
		readData = IssueData.read(reader);
		reader.endObject();
	}
	
	Assert.assertEquals("RESOLVED", readData.getStatus());
	Assert.assertEquals("FALSE-POSITIVE", readData.getResolution());
	Assert.assertEquals("admin", readData.getAssignee());
	Assert.assertEquals(Arrays.asList("Comment one", "Comment two"), readData.getComments());
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:40,代码来源:IssueDataTest.java

示例6: test

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	final Issue issue = ReflectionTestUtils.build(Issue.class, "rule_", "test:rule001", "component_",
			"nl.future-edge.sonarqube.plugins:sonar-issueresolver-plugin:src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java",
			"textRange_", ReflectionTestUtils.build(TextRange.class, "startLine_", 13, "startOffset_", 65));
	final Component component = ReflectionTestUtils.build(Component.class, "key_", "nl.future-edge.sonarqube.plugins:sonar-issueresolver-plugin:src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java",
		"longName_", "src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java");
	final List<Component> components = Arrays.asList(component);

	final IssueKey key = IssueKey.fromIssue(issue, components);

	final String json;
	try (final StringWriter writer = new StringWriter()) {
		final JsonWriter jsonWriter = JsonWriter.of(writer);
		jsonWriter.beginObject();
		key.write(jsonWriter);
		jsonWriter.endObject();
		jsonWriter.close();

		json = writer.toString();
	}
	Assert.assertEquals(
			"{\"longName\":\"src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java\",\"rule\":\"test:rule001\",\"line\":13}",
			json);

	final IssueKey readKey;
	try (final ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes("UTF-8"));
			final JsonReader reader = new JsonReader(bais)) {
		reader.beginObject();
		readKey = IssueKey.read(reader);
		reader.endObject();
	}

	Assert.assertEquals(key.hashCode(), readKey.hashCode());
	Assert.assertEquals(key, readKey);
	Assert.assertFalse(key.equals(null));
	Assert.assertTrue(key.equals(key));
	Assert.assertFalse(key.equals(new Object()));
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:40,代码来源:IssueKeyTest.java

示例7: writeStart

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
private void writeStart(final JsonWriter writer) {
	writer.beginObject();
	writer.prop("version", 1);
	writer.name("issues");
	writer.beginArray();
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:7,代码来源:ExportAction.java


注:本文中的org.sonar.api.utils.text.JsonWriter.beginObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。