|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.pdq.runtime.data.handlers.JSONResultHandler
public class JSONResultHandler extends Object implements ResultHandler<String>
An implementation of ResultHandler
that can be specified to cause pureQuery to return content of the results of an SQL query as a String
in the JSON format, which is described at http://www.json.org. JSONResultHandler
is provided to be an example of how a ResultHandler
may be written to process the contents of a ResultSet
. See ResultHandler
for a description of how an implementation of ResultHandler
can be specified to a pureQuery method.
The rows are returned by the JSONResultHandler
in the same order in which they are returned from the data source. An instance of JSONResultHandler
maintains no state information. Therefore, a single instance of JSONResultHandler
can be used for more than one pureQuery method.
The returned String
, which is described at http://www.json.org, has the following format:
ResultSet
, and a "]" indicates the end of the ResultSet
.ResultSet
. The start of each row is indicated by "{" and the end of each row is indicated by "}". Adjacent rows are separated by ",".String
representation of the contents of that column.For example, suppose a data source returned the contents of three columns:
Suppose data was returned for four rows as follows:
column1 | column2 | column3 |
---|---|---|
row1Column1Data | row1Column2Data | row1Column3Data |
row2Column1Data | row2Column2Data | row2Column3Data |
row3Column1Data | row3Column2Data | row3Column3Data |
row4Column1Data | row4Column2Data | row4Column3Data |
With this data, the String
returned by handle(ResultSet)
would be as follows (except that there would be no spaces, line breaks, or other white space in the actual returned String
):
[
{"column1":"row1Column1Data","column2":"row1Column2Data","column3":"row1Column3Data"},
{"column1":"row2Column1Data","column2":"row2Column2Data","column3":"row2Column3Data"},
{"column1":"row3Column1Data","column2":"row3Column2Data","column3":"row3Column3Data"},
{"column1":"row4Column1Data","column2":"row4Column2Data","column3":"row4Column3Data"}
]
Constructor and Description |
---|
JSONResultHandler() |
Modifier and Type | Method and Description |
---|---|
String |
handle(ResultSet rs) Returns the results of an SQL statement as a String in the JSON format. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
public JSONResultHandler()
public String handle(ResultSet rs)
String
in the JSON format.
See JSONResultHandler
for a description of the JSON format and for an example of the JSON format representation of a ResultSet
.
handle
in interface ResultHandler<String>
rs
- a ResultSet
that represents the results from an SQL statementString
that contains the entire contents of resultSet
in the JSON format
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |