@Override public int length(final Object obj) { if (obj instanceof JSONArray) { return ((JSONArray) obj).length(); } else if (obj instanceof JSONObject) { return ((JSONObject) obj).length(); } else { throw new IllegalArgumentException("Cannot determine length of " + obj + ", unsupported type."); } }
@Test public void a_filter_can_be_applied() { JSONArray fictionBooks = using(TAPESTRY_JSON_CONFIGURATION).parse(JSON_DOCUMENT) .read("$.store.book[?(@.category == 'fiction')]"); assertThat(fictionBooks.length()).isEqualTo(3); }
@Override public int length(final Object obj) { if (obj instanceof JSONArray) { return ((JSONArray) obj).length(); } else if (obj instanceof JSONObject) { return ((JSONObject) obj).length(); } else { throw new IllegalArgumentException("Cannot determine length of " + obj + ", unsupported type."); } }
@Override public int length(final Object obj) { if (obj instanceof JSONArray) { return ((JSONArray) obj).length(); } else if (obj instanceof JSONObject) { return ((JSONObject) obj).length(); } else { throw new IllegalArgumentException("Cannot determine length of " + obj + ", unsupported type."); } }
public void addInitializerCall(InitializationPriority priority, String functionName, JSONArray parameter) { // TAP5-2300: In 5.3, a JSONArray implied an array of method arguments, so unwrap and add // functionName to the arguments List parameterList = new ArrayList(parameter.length() + 1); parameterList.add(functionName); parameterList.addAll(parameter.toList()); createInitializer(priority).with(parameterList.toArray()); }
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()); } }
/** * Commits changes, adding one or more keys to the reply. * * @param reply * JSON Object to be sent to client */ public void commit(JSONObject reply) { if (libraryURLs.length() > 0) { reply.in(InternalConstants.PARTIAL_KEY).put("libraries", libraryURLs); } if (stylesheets.length() > 0) { reply.in(InternalConstants.PARTIAL_KEY).put("stylesheets", stylesheets); } List<?> inits = initsManager.getSortedInits(); if (inits.size() > 0) { reply.in(InternalConstants.PARTIAL_KEY).put("inits", JSONArray.from(inits)); } } }
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 protected void processSubmission(String controlName) { String parameterValue = request.getParameter(controlName); JSONArray values = new JSONArray(parameterValue); // Use a couple of local variables to cut down on access via bindings Collection<Object> selected = this.selected; selected.clear(); ValueEncoder encoder = this.encoder; // TODO: Validation error if the model does not contain a value. int count = values.length(); for (int i = 0; i < count; i++) { String value = values.getString(i); Object objectValue = encoder.toValue(value); selected.add(objectValue); } putPropertyNameIntoBeanValidationContext("selected"); try { fieldValidationSupport.validate(selected, resources, validate); this.selected = selected; } catch (final ValidationException e) { validationTracker.recordError(this, e.getMessage()); } removePropertyNameFromBeanValidationContext(); }
int count = values.length(); for (int i = 0; i < count; i++)
for (int i = 0; i < componentEvents.length(); i++)