|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritJsonEventFactory
public final class GerritJsonEventFactory
Contains utility methods for handling JSONObjects.
| Method Summary | |
|---|---|
static GerritJsonEvent |
getEvent(net.sf.json.JSONObject jsonObject)
Creates a GerritJsonEvent DTO out of the provided JSONObject. |
static GerritJsonEvent |
getEventIfInteresting(String jsonString)
Tries to parse the provided string into a GerritJsonEvent DTO if it is interesting and usable. |
static net.sf.json.JSONObject |
getJsonObjectIfInterestingAndUsable(String jsonString)
Tries to parse the provided string into a JSONObject and returns it if it is interesting and usable. |
static String |
getString(net.sf.json.JSONObject json,
String key)
Returns the value of a JSON property as a String if it exists otherwise returns null. |
static String |
getString(net.sf.json.JSONObject json,
String key,
String defaultValue)
Returns the value of a JSON property as a String if it exists otherwise returns the defaultValue. |
static boolean |
isInterestingAndUsable(String jsonString)
Tells if the provided string is a valid JSON string and represents an interesting and usable GerritJsonEvent
as defined by getJsonObjectIfInterestingAndUsable(java.lang.String). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static GerritJsonEvent getEvent(net.sf.json.JSONObject jsonObject)
getJsonObjectIfInterestingAndUsable(java.lang.String)
jsonObject - the parsed JSON Object
public static boolean isInterestingAndUsable(String jsonString)
GerritJsonEvent
as defined by getJsonObjectIfInterestingAndUsable(java.lang.String).
This is the same as doing (getJsonObjectIfInterestingAndUsable(jsonString) != null)
jsonString - the JSON formatted String.
public static net.sf.json.JSONObject getJsonObjectIfInterestingAndUsable(String jsonString)
GerritEventType.findByTypeValue(java.lang.String)GerritEventType.isInteresting() == trueGerritEventType.getEventRepresentative() is not null.
jsonString - the string to parse.
public static GerritJsonEvent getEventIfInteresting(String jsonString)
jsonString - the JSON formatted string.
getJsonObjectIfInterestingAndUsable(String)
public static String getString(net.sf.json.JSONObject json,
String key,
String defaultValue)
json - the JSONObject to check.key - the keydefaultValue - the value to return if the key is missing
public static String getString(net.sf.json.JSONObject json,
String key)
getString(net.sf.json.JSONObject, java.lang.String, java.lang.String)
with null as defaultValue.
json - the JSONObject to check.key - the key
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||