Package com.google.json.serialization

Examples of com.google.json.serialization.JsonArray


      preOrderVisitor.visit(node);
    }

    JsonValue childNode = node.get("children");
    if (childNode != JsonValue.NULL) {
      JsonArray children = childNode.asArray();

      for (int i = 0, n = children.getLength(); i < n; i++) {
        traverseImpl(children.get(i).asObject(), preOrderVisitor,
            postOrderVisitor);
      }
    }

    if (postOrderVisitor != null) {
View Full Code Here


  private double traverseImpl(JsonObject node,
      JsonVisitorDouble postOrderVisitor) throws JsonException {
    List<Double> values = new ArrayList<Double>();
    JsonValue childNode = node.get("children");
    if (childNode != JsonValue.NULL) {
      JsonArray children = childNode.asArray();
      for (int i = 0, n = children.getLength(); i < n; i++) {
        values.add(traverseImpl(children.get(i).asObject(), postOrderVisitor));
      }
    }
    return postOrderVisitor.visit(node, values);
  }
View Full Code Here

  }

  public void testTraversePostorder() throws JsonException {
    JsonObject root = new JsonObject();
    root.put("value", 3);
    JsonArray children = new JsonArray();
    children.add(makeChild("value", 1));
    children.add(makeChild("value", 2));
    root.put("children", children);

    JsonTraverser.get().traversePostOrder(root, new JsonVisitor() {
      private long curr = 0;
View Full Code Here

  }

  public void testTraversePreorder() throws JsonException {
    JsonObject root = new JsonObject();
    root.put("value", 1);
    JsonArray children = new JsonArray();
    children.add(makeChild("value", 2));
    children.add(makeChild("value", 3));
    root.put("children", children);

    JsonTraverser.get().traversePreOrder(root, new JsonVisitor() {
      private long curr = 0;
View Full Code Here

  }

  public void testTraversePostorderNumber() throws JsonException {
    JsonObject root = new JsonObject();
    root.put("value", 3);
    JsonArray children = new JsonArray();
    children.add(makeChild("value", 1));
    children.add(makeChild("value", 2));
    root.put("children", children);

    JsonTraverser.get().traverse(root, new JsonVisitorDouble() {
      private long curr = 0;
View Full Code Here

    }
  }

  private static JsonValue createBgScriptsObject(String bgScriptName) {
    final JsonObject obj = JsonObject.create();
    final JsonArray scriptsArray = JsonArray.create();
    scriptsArray.add(bgScriptName);   
    obj.put("scripts", scriptsArray);
    return obj;
  }
View Full Code Here

    return obj;
  }

  private static JsonValue createContentScriptsArray(
      SortedSet<ContentScriptArtifact> contentScripts) {
    final JsonArray array = JsonArray.create();
    for (ContentScriptArtifact contentScript : contentScripts) {
      JsonObject entry = JsonObject.create();
      JsonArray whiteList = JsonArray.create();
      String[] patterns = contentScript.getWhiteList();
      for (String pattern : patterns) {
        whiteList.add(pattern);
      }
      entry.put("matches", whiteList);
      JsonArray path = JsonArray.create();
      path.add(contentScript.getPath());
      entry.put("js", path);
      entry.put("run_at", contentScript.getRunAt());
      array.add(entry);
    }
    return array;
View Full Code Here

    return array;
  }

  private static JsonValue createPageActionsArray(
      SortedSet<PageActionArtifact> pageActions) {
    final JsonArray pageActionArray = JsonArray.create();
    for (PageActionArtifact pageAction : pageActions) {
      final JsonObject pageActionObject = JsonObject.create();
      pageActionObject.put("id", pageAction.getId());
      pageActionObject.put("name", pageAction.getName());
      final JsonArray iconsArray = JsonArray.create();
      String[] icons = pageAction.getIcons();
      for (String icon : icons) {
        iconsArray.add(icon);
      }
      pageActionObject.put("icons", iconsArray);
      pageActionArray.add(pageActionObject);
    }
    return pageActionArray;
View Full Code Here

    }
    return pageActionArray;
  }

  private static JsonValue createPluginsArray(SortedSet<PluginArtifact> plugins) {
    JsonArray pluginsArray = JsonArray.create();
    for (PluginArtifact plugin : plugins) {
      JsonObject pluginObject = JsonObject.create();
      pluginObject.put("path", plugin.getPath());
      pluginObject.put("public", plugin.isPublic());
      pluginsArray.add(pluginObject);
    }
    return pluginsArray;
  }
View Full Code Here

    // failure.
    assert (size == 1) : "Only 1 BrowserAction per extension allowed.";
    BrowserActionArtifact browserAction = browserActions.first();
    final JsonObject browserActionObject = JsonObject.create();
    browserActionObject.put("name", browserAction.getName());
    final JsonArray iconsArray = JsonArray.create();
    String[] icons = browserAction.getIcons();
    for (String icon : icons) {
      iconsArray.add(icon);
    }
    browserActionObject.put("icons", iconsArray);
    browserActionObject.put("default_icon", browserAction.getDefaultIcon());

    return browserActionObject;
View Full Code Here

TOP

Related Classes of com.google.json.serialization.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.