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


Java Json.createArray方法代码示例

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


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

示例1: sendUploadResponse

import elemental.json.Json; //导入方法依赖的package包/类
@Override
protected void sendUploadResponse(VaadinRequest request, VaadinResponse response,
                                  String fileName, long contentLength) throws IOException {
    JsonArray json = Json.createArray();
    JsonObject fileInfo = Json.createObject();
    fileInfo.put("name", fileName);
    fileInfo.put("size", contentLength);

    // just fake addresses and parameters
    fileInfo.put("url", fileName);
    fileInfo.put("thumbnail_url", fileName);
    fileInfo.put("delete_url", fileName);
    fileInfo.put("delete_type", "POST");
    json.set(0, fileInfo);

    PrintWriter writer = response.getWriter();
    writer.write(json.toJson());
    writer.close();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:CubaVaadinServletService.java

示例2: create

import elemental.json.Json; //导入方法依赖的package包/类
@Override
public Slob create(@Nullable String snapshot) throws InvalidSnapshot {
  if (snapshot == null) {
    return new RealtimeSlob(Json.createArray());
  } else {
    try {
      return new RealtimeSlob(Json.instance().parse(snapshot));
    } catch (JsonException e) {
      throw new InvalidSnapshot(e);
    }
  }
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:13,代码来源:RealtimeSlobAdapter.java

示例3: putNotNull

import elemental.json.Json; //导入方法依赖的package包/类
protected void putNotNull(JsonObject obj, String key, List<String> list) {
    if (list != null) {
        JsonArray arr = Json.createArray();
        for (String entry : list) {
            arr.set(arr.length(), entry);
        }
        obj.put(key, arr);
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:10,代码来源:AbstractBuilder.java

示例4: buildJson

import elemental.json.Json; //导入方法依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonObject map = Json.createObject();
    putNotNull(map, "allowMultiParagraphSelection", allowMultiParagraphSelection);
    if (buttons != null) {
        JsonArray btnList = Json.createArray();
        for (ToolbarButtonBuilder tbb : buttons) {
            btnList.set(btnList.length(), tbb.buildJson());
        }
        map.put("buttons", btnList);
    }
    putNotNull(map, "diffLeft", diffLeft);
    putNotNull(map, "diffTop", diffLeft);
    putNotNull(map, "firstButtonClass", firstButtonClass);
    putNotNull(map, "lastButtonClass", lastButtonClass);
    putNotNull(map, "standardizeSelectionStart", standardizeSelectionStart);
    putNotNull(map, "static", staticToolbar);
    // TODO relativeContainer // Toolbar is appended relative to a given DOM-Node instead of appending it to the body and position it absolute.
    //      map.put("relativeContainer", null);
    putNotNull(map, "align", align);
    putNotNull(map, "sticky", sticky);
    putNotNull(map, "stickyTopOffset", stickyTopOffset);
    putNotNull(map, "updateOnEmptySelection", updateOnEmptySelection);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:26,代码来源:Toolbar.java

示例5: buildJson

import elemental.json.Json; //导入方法依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonArray array = Json.createArray();
    for (KeyboardCommand c : commands) {
        JsonObject map = Json.createObject();
        putNotNull(map, "command", c.command);
        putNotNull(map, "key", c.key);
        putNotNull(map, "meta", c.meta);
        putNotNull(map, "shift", c.shift);
        putNotNull(map, "alt", c.alt);
        array.set(array.length(), map);
    }
    return array;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:15,代码来源:KeyboardCommands.java

示例6: putNotNull

import elemental.json.Json; //导入方法依赖的package包/类
public static void putNotNull(JsonObject obj, String key, List<String> list) {
    if (list != null) {
        JsonArray arr = Json.createArray();
        for (String entry : list) {
            arr.set(arr.length(), entry);
        }
        obj.put(key, arr);
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:10,代码来源:JUtils.java

示例7: putNotNullNumbers

import elemental.json.Json; //导入方法依赖的package包/类
public static void putNotNullNumbers(JsonObject obj, String key, List<Double> listOfNumbers) {
    if (listOfNumbers != null) {
        JsonArray arr = Json.createArray();
        for (Double n : listOfNumbers) {
            if (n == null) {
                arr.set(arr.length(), new JreJsonNull());
            } else {
                arr.set(arr.length(), n);
            }
        }
        obj.put(key, arr);
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:14,代码来源:JUtils.java

示例8: putNotNullStringListOrSingle

import elemental.json.Json; //导入方法依赖的package包/类
public static void putNotNullStringListOrSingle(JsonObject obj, String key, List<String> list) {
    if (list != null) {
        if (list.size() == 1) {
            putNotNull(obj, key, list.get(0));
        } else {
            JsonArray arr = Json.createArray();
            for (String entry : list) {
                arr.set(arr.length(), entry);
            }
            obj.put(key, arr);
        }
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:14,代码来源:JUtils.java

示例9: putNotNullIntListOrSingle

import elemental.json.Json; //导入方法依赖的package包/类
public static void putNotNullIntListOrSingle(JsonObject obj, String key, List<Integer> listOfNumbers) {
    if (listOfNumbers != null) {
        if (listOfNumbers.size() == 1) {
            putNotNull(obj, key, listOfNumbers.get(0));
        } else {
            JsonArray arr = Json.createArray();
            for (Integer n : listOfNumbers) {
                arr.set(arr.length(), n.doubleValue());
            }
            obj.put(key, arr);
        }
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:14,代码来源:JUtils.java

示例10: getState

import elemental.json.Json; //导入方法依赖的package包/类
@Override
public JsonObject getState() {
  JsonObject state = Json.createObject();
  JsonArray array = Json.createArray();
  state.put(PATH_PARAM_ID, array);

  List<String> rawPaths =
      projectExplorer
          .getTree()
          .getNodeStorage()
          .getAll()
          .stream()
          .filter(node -> projectExplorer.getTree().isExpanded(node))
          .filter(node -> node instanceof ResourceNode)
          .map(node -> ((ResourceNode) node).getData().getLocation().toString())
          .collect(Collectors.toList());

  int i = 0;
  for (String path : rawPaths) {
    array.set(i++, path);
  }

  state.put(SHOW_HIDDEN_FILES, projectExplorer.isShowHiddenFiles());

  return state;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:ProjectExplorerStateComponent.java

示例11: getPartStackState

import elemental.json.Json; //导入方法依赖的package包/类
private JsonObject getPartStackState(
    PartStack partStack, WorkBenchPartController partController) {
  JsonObject state = Json.createObject();
  state.put("SIZE", partController.getSize());
  state.put("STATE", partStack.getPartStackState().name());

  if (partStack.getParts().isEmpty()) {
    state.put("HIDDEN", true);
  } else {
    if (partStack.getActivePart() != null) {
      state.put("ACTIVE_PART", partStack.getActivePart().getClass().getName());
    }

    state.put("HIDDEN", partController.isHidden());

    JsonArray parts = Json.createArray();
    state.put("PARTS", parts);
    int i = 0;
    for (PartPresenter entry : partStack.getParts()) {
      JsonObject presenterState = Json.createObject();
      presenterState.put("CLASS", entry.getClass().getName());
      parts.set(i++, presenterState);
    }
  }
  return state;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:AbstractPerspective.java

示例12: storeEditors

import elemental.json.Json; //导入方法依赖的package包/类
private JsonArray storeEditors(EditorPartStack partStack) {
  JsonArray result = Json.createArray();
  int i = 0;
  List<EditorPartPresenter> parts = partStack.getParts();
  for (EditorPartPresenter part : parts) {
    JsonObject file = Json.createObject();
    file.put("PATH", part.getEditorInput().getFile().getLocation().toString());
    file.put("EDITOR_PROVIDER", openedEditorsToProviders.get(part));
    if (part instanceof TextEditor) {
      file.put("CURSOR_OFFSET", ((TextEditor) part).getCursorOffset());
      file.put("TOP_VISIBLE_LINE", ((TextEditor) part).getTopVisibleLine());
    }
    if (partStack.getActivePart().equals(part)) {
      file.put("ACTIVE", true);
    }
    result.set(i++, file);
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:EditorAgentImpl.java

示例13: shouldRestoreOpenedParts

import elemental.json.Json; //导入方法依赖的package包/类
@Test
@Ignore // TODO
public void shouldRestoreOpenedParts() throws Exception {
  JsonObject state = Json.createObject();
  JsonObject parts = Json.createObject();
  state.put("PART_STACKS", parts);
  JsonObject partStack = Json.createObject();
  parts.put("INFORMATION", partStack);
  JsonArray partsArray = Json.createArray();
  partStack.put("PARTS", partsArray);
  JsonObject part = Json.createObject();
  partsArray.set(0, part);
  part.put("CLASS", "foo.Bar");

  when(dynaProvider.<PartPresenter>getProvider(anyString())).thenReturn(partProvider);
  when(partProvider.get()).thenReturn(partPresenter);

  perspective.loadState(state);

  verify(dynaProvider).getProvider("foo.Bar");
  verify(partProvider).get();

  verify(partStackPresenter).addPart(partPresenter);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:AbstractPerspectivePersistenceTest.java

示例14: flushPendingCommands

import elemental.json.Json; //导入方法依赖的package包/类
public JsonArray flushPendingCommands() {
    for (Entry<Integer, Component[]> entry : fetchDomComponents
            .entrySet()) {
        JsonArray connectorsJson = Json.createArray();
        for (Component component : entry.getValue()) {
            connectorsJson.set(connectorsJson.length(),
                    component.getConnectorId());
        }

        addCommand("fetchDom", null, Json.create(entry.getKey().intValue()),
                connectorsJson);
    }
    fetchDomComponents.clear();

    JsonArray payload = pendingCommands;
    pendingCommands = Json.createArray();
    return payload;
}
 
开发者ID:vaadin,项目名称:serverside-elements,代码行数:19,代码来源:RootImpl.java

示例15: callElectronUiApi

import elemental.json.Json; //导入方法依赖的package包/类
private void callElectronUiApi(String[] args) {
    JsonArray paramsArray = Json.createArray();
    int i = 0;
    for (String arg : args) {
        paramsArray.set(i, Json.create(arg));
        i++;
    }
    getPage().getJavaScript().execute("callElectronUiApi(" + paramsArray.toJson() + ")");
}
 
开发者ID:jreznot,项目名称:electron-java-app,代码行数:10,代码来源:MainUI.java


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