Package com.opencsv
Class ResultSetColumnNameHelperService
java.lang.Object
com.opencsv.ResultSetHelperService
com.opencsv.ResultSetColumnNameHelperService
- All Implemented Interfaces:
ResultSetHelper
public class ResultSetColumnNameHelperService
extends ResultSetHelperService
implements ResultSetHelper
Helper class for processing JDBC ResultSet objects allowing the user to
process a subset of columns and set custom header names.
-
Field Summary
FieldsFields inherited from class com.opencsv.ResultSetHelperService
CLOBBUFFERSIZE, dateFormat, dateTimeFormat, DEFAULT_DATE_FORMAT, DEFAULT_TIMESTAMP_FORMAT, floatingPointFormat, integerFormat
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]
Returns the column names from the result set.String[]
Get all the column values from the result set.String[]
getColumnValues
(ResultSet rs, boolean trim) Get all the column values from the result set.String[]
getColumnValues
(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString) Get all the column values from the result set.private String[]
getColumnValueSubset
(String[] realColumnValues) private boolean
hasInvalidValue
(String[] strings) private void
void
setColumnNames
(String[] columnNames, String[] columnHeaders) Set the JDBC column names to use, and the header text for the CSV filevoid
setErrorLocale
(Locale errorLocale) Sets the locale for error messages.Methods inherited from class com.opencsv.ResultSetHelperService
handleClob, handleDate, handleNClob, handleNVarChar, handleTimestamp, handleVarChar, setDateFormat, setDateTimeFormat, setFloatingPointFormat, setIntegerFormat
-
Field Details
-
columnNames
-
columnHeaders
-
columnNamePositionMap
-
errorLocale
-
-
Constructor Details
-
ResultSetColumnNameHelperService
public ResultSetColumnNameHelperService()Nullary constructor.
-
-
Method Details
-
setErrorLocale
Sets the locale for error messages.- Parameters:
errorLocale
- Locale for error messages. If null, the default locale is used.- Since:
- 4.0
-
setColumnNames
Set the JDBC column names to use, and the header text for the CSV file- Parameters:
columnNames
- The JDBC column names to export, in the desired ordercolumnHeaders
- The column headers of the CSV file, in the desired order- Throws:
UnsupportedOperationException
- If the number of headers is different than the number of columns, or if any of the columns or headers is blank or null.
-
hasInvalidValue
-
getColumnNames
Returns the column names from the result set.- Specified by:
getColumnNames
in interfaceResultSetHelper
- Overrides:
getColumnNames
in classResultSetHelperService
- Parameters:
rs
- ResultSet- Returns:
- A string array containing the column names.
- Throws:
SQLException
- Thrown by the result set.
-
populateColumnData
- Throws:
SQLException
-
getColumnValues
Get all the column values from the result set.- Specified by:
getColumnValues
in interfaceResultSetHelper
- Overrides:
getColumnValues
in classResultSetHelperService
- Parameters:
rs
- The ResultSet containing the values.- Returns:
- String array containing all the column values.
- Throws:
SQLException
- Thrown by the result set.IOException
- Thrown by the result set.
-
getColumnValues
Get all the column values from the result set.- Specified by:
getColumnValues
in interfaceResultSetHelper
- Overrides:
getColumnValues
in classResultSetHelperService
- Parameters:
rs
- The ResultSet containing the values.trim
- Values should have white spaces trimmed.- Returns:
- String array containing all the column values.
- Throws:
SQLException
- Thrown by the result set.IOException
- Thrown by the result set.
-
getColumnValues
public String[] getColumnValues(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString) throws SQLException, IOException Get all the column values from the result set.- Specified by:
getColumnValues
in interfaceResultSetHelper
- Overrides:
getColumnValues
in classResultSetHelperService
- Parameters:
rs
- The ResultSet containing the values.trim
- Values should have white spaces trimmed.dateFormatString
- Format string for dates.timeFormatString
- Format string for timestamps.- Returns:
- String array containing all the column values.
- Throws:
SQLException
- Thrown by the result set.IOException
- Thrown by the result set.
-
getColumnValueSubset
-