org.labkey.remoteapi.query
Class RowsResponse

java.lang.Object
  extended by org.labkey.remoteapi.CommandResponse
      extended by org.labkey.remoteapi.query.RowsResponse
Direct Known Subclasses:
SaveRowsResponse, SelectRowsResponse

public abstract class RowsResponse
extends CommandResponse

Base class for command responses that contain an array of rows and meta-data about those rows. Primarily, this class converts date values in the rows array to real Java Date objects.


Constructor Summary
protected RowsResponse(java.lang.String text, int statusCode, java.lang.String contentType, org.json.simple.JSONObject json, Command sourceCommand)
          Constructs a new RowsResponse given the specified text and status code.
 
Method Summary
protected  void caseInsensitizeRowMaps()
           
protected  void fixupParsedData()
          Fixes up the parsed data.
 java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getRows()
          Returns the list of rows from the parsed response data.
 
Methods inherited from class org.labkey.remoteapi.CommandResponse
findObject, getContentType, getParsedData, getProperty, getProperty, getRequiredVersion, getSourceCommand, getStatusCode, getText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowsResponse

protected RowsResponse(java.lang.String text,
                       int statusCode,
                       java.lang.String contentType,
                       org.json.simple.JSONObject json,
                       Command sourceCommand)
Constructs a new RowsResponse given the specified text and status code.

Parameters:
text - The response text.
statusCode - The HTTP status code.
contentType - the Content-Type header value.
json - The parsed JSONObject (or null if JSON was not returned.
sourceCommand - The source command object
Method Detail

getRows

public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getRows()
Returns the list of rows from the parsed response data. Note that numbers in the map values will be either of type Double or type Long depedning on the prescence of a decimal point. The most reliable way to work with them is to use the Number class. For example:

 for (Map<String,Object> row : response.getRows())
 {
     Number key = (Number)row.get("Key");
     // use Number.intValue(), doubleValue(), longValue(), etc to get various primitive types
 }
 

Returns:
The list of rows (each row is a Map), or null if the rows list was not included in the response.

fixupParsedData

protected void fixupParsedData()
Fixes up the parsed data. Currently, this converts string-based date literals into real Java Date objects.


caseInsensitizeRowMaps

protected void caseInsensitizeRowMaps()