Package com.google.gwt.dev.json

Examples of com.google.gwt.dev.json.JsonObject


    logger.flush();
    BufferedReader jsonReader = extractJsonFromWriter(writer);

    int tally[] = new int[NUM_THREADS];
    for (int i = 0; i < MAX_EVENT_LOGS * NUM_THREADS; i++) {
      JsonObject result = null;
      try {
        result = JsonObject.parse(jsonReader).asObject();
      } catch (JsonException ex) {
        fail("Failed to parse json after " + i + " iterations.  "
            + ex.toString());
      }
      if (compareJsonToEvent(result, dummyOne)) {
        tally[0]++;
      } else if (compareJsonToEvent(result, dummyTwo)) {
        tally[1]++;
      } else if (compareJsonToEvent(result, dummyThree)) {
        tally[2]++;
      } else {
        fail("Node with typeName "
            + result.get("typeName").asString().getString()
            + " doesn't match expected");
      }
    }
    for (int i = 0; i < NUM_THREADS; i++) {
      assertEquals("dummy" + i + " has the wrong number of logs.", tally[i],
View Full Code Here


    logger.flush();

    // There should be no HTML in here
    String logString = writer.toString();
    BufferedReader jsonReader = new BufferedReader(new StringReader(logString));
    JsonObject dummyOneObject = JsonObject.parse(jsonReader).asObject();
    assertTrue(compareJsonToEvent(dummyOneObject, dummyOne));
    JsonArray children = dummyOneObject.get("children").asArray();
    assertEquals(1, children.getLength());
    JsonObject markTimelineObject = children.get(0).asObject();
    assertEquals(11.0, markTimelineObject.get("type").asNumber().getDecimal(), .001);
    JsonObject dataObject = markTimelineObject.get("data").asObject();
    assertEquals("json=" + logString, "Test Message",
        dataObject.get("message").asString().getString());
  }
View Full Code Here

    // There should be no HTML in here
    String logString = writer.toString();
    assertTrue(logString.trim().startsWith("{"));
    assertTrue(logString.trim().endsWith("}"));
    BufferedReader jsonReader = new BufferedReader(new StringReader(logString));
    JsonObject dummyOneObject = JsonObject.parse(jsonReader).asObject();
    assertTrue(compareJsonToEvent(dummyOneObject, dummyOne));
  }
View Full Code Here

          refEvent.processCpuStartTimeNanos + refEvent.processCpuDurationNanos;
      threadCpuStartTimeNanos = refEvent.threadCpuStartTimeNanos + refEvent.threadCpuDurationNanos;
    }

    JsonObject toJson() {
      JsonObject json = JsonObject.create();
      json.put("type", -2);
      json.put("typeName", type.getName());
      json.put("color", type.getColor());
      double startMs = convertToMilliseconds(getStartTimeNanos());
      json.put("time", startMs);
      double durationMs = convertToMilliseconds(getDurationNanos());
      json.put("duration", durationMs);

      JsonObject jsonData = JsonObject.create();
      for (int i = 0; i < data.size(); i += 2) {
        jsonData.put(data.get(i), data.get(i + 1));
      }
      json.put("data", jsonData);

      JsonArray jsonChildren = JsonArray.create();
      for (Event child : children) {
View Full Code Here

            break;
          } else if (event == flushSentinel) {
            writer.flush();
            flushLatch.countDown();
          } else {
            JsonObject json = event.toJson();
            json.write(writer);
            writer.write('\n');
          }
          if (System.currentTimeMillis() >= nextFlush) {
            writer.flush();
            nextFlush = System.currentTimeMillis() + FLUSH_TIMER_MSECS;
View Full Code Here

      }
    }

    @Override
    JsonObject toJson() {
      JsonObject json = JsonObject.create();
      json.put("type", 11);
      double startMs = convertToMilliseconds(getStartTimeNanos());
      json.put("time", startMs);
      json.put("duration", 0.0);
      JsonObject jsonData = JsonObject.create();
      for (int i = 0; i < data.size(); i += 2) {
        jsonData.put(data.get(i), data.get(i + 1));
      }
      json.put("data", jsonData);
      return json;
    }
View Full Code Here

      throws UnableToCompleteException {
    Set<String> sourceFiles = new LinkedHashSet<String>();
    for (EmittedArtifact map : sourceMaps) {
      // TODO maybe improve performance by not re-reading the sourcemap files.
      // (We'd need another way for SourceMapRecorder to pass the list of files here.)
      JsonObject json = loadSourceMap(logger, map);
      JsonArray sources = json.get("sources").asArray();
      for (int i = 0; i < sources.getLength(); i++) {
        sourceFiles.add(sources.get(i).asString().getString());
      }
    }
    return sourceFiles;
View Full Code Here

  /**
   * Reads a sourcemap as a JSON object.
   */
  private static JsonObject loadSourceMap(TreeLogger logger, EmittedArtifact sourceMap)
      throws UnableToCompleteException {
    JsonObject json;
    try {
      InputStream bytes = sourceMap.getContents(logger);
      try {
        json = JsonObject.parse(new InputStreamReader(bytes));
      } finally {
View Full Code Here

    public String toString() {
      return type.getName();
    }

    JsonObject toJson() {
      JsonObject json = JsonObject.create();
      json.put("type", -2);
      json.put("typeName", type.getName());
      json.put("color", type.getColor());
      double startMs = convertToMilliseconds(startTimeNanos);
      json.put("time", startMs);
      double durationMs = convertToMilliseconds(durationNanos);
      json.put("duration", durationMs);

      JsonObject jsonData = JsonObject.create();
      for (int i = 0; i < data.size(); i += 2) {
        jsonData.put(data.get(i), data.get(i + 1));
      }
      json.put("data", jsonData);

      JsonArray jsonChildren = JsonArray.create();
      for (Event child : children) {
View Full Code Here

            break;
          } else if (event == flushSentinel) {
            writer.flush();
            flushLatch.countDown();
          } else {
            JsonObject json = event.toJson();
            json.write(writer);
            writer.write('\n');
          }
          if (System.currentTimeMillis() >= nextFlush) {
            writer.flush();
            nextFlush = System.currentTimeMillis() + FLUSH_TIMER_MSECS;
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.json.JsonObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.