Java Code Examples for elemental.json.JsonArray#getObject()
The following examples show how to use
elemental.json.JsonArray#getObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UidlRequestHandler.java From flow with Apache License 2.0 | 6 votes |
private String removeHashInChange(JsonArray change) { if (change.length() < 3 || !change.get(2).getType().equals(JsonType.ARRAY)) { return null; } JsonArray value = change.getArray(2); if (value.length() < 2 || !value.get(1).getType().equals(JsonType.OBJECT)) { return null; } JsonObject location = value.getObject(1); if (!location.hasKey(LOCATION)) { return null; } String url = location.getString(LOCATION); Matcher match = URL_PATTERN.matcher(url); if (match.find()) { location.put(LOCATION, match.group(1)); } return url; }
Example 2
Source File: BootstrapHandler.java From flow with Apache License 2.0 | 6 votes |
private List<Element> inlineDependenciesInHead(Element head, BootstrapUriResolver uriResolver, LoadMode loadMode, JsonArray dependencies) { List<Element> dependenciesToInlineInBody = new ArrayList<>(); for (int i = 0; i < dependencies.length(); i++) { JsonObject dependencyJson = dependencies.getObject(i); Dependency.Type dependencyType = Dependency.Type .valueOf(dependencyJson.getString(Dependency.KEY_TYPE)); Element dependencyElement = createDependencyElement(uriResolver, loadMode, dependencyJson, dependencyType); head.appendChild(dependencyElement); } return dependenciesToInlineInBody; }
Example 3
Source File: TreeChangeProcessor.java From flow with Apache License 2.0 | 6 votes |
private static JsSet<StateNode> processAttachChanges(StateTree tree, JsonArray changes) { JsSet<StateNode> nodes = JsCollections.set(); int length = changes.length(); for (int i = 0; i < length; i++) { JsonObject change = changes.getObject(i); if (isAttach(change)) { int nodeId = (int) change.getNumber(JsonConstants.CHANGE_NODE); if (nodeId != tree.getRootNode().getId()) { StateNode node = new StateNode(nodeId, tree); tree.registerNode(node); nodes.add(node); } } } return nodes; }
Example 4
Source File: CubaSuggestionFieldWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void showSuggestions(JsonArray suggestions, boolean userOriginated) { this.suggestions.clear(); for (int i = 0; i < suggestions.length(); i++) { JsonObject jsonSuggestion = suggestions.getObject(i); Suggestion suggestion = new Suggestion( jsonSuggestion.getString(SUGGESTION_ID), jsonSuggestion.getString(SUGGESTION_CAPTION), jsonSuggestion.getString(SUGGESTION_STYLE_NAME) ); this.suggestions.add(suggestion); } showSuggestions(userOriginated); }
Example 5
Source File: DependencyLoader.java From flow with Apache License 2.0 | 5 votes |
private JsMap<String, BiConsumer<String, ResourceLoadListener>> extractLazyDependenciesAndLoadOthers( LoadMode loadMode, JsonArray dependencies) { JsMap<String, BiConsumer<String, ResourceLoadListener>> lazyDependencies = JsCollections .map(); for (int i = 0; i < dependencies.length(); i++) { JsonObject dependencyJson = dependencies.getObject(i); Dependency.Type type = Dependency.Type .valueOf(dependencyJson.getString(Dependency.KEY_TYPE)); BiConsumer<String, ResourceLoadListener> resourceLoader = getResourceLoader( type, loadMode); if (type == Dependency.Type.DYNAMIC_IMPORT) { loadDependencyEagerly( dependencyJson.getString(Dependency.KEY_URL), resourceLoader); } else { switch (loadMode) { case EAGER: loadDependencyEagerly(getDependencyUrl(dependencyJson), resourceLoader); break; case LAZY: lazyDependencies.set(getDependencyUrl(dependencyJson), resourceLoader); break; case INLINE: loadDependencyEagerly( dependencyJson.getString(Dependency.KEY_CONTENTS), resourceLoader); break; default: throw new IllegalArgumentException( "Unknown load mode = " + loadMode); } } } return lazyDependencies; }
Example 6
Source File: CubaSideMenuWidget.java From cuba with Apache License 2.0 | 4 votes |
protected void addItems(JsonArray items, HasWidgets container) { for (int i = 0; i < items.length(); i++) { JsonObject itemJson = items.getObject(i); Icon icon = null; String iconId = itemJson.getString("icon"); if (menuItemIconSupplier != null && iconId != null) { icon = menuItemIconSupplier.apply(iconId); } boolean captionAsHtml = false; if (itemJson.hasKey("captionAsHtml")) { captionAsHtml = itemJson.getBoolean("captionAsHtml"); } MenuItemWidget menuItemWidget = new MenuItemWidget(this, itemJson.getString("id"), icon, itemJson.getString("styleName"), itemJson.getString("caption"), captionAsHtml); menuItemWidget.setDescription(itemJson.getString("description")); menuItemWidget.setCubaId(itemJson.getString("cubaId")); menuItemWidget.setBadgeText(itemJson.getString("badgeText")); container.add(menuItemWidget); JsonArray childrenItemsJson = itemJson.getArray("children"); if (childrenItemsJson != null) { MenuContainerWidget menuContainerWidget = new MenuContainerWidget(this, menuItemWidget); addItems(childrenItemsJson, menuContainerWidget); container.add(menuContainerWidget); menuItemWidget.setSubMenu(menuContainerWidget); if (itemJson.hasKey("expanded") && itemJson.getBoolean("expanded")) { menuContainerWidget.setExpanded(true); } } } }