Refine search
private JsonArray getArray(JsonArrayBuilder builder) { while(hasNext()) { JsonParser.Event e = next(); if (e == JsonParser.Event.END_ARRAY) { return builder.build(); } builder.add(getValue()); } throw parsingException(JsonToken.EOF, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL, SQUARECLOSE]"); }
JsonArrayBuilder c = Json.createArrayBuilder(); for (Mention m : gold.corefMentions) { c.add(m.mentionID); clusters.add(c.build()); clusters.build()).build()); sentences.add(getSentenceArray(sentence.get(CoreAnnotations.TokensAnnotation.class))); builder.add(val); features.add(key, builder.build()); labels.add(key, e.getValue() ? 1 : 0); .add("sentences", sentences.build()) .add("mentions", mentions.build()) .add("labels", labels.build()) .add("pair_feature_names", featureNames.build()) .add("pair_features", features.build()) .add("document_features", docFeatures.build())
@Override public JsonArray add(JsonValue value) { //TODO should we check for arrayoutofbounds? // The spec seems to say index = array.size() is allowed. This is handled as append JsonArrayBuilder builder = Json.createArrayBuilder(this.array); if (index == -1 || index == array.size()) { builder.add(value); } else { if(index < array.size()) { builder.add(index, value); } else { throw new JsonException(JsonMessages.NODEREF_ARRAY_INDEX_ERR(index, array.size())); } } return builder.build(); }
private boolean hasValidAudience(JsonObject claims) throws RealmUnavailableException { if (this.audiences.isEmpty()) return true; JsonValue audience = claims.get("aud"); if (audience == null) { log.debug("Token does not contain an audience claim"); return false; } JsonArray audClaimArray; if (JsonValue.ValueType.STRING.equals(audience.getValueType())) { audClaimArray = Json.createArrayBuilder().add(audience).build(); } else { audClaimArray = (JsonArray) audience; } boolean valid = audClaimArray.stream() .map(jsonValue -> (JsonString) jsonValue) .anyMatch(audience1 -> audiences.contains(audience1.getString())); if (!valid) { log.debugf("Audience check failed. Provided [%s] but was expected [%s].", audClaimArray.toArray(), this.audiences); } return valid; }
/** * Update an account with an ACME server using the given account information. * * @param account the ACME account information to use (must not be {@code null}) * @param staging whether or not the staging server URL should be used * @param termsOfServiceAgreed the new value for whether or not the terms of service have been agreed to * @param contactUrls the new account contact URLs * @throws AcmeException if an error occurs while attempting to update the account */ public void updateAccount(AcmeAccount account, boolean staging, boolean termsOfServiceAgreed, String[] contactUrls) throws AcmeException { Assert.checkNotNullParam("account", account); JsonObjectBuilder payloadBuilder = Json.createObjectBuilder() .add(TERMS_OF_SERVICE_AGREED, termsOfServiceAgreed); if (contactUrls != null && ! (contactUrls.length == 0)) { JsonArrayBuilder contactBuilder = Json.createArrayBuilder(); for (String contactUrl : contactUrls) { contactBuilder.add(contactUrl); } payloadBuilder.add(CONTACT, contactBuilder.build()); } sendPostRequestWithRetries(account, staging, getAccountUrl(account, staging), false, getEncodedJson(payloadBuilder.build()), HttpURLConnection.HTTP_OK); account.setTermsOfServiceAgreed(termsOfServiceAgreed); if (contactUrls != null && ! (contactUrls.length == 0)) { account.setContactUrls(contactUrls); } }
final String processGroupId = mapHolder.getProcessGroupId(event.getComponentId(), event.getComponentType()); final String processGroupName = mapHolder.getComponentName(processGroupId); arrayBuilder.add(serialize(factory, builder, event, df, componentName, processGroupId, processGroupName, hostname, url, rootGroupName, platform, nodeId)); final JsonArray jsonArray = arrayBuilder.build();
JsonArray objarr = jsonReader.readArray(); for (JsonValue o : objarr) obj.add(o); jsonReader.close(); l.add(w2.getPhrase()); pats.add(p.toStringSimple()); IOUtils.writeStringToFile(StringUtils.normalize(StringUtils.toAscii(obj.build().toString())), filename, "ASCII"); writtenInJustification.put(label, true);
jsonReader.close(); for (JsonValue o : objarr) obj.add(o); } else obj = Json.createArrayBuilder(); pos.add(w.getPhrase()); for (CandidatePhrase w : negWords.get(pat.first())) neg.add(w.getPhrase()); for (CandidatePhrase w : unlabWords.get(pat.first())) unlab.add(w.getPhrase()); IOUtils.writeStringToFile(StringUtils.normalize(StringUtils.toAscii(obj.build().toString())), filename, "ASCII"); writtenPatInJustification.put(label, true);
.add(VALUE, domainName) .build(); identifiersBuilder.add(identifier); .add(IDENTIFIERS, identifiersBuilder.build()); HttpURLConnection connection = sendPostRequestWithRetries(account, staging, newOrderUrl, false, getEncodedJson(payloadBuilder.build()), HttpURLConnection.HTTP_CREATED); JsonObject jsonResponse = getJsonResponse(connection);
JsonObject toJsonObject() { JsonObjectBuilder ob = Json.createObjectBuilder(); ob.add("id", enrollmentID); ob.add("type", type); if (this.secret != null) { ob.add("secret", secret); } if (null != maxEnrollments) { ob.add("max_enrollments", maxEnrollments); } if (affiliation != null) { ob.add("affiliation", affiliation); } JsonArrayBuilder ab = Json.createArrayBuilder(); for (Attribute attr : attrs) { ab.add(attr.toJsonObject()); } if (caName != null) { ob.add(HFCAClient.FABRIC_CA_REQPROP, caName); } ob.add("attrs", ab.build()); return ob.build(); } }
private JsonObject idToJsonObject() { JsonObjectBuilder ob = Json.createObjectBuilder(); ob.add("id", enrollmentID); ob.add("type", type); if (null != maxEnrollments) { ob.add("max_enrollments", maxEnrollments); } if (affiliation != null) { ob.add("affiliation", affiliation); } JsonArrayBuilder ab = Json.createArrayBuilder(); for (Attribute attr : attrs) { ab.add(attr.toJsonObject()); } ob.add("attrs", ab.build()); if (this.secret != null) { ob.add("secret", secret); } if (client.getCAName() != null) { ob.add(HFCAClient.FABRIC_CA_REQPROP, client.getCAName()); } return ob.build(); } }
private JsonArray getArray(JsonArrayBuilder builder) { while(hasNext()) { JsonParser.Event e = next(); if (e == JsonParser.Event.END_ARRAY) { return builder.build(); } builder.add(getValue()); } throw parsingException(JsonToken.EOF, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL, SQUARECLOSE]"); }
@Override public JsonArray add(JsonValue value) { //TODO should we check for arrayoutofbounds? // The spec seems to say index = array.size() is allowed. This is handled as append JsonArrayBuilder builder = Json.createArrayBuilder(this.array); if (index == -1 || index == array.size()) { builder.add(value); } else { if(index < array.size()) { builder.add(index, value); } else { throw new JsonException(JsonMessages.NODEREF_ARRAY_INDEX_ERR(index, array.size())); } } return builder.build(); }