|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.pdq.runtime.data.handlers.XMLResultHandler
public class XMLResultHandler 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 an XML String
. XMLResultHandler
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 XMLResultHandler
in the same order in which they are returned from the data source. An instance of XMLResultHandler
maintains no state information. Therefore, a single instance of XMLResultHandler
can be used for more than one pureQuery method.
The returned String
has the following format:
ResultSet
, and a <⁄result> tag indicates the end of the ResultSet
. A line break occurs after the <result> tag.ResultSet
. Each row is on a line by itself, and the start of each row is indented one tab character. The start and end of each row are indicated by tags that are the name of the table to which the contents of the first column belong. For example, if tablename is the name of that table, the tag that indicates the start of that row would be <tablename>, and the tag that indicates the end of that row would be <⁄tablename>.String
representation of the contents of the column is between the tags, with no spaces separating it from the tags.For an example, suppose a data source had three tables, each with just one column:
Table Name | Column Name |
---|---|
table1 | t1Column1 |
table2 | t2Column2 |
table3 | t3Column3 |
Then suppose that the following SQL was used to query the data source:
SELECT
table1.t1Column1 AS t1Column1,
table2.t2Column2 AS t2Column2,
table3.t3Column3 AS t3Column3
FROM
table1, table2, table3
WHERE
some logic;
Suppose data were returned for four rows as follows:
t1Column1 | t2Column2 | t3Column3 |
---|---|---|
row1T1Column1Data | row1T2Column2Data | row1T3Column3Data |
row2T1Column1Data | row2T2Column2Data | row2T3Column3Data |
row3T1Column1Data | row3T2Column2Data | row3T3Column3Data |
row4T1Column1Data | row4T2Column2Data | row4T3Column3Data |
With this data, the String
returned by handle(ResultSet)
would be as follows (in the returned String
, the only white space would be a line break after the <result> tag, the line breaks after each <⁄table1> tag, and a tab character before each <table1> tag.).
<result>
<table1><t1Column1>row1T1Column1Data<⁄t1Column1><t2Column2>row1T2Column2Data<⁄t2Column2><t3Column3>row1T3Column3Data<⁄t3Column3><⁄table1>
<table1><t1Column1>row2T1Column1Data<⁄t1Column1><t2Column2>row2T2Column2Data<⁄t2Column2><t3Column3>row2T3Column3Data<⁄t3Column3><⁄table1>
<table1><t1Column1>row3T1Column1Data<⁄t1Column1><t2Column2>row3T2Column2Data<⁄t2Column2><t3Column3>row3T3Column3Data<⁄t3Column3><⁄table1>
<table1><t1Column1>row4T1Column1Data<⁄t1Column1><t2Column2>row4T2Column2Data<⁄t2Column2><t3Column3>row4T3Column3Data<⁄t3Column3><⁄table1>
<⁄result>
Constructor and Description |
---|
XMLResultHandler() |
Modifier and Type | Method and Description |
---|---|
String |
handle(ResultSet rs) Returns the results of an SQL statement as an XML String . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
public XMLResultHandler()
public String handle(ResultSet rs)
String
.
See XMLResultHandler
for a description and an example of how the XML is formatted in the String
that is returned.
handle
in interface ResultHandler<String>
rs
- a ResultSet
that represents the results from an SQL statementString
that contains the entire contents of resultSet
in XML
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |