org.labkey.remoteapi.query.SelectRowsResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of labkey-client-api Show documentation
Show all versions of labkey-client-api Show documentation
The client-side library for Java developers is a separate JAR from the LabKey Server code base. It can be used by any Java program, including another Java web application.
The newest version!
/*
* Copyright (c) 2008-2017 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.remoteapi.query;
import org.json.simple.JSONObject;
import org.labkey.remoteapi.Command;
import java.util.List;
import java.util.Map;
/*
* User: Dave
* Date: Jul 14, 2008
* Time: 9:50:15 AM
*/
/**
* The command response class returned from the
* {@link SelectRowsCommand#execute(org.labkey.remoteapi.Connection, String)}
* method. This class provides helpful methods for obtaining specific bits
* of the parsed response data.
* @see SelectRowsCommand
*/
public class SelectRowsResponse extends RowsResponse
{
/**
* An enumeration of the possible column data types
*/
public enum ColumnDataType
{
STRING,
INT,
FLOAT,
BOOLEAN,
DATE;
public static ColumnDataType parseJsonType(String type)
{
if("string".equalsIgnoreCase(type))
return STRING;
else if("int".equalsIgnoreCase(type))
return INT;
else if("float".equalsIgnoreCase(type))
return FLOAT;
else if("boolean".equalsIgnoreCase(type))
return BOOLEAN;
else if("date".equalsIgnoreCase(type))
return DATE;
else
return null;
}
}
/**
* Constructs a new SelectRowsResponse given the response text and HTTP status code.
* @param text The response text.
* @param statusCode The HTTP status code.
* @param contentType The Content-Type header value.
* @param json The parsed JSONObject (or null if no JSON was returned
* @param sourceCommand A copy of the command that created this response
*/
public SelectRowsResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
{
super(text, statusCode, contentType, json, sourceCommand);
}
/**
* Returns the number of rows this query could return. If a maximum row limit was set
* on the SelectRowsCommand, this value may be higher than the actual number of rows
* returned. This value allows clients that page results to know the total number of
* possible rows, even if only a page of them was returned.
* @return The total number of rows, or null if this value was not returned by the server.
*/
public Number getRowCount()
{
return getProperty("rowCount");
}
/**
* Returns an iterable Rowset. Use this to iterate over the rows,
* working with the Row interface, which hides the differences between
* the normal (<9.1) and extended (>=9.1) response formats.
* @return An iterable Rowset.
*/
public Rowset getRowset()
{
return new RowsResponseRowset((List