Top Description Fields Constructors Methods
com.opencsv

public Class ResultSetHelperService

extends Object
implements ResultSetHelper
Class Inheritance
All Implemented Interfaces
com.opencsv.ResultSetHelper
Known Direct Subclasses
com.opencsv.ResultSetColumnNameHelperService
Imports
org.apache.commons.lang3.StringUtils, org.apache.commons.text.TextStringBuilder, java.io.IOException, java.sql.*, java.text.NumberFormat, .SimpleDateFormat, java.util.Objects

Helper class for processing JDBC ResultSet objects.

Field Summary

Modifier and TypeField and Description
protected static final int
protected String
protected String
pack-priv static final String
pack-priv static final String
protected NumberFormat
protected NumberFormat
private static final String
protected String

Constructor Summary

AccessConstructor and Description
public
ResultSetHelperService()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
private String
public String[]
getColumnNames(ResultSet rs)

Implements com.opencsv.ResultSetHelper.getColumnNames.

Returns the column names from the ResultSet.

private String
getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString, String timestampFormatString)

public String[]
getColumnValues(ResultSet rs)

Implements com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set.

public String[]
getColumnValues(ResultSet rs, boolean trim)

Implements com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set with the values trimmed if desired.

public String[]
getColumnValues(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString)

Implements com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set with the values trimmed if desired.

protected String

Returns:

the data in the Clob as a string.
handleClob
(ResultSet
- result set
rs
,
int
- column location of the data in the result set
colIndex
)

retrieves the data out of a CLOB

protected String

Returns:

- a string representing the data from the result set in the format set in dateFomratString.
handleDate
(ResultSet
- result set
rs
,
int
- column location of the data in the result set
colIndex
,
String
- desired format of the date
dateFormatString
)

retrieves an date from a result set

protected String

Returns:

the data in the NCLOB as a string.
handleNClob
(ResultSet
- result set
rs
,
int
- column location of the data in the result set
colIndex
)

retrieves the data out of a NCLOB

protected String

Returns:

a string representing the NVarChar from the result set
handleNVarChar
(ResultSet
- result set
rs
,
int
- column location of the data in the result set
colIndex
,
boolean
- should the value be trimmed before being returned
trim
)

retrieves the data from an NVarChar in a result set

protected String

Returns:

Formatted time stamp.
handleTimestamp
(Timestamp
Timestamp read from resultset
timestamp
,
String
Format string
timestampFormatString
)

The formatted timestamp.

protected String

Returns:

a string representing the VarChar from the result set
handleVarChar
(ResultSet
- result set
rs
,
int
- column location of the data in the result set
colIndex
,
boolean
- should the value be trimmed before being returned
trim
)

retrieves the data from an VarChar in a result set

public void
setDateFormat(String
Desired date format
dateFormat
)

Set a default date format pattern that will be used by the service.

public void
setDateTimeFormat(String
Desired date time format
dateTimeFormat
)

Set a default date time format pattern that will be used by the service.

public void
setFloatingPointFormat(NumberFormat
Desired number format. Should not be null
format
)

Set a default number formatter for integer numbers that will be used by the service.

public void
setIntegerFormat(NumberFormat
Desired number format. Should not be null
format
)

Set a default number formatter for floating point numbers that will be used by the service.

public void
setNullDefault(String nullDefault)

Set a default value that will be used when column value is null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLOBBUFFERSIZEback to summary
protected static final int CLOBBUFFERSIZE
dateFormatback to summary
protected String dateFormat
dateTimeFormatback to summary
protected String dateTimeFormat
DEFAULT_DATE_FORMATback to summary
pack-priv static final String DEFAULT_DATE_FORMAT
DEFAULT_TIMESTAMP_FORMATback to summary
pack-priv static final String DEFAULT_TIMESTAMP_FORMAT
floatingPointFormatback to summary
protected NumberFormat floatingPointFormat
integerFormatback to summary
protected NumberFormat integerFormat
NULL_DEFAULT_VALUEback to summary
private static final String NULL_DEFAULT_VALUE
nullDefaultback to summary
protected String nullDefault

Constructor Detail

ResultSetHelperServiceback to summary
public ResultSetHelperService()

Default constructor.

Method Detail

applyFormatterback to summary
private String applyFormatter(NumberFormat formatter, Number value)
getColumnNamesback to summary
public String[] getColumnNames(ResultSet rs) throws SQLException

