Package com.google.gwt.dev.json

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


      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) {
        jsonChildren.add(child.toJson());
      }
      json.put("children", jsonChildren);

      return json;
    }
View Full Code Here


  /**
   * Returns a sorted list of all the directories containing at least one filename
   * in the source map.
   */
  List<String> getSourceDirectories() {
    JsonArray sources = (JsonArray) json.get("sources");
    Set<String> directories = new HashSet<String>();
    for (int i = 0; i < sources.getLength(); i++) {
      String filename = sources.get(i).asString().getString();
      int lastSlashPos = filename.lastIndexOf('/');
      directories.add(lastSlashPos < 0 ? "" : filename.substring(0, lastSlashPos));
    }

    List<String> result = new ArrayList<String>();
View Full Code Here

  List<String> getSourceFilesInDirectory(String parent) {
    if (!parent.endsWith("/")) {
      throw new IllegalArgumentException("unexpected: " + parent);
    }

    JsonArray sources = (JsonArray) json.get("sources");

    List<String> result = new ArrayList<String>();
    for (int i = 0; i < sources.getLength(); i++) {
      String candidate = sources.get(i).asString().getString();
      if (!candidate.startsWith(parent)) {
        continue;
      }
      int nameStart = candidate.lastIndexOf('/') + 1;
      if (nameStart == parent.length()) {
View Full Code Here

   * Used in directorylist.html.
   */
  JsonObject exportSourceMapDirectoryListVars(Outbox box, SourceMap map) {
    JsonObject out = new JsonObject();
    out.put("moduleName", box.getOutputModuleName()); // TODO: rename
    JsonArray directories = new JsonArray();
    for (String name : map.getSourceDirectories()) {
      JsonObject dir = new JsonObject();
      dir.put("name", name);
      dir.put("link", name + "/");
      directories.add(dir);
    }
    out.put("directories", directories);
    return out;
  }
View Full Code Here

  JsonObject exportSourceMapFileListVars(Outbox box, SourceMap map,
      String directory) {
    JsonObject out = new JsonObject();
    out.put("moduleName", box.getOutputModuleName()); // TODO: rename
    out.put("directory", directory);
    JsonArray files = new JsonArray();
    for (String name : map.getSourceFilesInDirectory(directory)) {
      JsonObject file = new JsonObject();
      file.put("name", name);
      file.put("link", name + "?html");
      files.add(file);
    }
    out.put("files", files);
    return out;
  }
View Full Code Here

  }

  // === utility methods ===

  private JsonArray exportOutputModuleNames() {
    JsonArray moduleNames = new JsonArray();
    for (String module : outboxes.getOutputModuleNames()) {
      moduleNames.add(module);
    }
    return moduleNames;
  }
View Full Code Here

    }
    return moduleNames;
  }

  private JsonArray exportWarnings() {
    JsonArray out = new JsonArray();
    // Add warnings if any
    return out;
  }
View Full Code Here

   * Lists the files that the last successful GWT compiler generated in an outbox.
   */
  private JsonArray exportOutputFiles(Outbox box) {
    File[] files = new File(box.getWarDir(), box.getOutputModuleName()).listFiles();
    if (files == null) {
      return new JsonArray();
    }
    Arrays.sort(files);

    JsonArray result = new JsonArray();
    for (File file : files) {
      if (file.isFile()) {
        JsonObject map = new JsonObject();
        map.put("name", file.getName());
        map.put("link", file.getName());
        result.add(map);
      }
    }
    return result;
  }
View Full Code Here

    assertTrue("dummyOne", compareJsonToEvent(parsedObject, dummyOne));

    JsonObject dataObject = parsedObject.get("data").asObject();
    assertNotNull(dataObject);

    JsonArray childArray = parsedObject.get("children").asArray();
    assertNotNull(childArray);
    assertEquals(2, childArray.getLength());

    JsonObject child = childArray.get(0).asObject();
    assertTrue("dummyTwo", compareJsonToEvent(child, dummyTwo));

    child = childArray.get(1).asObject();
    assertTrue("dummyThree", compareJsonToEvent(child, dummyThree));
  }
View Full Code Here

    // 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

TOP

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

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.