/** * Create a filter for matching against a string metadata field. * @param field the field to match against. * @param value the value to match against. */ public MetadataFieldFilter(String field, String value) { this.field = field; this.value = JsonValue.valueOf(value); }
public static JsonValue valueOf( Object object ) { if (object != null) { Class c = object.getClass(); if (String.class.equals(c)) return valueOf( (String) object ); if (Integer.class.equals(c) || int.class.equals(c)) return valueOf( (Integer) object ); if (Double.class.equals(c) || double.class.equals(c)) return valueOf( (Double) object ); if (Float.class.equals(c) || float.class.equals(c)) return valueOf( (Float) object ); if (Boolean.class.equals(c) || boolean.class.equals(c)) return valueOf( (Boolean) object ); if (Long.class.equals(c) || long.class.equals(c)) return valueOf( (Long) object ); throw new IllegalArgumentException("Unsupported object type in JsonValue.valueOf : "+c.getName()); } return NULL; }
private void updateWhitelist() throws ConnectionException { JsonValue whitelistedUserList = JsonValue.valueOf(whitelistedIds.stream().collect(Collectors.joining(","))); putOption("alloweduserlist", whitelistedUserList, true); } }
/** * Adds a pending field change that needs to be sent to the API. It will be included in the JSON string the next * time {@link #getPendingChanges} is called. * @param key the name of the field. * @param value the new long value of the field. */ void addPendingChange(String key, long value) { this.addPendingChange(key, JsonValue.valueOf(value)); }
/** * Adds a pending field change that needs to be sent to the API. It will be included in the JSON string the next * time {@link #getPendingChanges} is called. * @param key the name of the field. * @param value the new String value of the field. */ void addPendingChange(String key, String value) { this.addPendingChange(key, JsonValue.valueOf(value)); }
private void updateBanlist() throws ConnectionException { JsonValue bannedUserList = JsonValue.valueOf(bannedIds.stream().collect(Collectors.joining(","))); putOption("banneduserlist", bannedUserList, true); }
public void setTopic(String topic) throws ConnectionException { putOption("topic", JsonValue.valueOf(topic), true); }
public void alertsOff() throws ConnectionException { putOption("alerts", JsonValue.valueOf(false), false); }
@Override public void setImage(BufferedImage image, String imageType) throws ConnectionException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, imageType, baos); String id = Utils.uploadImage(baos.toByteArray(), Utils.ImageType.AVATAR, this); putOption("picture", JsonValue.valueOf( String.format("URL@https://api.asm.skype.com/v1/objects/%s/views/avatar_fullsize", id)), true); }
@Override public void setImage(File image) throws ConnectionException, IOException { byte[] data = Files.readAllBytes(image.toPath()); String id = Utils.uploadImage(data, Utils.ImageType.AVATAR, this); putOption("picture", JsonValue.valueOf( String.format("URL@https://api.asm.skype.com/v1/objects/%s/views/avatar_fullsize", id)), true); }
protected void parseHashMapEntry(JsonObject jsonBody, Map.Entry<String, Object> entry) { Object obj = entry.getValue(); if (obj instanceof BoxJsonObject) { jsonBody.add(entry.getKey(), parseJsonObject(obj)); } else if (obj instanceof Double) { jsonBody.add(entry.getKey(), Double.toString((Double) obj)); } else if (obj instanceof Enum || obj instanceof Boolean) { jsonBody.add(entry.getKey(), obj.toString()); } else if (obj instanceof JsonArray) { jsonBody.add(entry.getKey(), (JsonArray) obj); } else if (obj instanceof Long) { jsonBody.add(entry.getKey(), JsonValue.valueOf((Long)obj)); } else if (obj instanceof Integer) { jsonBody.add(entry.getKey(), JsonValue.valueOf((Integer)obj)); } else if (obj instanceof Float) { jsonBody.add(entry.getKey(), JsonValue.valueOf((Float)obj)); } else if (obj instanceof String) { jsonBody.add(entry.getKey(), (String) obj); } else { BoxLogUtils.e("Unable to parse value " + obj, new RuntimeException("Invalid value")); } }
@Override public void setOptionEnabled(Option option, boolean enabled) throws ConnectionException { putOption(option.getId(), JsonValue.valueOf(enabled), true); updateOption(option, enabled); }