Implements com.opencsv.ResultSetHelper.getColumnNames.

Doc from com.opencsv.ResultSetHelper.getColumnNames.

Returns the column names from the ResultSet.

Annotations
@Override
Exceptions
SQLException:
Thrown by the ResultSet.
getColumnValueback to summary
private String getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString, String timestampFormatString) throws SQLException, IOException
getColumnValuesback to summary
public String[] getColumnValues(ResultSet rs) throws SQLException, IOException

Implements com.opencsv.ResultSetHelper.getColumnValues.

Doc from com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set.

Annotations
@Override
Exceptions
SQLException:
Thrown by the ResultSet.
IOException:
Thrown by the ResultSet.
getColumnValuesback to summary
public String[] getColumnValues(ResultSet rs, boolean trim) throws SQLException, IOException

Implements com.opencsv.ResultSetHelper.getColumnValues.

Doc from com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set with the values trimmed if desired.

Annotations
@Override
Exceptions
SQLException:
Thrown by the ResultSet.
IOException:
Thrown by the ResultSet.
getColumnValuesback to summary
public String[] getColumnValues(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString) throws SQLException, IOException

Implements com.opencsv.ResultSetHelper.getColumnValues.

Doc from com.opencsv.ResultSetHelper.getColumnValues.

Returns the column values from the result set with the values trimmed if desired. Also format the date and time columns based on the format strings passed in.

Annotations
@Override
Exceptions
SQLException:
Thrown by the ResultSet.
IOException:
Thrown by the ResultSet.
handleClobback to summary
protected String handleClob(ResultSet rs, int colIndex) throws SQLException, IOException

retrieves the data out of a CLOB

Parameters
rs:ResultSet

- result set

colIndex:int

- column location of the data in the result set

Returns:String

the data in the Clob as a string.

handleDateback to summary
protected String handleDate(ResultSet rs, int colIndex, String dateFormatString) throws SQLException

retrieves an date from a result set

Parameters
rs:ResultSet

- result set

colIndex:int

- column location of the data in the result set

dateFormatString:String

- desired format of the date

Returns:String

- a string representing the data from the result set in the format set in dateFomratString.

handleNClobback to summary
protected String handleNClob(ResultSet rs, int colIndex) throws SQLException, IOException

retrieves the data out of a NCLOB

Parameters
rs:ResultSet

- result set

colIndex:int

- column location of the data in the result set

Returns:String

the data in the NCLOB as a string.

handleNVarCharback to summary
protected String handleNVarChar(ResultSet rs, int colIndex, boolean trim) throws SQLException

retrieves the data from an NVarChar in a result set

Parameters
rs:ResultSet

- result set

colIndex:int

- column location of the data in the result set

trim:boolean

- should the value be trimmed before being returned

Returns:String

a string representing the NVarChar from the result set

handleTimestampback to summary
protected String handleTimestamp(Timestamp timestamp, String timestampFormatString)

The formatted timestamp.

Parameters
timestamp:Timestamp

Timestamp read from resultset

timestampFormatString:String

Format string

Returns:String

Formatted time stamp.

handleVarCharback to summary
protected String handleVarChar(ResultSet rs, int colIndex, boolean trim) throws SQLException

retrieves the data from an VarChar in a result set

Parameters
rs:ResultSet

- result set

colIndex:int

- column location of the data in the result set

trim:boolean

- should the value be trimmed before being returned

Returns:String

a string representing the VarChar from the result set

setDateFormatback to summary
public void setDateFormat(String dateFormat)

Set a default date format pattern that will be used by the service.

Parameters
dateFormat:String

Desired date format

setDateTimeFormatback to summary
public void setDateTimeFormat(String dateTimeFormat)

Set a default date time format pattern that will be used by the service.

Parameters
dateTimeFormat:String

Desired date time format

setFloatingPointFormatback to summary
public void setFloatingPointFormat(NumberFormat format)

Set a default number formatter for integer numbers that will be used by the service.

Parameters
format:NumberFormat

Desired number format. Should not be null

setIntegerFormatback to summary
public void setIntegerFormat(NumberFormat format)

Set a default number formatter for floating point numbers that will be used by the service.

Parameters
format:NumberFormat

Desired number format. Should not be null

setNullDefaultback to summary
public void setNullDefault(String nullDefault)

Set a default value that will be used when column value is null.