|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.labkey.remoteapi.CommandResponse
public class CommandResponse
Represents the details of a response returned from the LabKey Server.
Client code will typically use a class derived from this class that is returned from the particular command used (e.g. SelectRowsCommand returns SelectRowsResponse). However, if you are using the Command class directly to call an HTTP API that does not yet have a specialized command class, you would use this object to obtain the response details.
| Constructor Summary | |
|---|---|
CommandResponse(java.lang.String text,
int statusCode,
java.lang.String contentType,
org.json.simple.JSONObject json,
Command sourceCommand)
Constructs a new CommandResponse, initialized with the provided response text and status code. |
|
| Method Summary | ||
|---|---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
findObject(java.util.List<java.util.Map<java.lang.String,java.lang.Object>> objects,
java.lang.String propertyName,
java.lang.String value)
Finds an Map in a List of Maps who's property identified by propertyName
matches the value supplied. |
|
java.lang.String |
getContentType()
Returns the Content-Type header value from the response. |
|
java.util.Map<java.lang.String,java.lang.Object> |
getParsedData()
Attempts to parse the response text and return a property Map. |
|
|
getProperty(java.lang.String path)
Returns the value of a specific property in the parsed data given a path to that property. |
|
protected
|
getProperty(java.lang.String[] path,
int index,
java.util.Map<java.lang.String,java.lang.Object> parent)
Called by getProperty(String) after splitting the path into
a String[], and recursively by itself as it descends the property
hierarchy. |
|
double |
getRequiredVersion()
Returns the API version number required by the source command. |
|
Command |
getSourceCommand()
Returns a reference to a copy of the command that created this response |
|
int |
getStatusCode()
Returns the HTTP status code (typically 200). |
|
java.lang.String |
getText()
Returns the raw response text. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CommandResponse(java.lang.String text,
int statusCode,
java.lang.String contentType,
org.json.simple.JSONObject json,
Command sourceCommand)
text - The response textstatusCode - The HTTP status codecontentType - The response content typejson - The parsed JSONObject (or null if JSON was not returned).sourceCommand - A copy of the command that created this response| Method Detail |
|---|
public java.lang.String getText()
Use this if your command returns something other than JSON, or if you want to use a different JSON parser.
This may return null if no response body was sent by the server.
public int getStatusCode()
public java.lang.String getContentType()
public double getRequiredVersion()
public Command getSourceCommand()
public java.util.Map<java.lang.String,java.lang.Object> getParsedData()
If the response text cannot be parsed, a runtime error will be thrown.
Note that the values in the Map may be simple values, Lists, or Maps.
public <T> T getProperty(java.lang.String path)
The path is a period-delimited list of property names. For example, to obtain the 'bar' property from the Map associated with the 'foo' property, the path would be 'foo.bar'.
path - The property path.
protected <T> T getProperty(java.lang.String[] path,
int index,
java.util.Map<java.lang.String,java.lang.Object> parent)
getProperty(String) after splitting the path into
a String[], and recursively by itself as it descends the property
hierarchy.
path - The path split into a String[].index - The current index into the path array.parent - The current parent map.
protected java.util.Map<java.lang.String,java.lang.Object> findObject(java.util.List<java.util.Map<java.lang.String,java.lang.Object>> objects,
java.lang.String propertyName,
java.lang.String value)
propertyName
matches the value supplied. Returns null if not found.
objects - The list of Maps to search.propertyName - The property name to examine in each Map.value - The value to compare against.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||