|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.endeca.portal.data.functions.util.QueryFunctionUtils
public final class QueryFunctionUtils
A set of static utility methods for serializing QueryFunctions as JSON Strings and JSONObjects. Note on Exceptions for the toString/toJSONObject methods: Jackson's checked exceptions have been mapped to run time exceptions, as an exception in this code indicates a programming problem on the part of the QueryFunction implementer or the caller of this code, and not something that should happen as a matter of course. See the following page for a rationale: http://stackoverflow.com/a/322889/21220 The upshot of this is that clients will be less likely to catch and suppress errors around JSON serializing and parsing, and hence we should catch more programming errors.
| Method Summary | ||
|---|---|---|
static void |
addSearchAdjustmentConfig(QueryState q)
Adds a SearchAdjustmentConfig to the QueryState when the QueryState contains a SearchFilter. |
|
static QueryFunction |
fromJSONObject(org.json.JSONObject fn)
Utility method for bridging between Jackson based serialization and code which still uses org.json.JSONObject. |
|
static
|
fromJSONObject(org.json.JSONObject fn,
java.lang.Class<T> valueType)
Utility method for bridging between Jackson based serialization and code which still uses org.json.JSONObject. |
|
static QueryFunction |
fromString(java.lang.String fn)
Converts a String representation of a QueryFunction to an instance of a QueryFunction. |
|
static
|
fromString(java.lang.String fn,
java.lang.Class<T> valueType)
Converts a String representation of a QueryFunction to a subclass of QueryFunction. |
|
static boolean |
hasSearchFilter(QueryState q)
Returns true if the QueryState contains a SearchFilter. |
|
static java.util.List<QueryFunction> |
listFromString(java.lang.String fns)
Converts a String representation of an array of QueryFunctions to an instance of a List |
|
static
|
listFromString(java.lang.String fns,
java.lang.Class<T> itemType)
Converts a String representation of an array of QueryFunctions to an instance of a List |
|
static java.lang.String |
listToString(java.util.List<QueryFunction> fns)
Converts a potentially heterogenous List |
|
static
|
listToString(java.util.List<T> fns,
java.lang.Class<T> itemType)
Converts a homogeneous List |
|
static org.json.JSONObject |
toJSONObject(QueryFunction fn)
Utility method for bridging between Jackson based serialization and code which still uses org.json.JSONObject. |
|
static java.lang.String |
toString(QueryFunction fn)
Converts a QueryFunction into a String version of its JSON Object. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T extends QueryFunction> T fromString(java.lang.String fn,
java.lang.Class<T> valueType)
throws java.io.IOException
fn - the JSON representation of the QueryFunction.valueType - the expected type of the QueryFunction. This should match or be a parent of the class attribute in the JSON.
java.io.IOException
public static QueryFunction fromString(java.lang.String fn)
throws java.io.IOException
fn - the JSON representation of the QueryFunction.
java.io.IOException
public static <T extends QueryFunction> java.util.List<T> listFromString(java.lang.String fns,
java.lang.Class<T> itemType)
throws java.io.IOException
fns - the JSON representation of the array of QueryFunctions.itemType - the expected type of the items in the Array. This should match or be a parent of each class attribute in the JSON.
java.io.IOException
public static java.util.List<QueryFunction> listFromString(java.lang.String fns)
throws java.io.IOException
fns - the JSON representation of the array of QueryFunctions.
java.io.IOExceptionpublic static java.lang.String toString(QueryFunction fn)
fn - the QueryFunction to convert to a JSON Object.
java.lang.IllegalArgumentException - If the QueryFunction is not JSON serializable
public static <T extends QueryFunction> java.lang.String listToString(java.util.List<T> fns,
java.lang.Class<T> itemType)
fns - The list of QueryFunctions to convert to JSON.itemType - the expected type of the items in the Array.
java.lang.IllegalArgumentException - If the QueryFunction is not JSON serializablepublic static java.lang.String listToString(java.util.List<QueryFunction> fns)
fns - The list of QueryFunctions to convert to JSON.
public static <T extends QueryFunction> T fromJSONObject(org.json.JSONObject fn,
java.lang.Class<T> valueType)
throws java.io.IOException
java.io.IOException
public static QueryFunction fromJSONObject(org.json.JSONObject fn)
throws java.io.IOException
java.io.IOExceptionpublic static org.json.JSONObject toJSONObject(QueryFunction fn)
java.lang.IllegalArgumentException - If the QueryFunction is not JSON serializablepublic static void addSearchAdjustmentConfig(QueryState q)
public static boolean hasSearchFilter(QueryState q)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||