@Override public void setArrayIndex(final Object array, final int index, final Object newValue) { Object v = newValue == null ? JSONObject.NULL : newValue; JSONArray list = (JSONArray) array; list.put(index, v); }
public void addInitialization(InitializationPriority priority, String moduleName, String functionName, JSONArray arguments) { assert priority != null; assert InternalUtils.isNonBlank(moduleName); String name = functionName == null ? moduleName : moduleName + ":" + functionName; if ((arguments == null || arguments.length() == 0)) { if (pureInits.contains(name)) { // A degenerate case is a pure init added repeatedly with different priorities. That isn't handled: // the first priority wins. return; } pureInits.add(name); InternalUtils.addToMapList(inits, priority, name); } else { JSONArray init = new JSONArray(); init.put(name); init.putAll(arguments); InternalUtils.addToMapList(inits, priority, init); } initCount++; }
@Override public void setArrayIndex(final Object array, final int index, final Object newValue) { Object v = newValue == null ? JSONObject.NULL : newValue; JSONArray list = (JSONArray) array; list.put(index, v); }
/** * Creates a new {@code JSONArray} with values from the given primitive array. * * @param values The values to use. * @throws RuntimeException if any of the values are non-finite double values (i.e. NaN or infinite) */ public JSONArray(Object... values) { this(); for (int i = 0; i < values.length; ++i) { put(values[i]); } }
/** * Creates a new {@code JSONArray} with values from the given primitive array. * * @param values The values to use. * @throws RuntimeException if any of the values are non-finite double values (i.e. NaN or infinite) */ public JSONArray(Object... values) { this(); for (int i = 0; i < values.length; ++i) { put(values[i]); } }
@Override public void setArrayIndex(final Object array, final int index, final Object newValue) { Object v = newValue == null ? JSONObject.NULL : newValue; JSONArray list = (JSONArray) array; list.put(index, v); }
public void addLibrary(String libraryURL) { libraryURLs.put(libraryURL); }
/** * Puts all objects from the collection into this JSONArray, using {@link #put(Object)}. * * @param collection * List, array, JSONArray, or other iterable object, or null * @return this JSONArray * @since 5.4 */ public JSONArray putAll(Iterable<?> collection) { if (collection != null) { for (Object o : collection) { put(o); } } return this; }
/** * Puts all objects from the collection into this JSONArray, using {@link #put(Object)}. * * @param collection * List, array, JSONArray, or other iterable object, or null * @return this JSONArray * @since 5.4 */ public JSONArray putAll(Iterable<?> collection) { if (collection != null) { for (Object o : collection) { put(o); } } return this; }
/** * Transforms the matches into a JSONArray * * @return JSONArray of available responses */ protected JSONArray generateResponseJSON(List matches) { JSONArray array = new JSONArray(); for (Object o : matches) { if (o instanceof JSONObject) array.put(o); else array.put(o.toString()); } return array; } }
/** * Same as {@link #put}, with added validity checks. * * @param value The value to append. */ void checkedPut(Object value) { JSONObject.testValidity(value); if (value instanceof Number) { JSON.checkDouble(((Number) value).doubleValue()); } put(value); }
/** * Same as {@link #put}, with added validity checks. * * @param value The value to append. */ void checkedPut(Object value) { JSONObject.testValidity(value); if (value instanceof Number) { JSON.checkDouble(((Number) value).doubleValue()); } put(value); }
public void addScript(InitializationPriority priority, String script) { addInitialization(priority, "t5/core/pageinit", "evalJavaScript", new JSONArray().put(script)); }
public void addStylesheetLink(StylesheetLink stylesheet) { JSONObject object = new JSONObject( "href", stylesheet.getURL(), "media", stylesheet.getOptions().media); stylesheets.put(object); }
public String getInitialJSON() { JSONArray array = new JSONArray(); for (Object o : selected) { String value = encoder.toClient(o); array.put(value); } return array.toString(compactJSON); }
@Override public org.apache.tapestry5.json.JSONObject tapestry(final Users obj) throws IOException { org.apache.tapestry5.json.JSONObject jso = new org.apache.tapestry5.json.JSONObject(); if (obj.users != null) { org.apache.tapestry5.json.JSONArray jsarr = new org.apache.tapestry5.json.JSONArray(); for (User u : obj.users) { jsarr.put(tapestry(u)); } jso.put("users", jsarr); } return jso; }
private void addPublishEventInfo(Flow<EventHandlerMethod> eventHandlerMethods, MutableComponentModel model) { JSONArray publishEvents = new JSONArray(); for (EventHandlerMethod eventHandlerMethod : eventHandlerMethods) { if (eventHandlerMethod.publishEvent != null) { publishEvents.put(eventHandlerMethod.eventType.toLowerCase()); } } // If we do have events to publish, we apply the mixin and pass // event information to it. if (publishEvents.length() > 0) { model.addMixinClassName(PublishServerSideEvents.class.getName(), "after:*"); model.setMeta(InternalConstants.PUBLISH_COMPONENT_EVENTS_META, publishEvents.toString()); } }
void beginRender(MarkupWriter writer) { JSONArray selectedValues = new JSONArray(); for (OptionModel selected : selectedOptions) { Object value = selected.getValue(); String clientValue = encoder.toClient(value); selectedValues.put(clientValue); } JSONArray naturalOrder = new JSONArray(); for (String value : this.naturalOrder) { naturalOrder.put(value); } String clientId = getClientId(); JSONObject options = new JSONObject(); options.put("id", clientId); options.put("reorder", reorder); options.put("naturalOrder", naturalOrder); javascriptSupport.require("tjq/palette").with(options); writer.element("input", "type", "hidden", "id", clientId + "-values", "name", getControlName() + "-values", "value", selectedValues); writer.end(); }
confs.put("mDataProp", propertyName); confs.put("bSortable", getModel().get(propertyName).isSortable()); columnConfs.put(confs);