public class ResultSetConverter extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
columnDelimitor
The class columnDelimitorchar (defualt = "|") used for delimiting the ResultSet columns during conversions to CSV, StringBuilder or String .
|
static String |
DEFAULT_COLUMN_DELIMITOR
The Default char ("|") used for delimiting the ResultSet columns.
|
private ResultSet |
rs_
The class ResultSet that gets converted.
|
private Document |
rsDoc_ |
static String |
SYSTEM_FILE_SEPERATOR |
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
Constructor and Description |
---|
ResultSetConverter(ResultSet rs)
Constructor that initializes the class resultset.
|
Modifier and Type | Method and Description |
---|---|
String |
convertToCSV() |
String |
convertToCSV(boolean includeColumnsHeaders)
Converts a ResultSet to a csv String that holds one result per line.
|
String |
convertToCSVFile(String fileName,
boolean includeColumnsHeaders)
Converts a ResultSet StringBuffer to a saved file that holds one result per line.
|
JSONArray |
convertToJson()
Converts the class ResultSet into a fully described JSON Array Object (org.json.JSONArray)
|
StringBuilder |
convertToStringBuilder()
Convert to a Delimited StringBuilder.
|
Document |
convertToXml()
Converts the class ResultSet into a fully described XML Document (nu.xom.Documnet)
|
private Node |
convertToXML(ResultSet data,
int field,
int type)
converts the rs data field to a hex encoded Text xml node.
|
String |
getColumnDelimitor()
Get Method for class field 'columnDelimitor' that gets used in deliminating the CSV, StringBuilder or String conversions.
|
ResultSet |
getRs()
Get Method for this classes ResultSet.
|
static String |
getXmlSchemaType(int type)
lookup method to convert the passed in java.sql.Types int into a XML xsi:type, http://www.w3.org/2001/XMLSchema-instance String.
|
private Text |
hexEncode(InputStream in)
Crerates a HEX encoded Text (String ) object.
|
void |
setColumnDelimitor(String columnDelimitor)
Set Method for class field 'columnDelimitor' that gets used in deliminating the CSV, StringBuilder or String conversions.
|
void |
setRs(ResultSet rs)
Set Method for this classes ResultSet.
|
String |
toString()
Convert to a Delimited String.
|
private Element |
writeXmlArray(Array array)
creates an XML Array element.
|
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
public static final String DEFAULT_COLUMN_DELIMITOR
protected static String columnDelimitor
public ResultSetConverter(ResultSet rs)
public void setRs(ResultSet rs)
rs
- is the value to set this class field to.public ResultSet getRs()
public void setColumnDelimitor(String columnDelimitor)
columnDelimitor
- is the value to set this class field to.public String getColumnDelimitor()
public Document convertToXml() throws IOException, SQLException, JSONException, Exception
IOException
SQLException
JSONException
Exception
private Node convertToXML(ResultSet data, int field, int type) throws SQLException, IOException
SQLException
IOException
private Text hexEncode(InputStream in) throws IOException
IOException
private Element writeXmlArray(Array array) throws IOException, SQLException
IOException
SQLException
public static String getXmlSchemaType(int type)
public JSONArray convertToJson() throws SQLException, JSONException, Exception
SQLException
JSONException
Exception
public String convertToCSVFile(String fileName, boolean includeColumnsHeaders)
fileName
- is the name of the file to savepublic String convertToCSV()
public String convertToCSV(boolean includeColumnsHeaders)
public StringBuilder convertToStringBuilder()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses