/** * Get an optional int value associated with a key, * or the default if there is no such key or if the value is not a number. * If the value is a string, an attempt will be made to evaluate it as * a number. * * @param key A key string. * @param defaultValue The default. * @return An object which is the value. */ public int optInt(final String key, final int defaultValue) { try { return getInt(key); } catch (Exception e) { return defaultValue; } }
/** * Get an optional int value associated with a key, * or the default if there is no such key or if the value is not a number. * If the value is a string, an attempt will be made to evaluate it as * a number. * * @param key A key string. * @param defaultValue The default. * @return An object which is the value. */ public int optInt(final String key, final int defaultValue) { try { return getInt(key); } catch (Exception e) { return defaultValue; } }
public static final AddressSettingsInfo from(final String jsonString) throws Exception { JSONObject object = new JSONObject(jsonString); return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"), object.getLong("maxSizeBytes"), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"), object.getInt("maxDeliveryAttempts"), object.getLong("redeliveryDelay"), object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"), object.getLong("redistributionDelay"), object.getBoolean("sendToDLAOnNoRoute")); }
public static AddressSettingsInfo from(final String jsonString) throws Exception { JSONObject object = new JSONObject(jsonString); return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"), object.getLong("maxSizeBytes"), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"), object.getInt("maxDeliveryAttempts"), object.getLong("redeliveryDelay"), object.getDouble("redeliveryMultiplier"), object.getLong("maxRedeliveryDelay"), object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"), object.getLong("redistributionDelay"), object.getBoolean("sendToDLAOnNoRoute"), object.getLong("slowConsumerThreshold"), object.getLong("slowConsumerCheckPeriod"), object.getString("slowConsumerPolicy")); }
/** * Returns an array of RoleInfo corresponding to the JSON serialization returned * by {@link QueueControl#listMessageCounter()}. */ public static MessageCounterInfo fromJSON(final String jsonString) throws Exception { JSONObject data = new JSONObject(jsonString); String name = data.getString("destinationName"); String subscription = data.getString("destinationSubscription"); boolean durable = data.getBoolean("destinationDurable"); long count = data.getLong("count"); long countDelta = data.getLong("countDelta"); int depth = data.getInt("messageCount"); int depthDelta = data.getInt("messageCountDelta"); String lastAddTimestamp = data.getString("lastAddTimestamp"); String updateTimestamp = data.getString("updateTimestamp"); return new MessageCounterInfo(name, subscription, durable, count, countDelta, depth, depthDelta, lastAddTimestamp, updateTimestamp); }
/** * Returns an array of RoleInfo corresponding to the JSON serialization returned * by {@link QueueControl#listMessageCounter()}. */ public static MessageCounterInfo fromJSON(final String jsonString) throws Exception { JSONObject data = new JSONObject(jsonString); String name = data.getString("destinationName"); String subscription = data.getString("destinationSubscription"); boolean durable = data.getBoolean("destinationDurable"); long count = data.getLong("count"); long countDelta = data.getLong("countDelta"); int depth = data.getInt("messageCount"); int depthDelta = data.getInt("messageCountDelta"); String lastAddTimestamp = data.getString("lastAddTimestamp"); String updateTimestamp = data.getString("updateTimestamp"); return new MessageCounterInfo(name, subscription, durable, count, countDelta, depth, depthDelta, lastAddTimestamp, updateTimestamp); }
/** * Returns an array of SubscriptionInfo corresponding to the JSON serialization returned * by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods. */ public static SubscriptionInfo[] from(final String jsonString) throws Exception { JSONArray array = new JSONArray(jsonString); SubscriptionInfo[] infos = new SubscriptionInfo[array.length()]; for (int i = 0; i < array.length(); i++) { JSONObject sub = array.getJSONObject(i); SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"), sub.optString("clientID", null), sub.optString("name", null), sub.getBoolean("durable"), sub.optString("selector", null), sub.getInt("messageCount"), sub.getInt("deliveringCount")); infos[i] = info; } return infos; }