public class ResultSetTableIterator extends java.lang.Object implements TableIterator
TableIterator
which lets iterate over a SQL ResultSet
.
Note:
getColType()
will return a TAP type based on the one declared in the ResultSetMetaData
object.
Constructor and Description |
---|
ResultSetTableIterator(DBConnection dbConn,
java.sql.ResultSet dataSet)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(DBConnection dbConn,
java.sql.ResultSet dataSet,
DBColumn[] metadata)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(DBConnection dbConn,
java.sql.ResultSet dataSet,
DBColumn[] resultMeta,
JDBCTranslator translator,
java.lang.String dbms)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(DBConnection dbConn,
java.sql.ResultSet dataSet,
JDBCTranslator translator,
java.lang.String dbms)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(java.sql.ResultSet dataSet)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(java.sql.ResultSet dataSet,
DBColumn[] resultMeta)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(java.sql.ResultSet dataSet,
DBColumn[] resultMeta,
JDBCTranslator translator,
java.lang.String dbms)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(java.sql.ResultSet dataSet,
JDBCTranslator translator)
Deprecated.
Use
ResultSetTableIterator(ResultSet, JDBCTranslator, String) instead ; using the translator without the DBMS name is generally not enough.
It is then preferable to give also the DBMS name. |
ResultSetTableIterator(java.sql.ResultSet dataSet,
JDBCTranslator translator,
java.lang.String dbms)
Build a TableIterator able to read rows and columns of the given ResultSet.
|
ResultSetTableIterator(java.sql.ResultSet dataSet,
JDBCTranslator translator,
java.lang.String dbms,
DBColumn[] resultMeta)
Deprecated.
Use
ResultSetTableIterator(ResultSet, DBColumn[], JDBCTranslator, String) instead ; only the position of the parameters has changed. |
ResultSetTableIterator(java.sql.ResultSet dataSet,
java.lang.String dbms)
Deprecated.
Use
ResultSetTableIterator(ResultSet, JDBCTranslator, String) instead ; using the translator without the DBMS name is generally not enough.
It is then preferable to give also the DBMS name. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream or input over which this class iterates.
|
protected DBType |
convertType(int dbmsType,
java.lang.String dbmsTypeName,
java.lang.String dbms)
Convert the given DBMS type into the corresponding
DBType instance. |
protected DBType |
defaultTypeConversion(java.lang.String dbmsTypeName,
java.lang.String[] params,
java.lang.String dbms)
Convert the given DBMS type into the better matching
DBType instance. |
protected java.lang.Object |
formatColValue(java.lang.Object colValue)
Format the given column value.
|
DBType |
getColType()
Get the type of the current column value.
|
TAPColumn[] |
getMetadata()
Get all the metadata column that have been successfully extracted at the creation of this iterator.
|
boolean |
hasNextCol()
Tell whether another column is available.
|
java.lang.Object |
nextCol()
Return the value of the next column and format it (see
formatColValue(Object) ). |
boolean |
nextRow()
Go to the next row if there is one.
|
public ResultSetTableIterator(java.sql.ResultSet dataSet) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call defaultTypeConversion(String, String[], String)
which proceeds a default conversion using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
dataSet
- Dataset over which this iterator must iterate.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(java.sql.ResultSet dataSet, DBColumn[] resultMeta) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is reading first the given metadata (if any),
and then, try to guess the datatype from the DBMS column datatype (using convertType(int, String, String)
).
The second parameter of this constructor aims to provide the metadata expected for each column of the ResultSet.
For that, it is expected that all these metadata are TAPColumn
objects. Indeed, simple DBColumn
instances do not have the type information. If just DBColumn
s are provided, the ADQL name it provides will be kept
but the type will be guessed from the type provided by the ResultSetMetadata.
Note:
If this parameter is incomplete (array length less than the column count returned by the ResultSet or some array items are NULL),
column metadata will be associated in the same order as the ResultSet columns. Missing metadata will be built from the
ResultSetMetaData
and so the types will be guessed.
In order to guess a TAP type from a DBMS type, this constructor will call defaultTypeConversion(String, String[], String)
which proceeds a default conversion using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
dataSet
- Dataset over which this iterator must iterate.resultMeta
- List of expected columns. note: these metadata are expected to be really TAPColumn
objects ; MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
@Deprecated public ResultSetTableIterator(java.sql.ResultSet dataSet, java.lang.String dbms) throws java.lang.NullPointerException, DataReadException
ResultSetTableIterator(ResultSet, JDBCTranslator, String)
instead ; using the translator without the DBMS name is generally not enough.
It is then preferable to give also the DBMS name.Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which deals with the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by a translator. That's why it is recommended
to use one of the constructor having a JDBCTranslator
in parameter.
Important:
The second parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dataSet
- Dataset over which this iterator must iterate.dbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
@Deprecated public ResultSetTableIterator(java.sql.ResultSet dataSet, JDBCTranslator translator) throws java.lang.NullPointerException, DataReadException
ResultSetTableIterator(ResultSet, JDBCTranslator, String)
instead ; using the translator without the DBMS name is generally not enough.
It is then preferable to give also the DBMS name.Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
dataSet
- Dataset over which this iterator must iterate.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLjava.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(java.sql.ResultSet dataSet, JDBCTranslator translator, java.lang.String dbms) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
Important:
The third parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the translator conversion failed and when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dataSet
- Dataset over which this iterator must iterate.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLdbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
@Deprecated public ResultSetTableIterator(java.sql.ResultSet dataSet, JDBCTranslator translator, java.lang.String dbms, DBColumn[] resultMeta) throws java.lang.NullPointerException, DataReadException
ResultSetTableIterator(ResultSet, DBColumn[], JDBCTranslator, String)
instead ; only the position of the parameters has changed.Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is reading first the given metadata (if any),
and then, try to guess the datatype from the DBMS column datatype (using convertType(int, String, String)
).
The third parameter of this constructor aims to provide the metadata expected for each column of the ResultSet.
For that, it is expected that all these metadata are TAPColumn
objects. Indeed, simple DBColumn
instances do not have the type information. If just DBColumn
s are provided, the ADQL name it provides will be kept
but the type will be guessed from the type provide by the ResultSetMetadata.
Note:
If this parameter is incomplete (array length less than the column count returned by the ResultSet or some array items are NULL),
column metadata will be associated in the same order as the ResultSet columns. Missing metadata will be built from the
ResultSetMetaData
and so the types will be guessed.
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
Important:
The third parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the translator conversion failed and when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dataSet
- Dataset over which this iterator must iterate.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLdbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.resultMeta
- List of expected columns. note: these metadata are expected to be really TAPColumn
objects ; MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(java.sql.ResultSet dataSet, DBColumn[] resultMeta, JDBCTranslator translator, java.lang.String dbms) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is reading first the given metadata (if any),
and then, try to guess the datatype from the DBMS column datatype (using convertType(int, String, String)
).
The second parameter of this constructor aims to provide the metadata expected for each column of the ResultSet.
For that, it is expected that all these metadata are TAPColumn
objects. Indeed, simple DBColumn
instances do not have the type information. If just DBColumn
s are provided, the ADQL name it provides will be kept
but the type will be guessed from the type provided by the ResultSetMetadata.
Note:
If this parameter is incomplete (array length less than the column count returned by the ResultSet or some array items are NULL),
column metadata will be associated in the same order as the ResultSet columns. Missing metadata will be built from the
ResultSetMetaData
and so the types will be guessed.
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
Important:
The fourth parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the translator conversion failed and when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dataSet
- Dataset over which this iterator must iterate.resultMeta
- List of expected columns. note: these metadata are expected to be really TAPColumn
objects ; MAY be NULL.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLdbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(DBConnection dbConn, java.sql.ResultSet dataSet) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call defaultTypeConversion(String, String[], String)
which proceeds a default conversion using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
dbConn
- DBConnection
instance which has provided the given result.dataSet
- Dataset over which this iterator must iterate.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(DBConnection dbConn, java.sql.ResultSet dataSet, DBColumn[] metadata) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
The third parameter of this constructor aims to provide the metadata expected for each column of the ResultSet.
For that, it is expected that all these metadata are TAPColumn
objects. Indeed, simple DBColumn
instances do not have the type information. If just DBColumn
s are provided, the ADQL name it provides will be kept
but the type will be guessed from the type provided by the ResultSetMetadata.
Note:
If this parameter is incomplete (array length less than the column count returned by the ResultSet or some array items are NULL),
column metadata will be associated in the same order as the ResultSet columns. Missing metadata will be built from the
ResultSetMetaData
and so the types will be guessed.
In order to guess a TAP type from a DBMS type, this constructor will call defaultTypeConversion(String, String[], String)
which proceeds a default conversion using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
dbConn
- DBConnection
instance which has provided the given result.dataSet
- Dataset over which this iterator must iterate.metadata
- List of expected columns. note: these metadata are expected to be really TAPColumn
objects ; MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(DBConnection dbConn, java.sql.ResultSet dataSet, JDBCTranslator translator, java.lang.String dbms) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is trying to guess the datatype
from the DBMS column datatype (using convertType(int, String, String)
).
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
Important:
The fourth parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the translator conversion failed and when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dbConn
- DBConnection
instance which has provided the given result.dataSet
- Dataset over which this iterator must iterate.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLdbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given ResultSet is closed or if the metadata (columns count and types) can not be fetched.ResultSetTableIterator(DBConnection, ResultSet, DBColumn[], JDBCTranslator, String)
public ResultSetTableIterator(DBConnection dbConn, java.sql.ResultSet dataSet, DBColumn[] resultMeta, JDBCTranslator translator, java.lang.String dbms) throws java.lang.NullPointerException, DataReadException
Build a TableIterator able to read rows and columns of the given ResultSet.
In order to provide the metadata through getMetadata()
, this constructor is reading first the given metadata (if any),
and then, try to guess the datatype from the DBMS column datatype (using convertType(int, String, String)
).
The third parameter of this constructor aims to provide the metadata expected for each column of the ResultSet.
For that, it is expected that all these metadata are TAPColumn
objects. Indeed, simple DBColumn
instances do not have the type information. If just DBColumn
s are provided, the ADQL name it provides will be kept
but the type will be guessed from the type provided by the ResultSetMetadata.
Note:
If this parameter is incomplete (array length less than the column count returned by the ResultSet or some array items are NULL),
column metadata will be associated in the same order as the ResultSet columns. Missing metadata will be built from the
ResultSetMetaData
and so the types will be guessed.
In order to guess a TAP type from a DBMS type, this constructor will call convertType(int, String, String)
which will ask to the given translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
)
if not NULL. However if no translator is provided, this function will proceed to a default conversion
using the most common standard datatypes known in Postgres, SQLite, MySQL, Oracle and JavaDB/Derby.
This conversion is therefore not as precise as the one expected by the translator.
Important:
The fifth parameter of this constructor is given as second parameter of convertType(int, String, String)
.
This parameter is really used ONLY when the translator conversion failed and when the DBMS is SQLite ("sqlite").
Indeed, SQLite has so many datatype restrictions that it is absolutely needed to know it is the DBMS from which the
ResultSet is coming. Without this information, type guessing will be unpredictable!
dbConn
- DBConnection
instance which has provided the given result.dataSet
- Dataset over which this iterator must iterate.resultMeta
- List of expected columns. note: these metadata are expected to be really TAPColumn
objects ; MAY be NULL.translator
- The JDBCTranslator
used to transform the ADQL query into SQL query. This translator is also able to convert
JDBC types and to parse geometrical values. note: MAY be NULLdbms
- Lower-case string which indicates from which DBMS the given ResultSet is coming. note: MAY be NULL.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the metadata (columns count and types) can not be fetched.convertType(int, String, String)
public void close() throws DataReadException
TableIterator
close
in interface TableIterator
DataReadException
- If any error occurs while closing it.public TAPColumn[] getMetadata()
TableIterator
Get all the metadata column that have been successfully extracted at the creation of this iterator.
Important: This function should be callable at any moment from the creation of the iterator until the end of the table dataset has been reached.
Note: This function MAY BE NOT IMPLEMENTED or the metadata can not be fetched. In this case, NULL will be returned.
Warning: If the metadata part of the original document is corrupted (i.e. false number of columns),
the column type information should be fetched thanks to TableIterator.getColType()
while iterating over rows and columns.
getMetadata
in interface TableIterator
TAPColumn
objects (each for a column of any row),
or NULL if this function is not implemented OR if it was not possible to get these metadata.TableIterator.getColType()
public boolean nextRow() throws DataReadException
TableIterator
Go to the next row if there is one.
Note: After a call to this function the columns must be fetched individually using TableIterator.nextCol()
IF this function returned true.
nextRow
in interface TableIterator
DataReadException
- If an error occurs while reading the table dataset.public boolean hasNextCol() throws java.lang.IllegalStateException, DataReadException
TableIterator
hasNextCol
in interface TableIterator
TableIterator.nextCol()
will return the value of the next column with no error,
false otherwise.java.lang.IllegalStateException
- If TableIterator.nextRow()
has not yet been called.DataReadException
- If an error occurs while reading the table dataset.public java.lang.Object nextCol() throws java.util.NoSuchElementException, java.lang.IllegalStateException, DataReadException
Return the value of the next column and format it (see formatColValue(Object)
).
Note: The column type can be fetched using getColType()
after a call to nextCol()
.
nextCol
in interface TableIterator
java.util.NoSuchElementException
- If no more column value is available.java.lang.IllegalStateException
- If nextRow()
has not yet been called.DataReadException
- If an error occurs while reading the table dataset.TableIterator.nextCol()
,
formatColValue(Object)
protected java.lang.Object formatColValue(java.lang.Object colValue) throws DataReadException
Format the given column value.
This function should be overwritten if a different or additional formatting should be performed before, after or instead of the one implemented here by default.
By default, the following function performs the following formatting:
Timestamp
, Date
or Time
: the date-time is converted into a string with the ISO8601 format (see ISO8601Format
).Character
object.colValue
- A column value as provided by a ResultSet
.DataReadException
- In case a formatting can not be performed.public DBType getColType() throws java.lang.IllegalStateException, DataReadException
TableIterator
Get the type of the current column value.
Note 1: "Current column value" means here "the value last returned by TableIterator.nextCol()
".
Note 2: This function MAY BE NOT IMPLEMENTED or the type information can not be fetched. If this is the case, NULL will be returned.
Warning: In some cases, the metadata part of the original document does not match with the data
it should have represented. In such case, the types returned here and by TableIterator.getMetadata()
would be different.
In case of such mismatch, the type returned by TableIterator.getColType()
should be considered as more correct/accurate.
getColType
in interface TableIterator
java.lang.IllegalStateException
- If TableIterator.nextCol()
has not yet been called.DataReadException
- If an error occurs while reading the table dataset.protected DBType convertType(int dbmsType, java.lang.String dbmsTypeName, java.lang.String dbms) throws DataReadException
Convert the given DBMS type into the corresponding DBType
instance.
This function first tries the conversion using the translator (JDBCTranslator.convertTypeFromDB(int, String, String, String[])
).
If the translator fails, a default conversion is done.
Warning:
It is not recommended to rely on the default conversion.
This conversion is just a matter of guessing the better matching DBType
considering the types of the following DBMS: PostgreSQL, SQLite, MySQL, Oracle and Java/DB/Derby.
dbmsType
- DBMS column data-type name.dbms
- Lower-case string which indicates which DBMS the ResultSet is coming from. note: MAY be NULL.DBType
object,
or an UNKNOWN
type if none can be found.DataReadException
JDBCTranslator.convertTypeFromDB(int, String, String, String[])
,
defaultTypeConversion(String, String[], String)
protected final DBType defaultTypeConversion(java.lang.String dbmsTypeName, java.lang.String[] params, java.lang.String dbms)
Convert the given DBMS type into the better matching DBType
instance.
This function is used to guess the TAP type of a column when it is not provided in the constructor.
It aims not to be exhaustive, but just to provide a type when the given TAP metadata are incomplete.
Note: Any unknown DBMS data-type will be considered and translated as a VARCHAR. This latter will be also returned if the given parameter is an empty string or NULL.
Note: This type conversion function has been designed to work with all standard data-types of the following DBMS: PostgreSQL, SQLite, MySQL, Oracle and JavaDB/Derby.
Important: The third parameter is REALLY NEEDED when the DBMS is SQLite ("sqlite")! Indeed, SQLite has a so restrictive list of data-types that this function can reliably convert only if it knows the DBMS is SQLite. Otherwise, the conversion result would be unpredictable. In this default implementation of this function, all other DBMS values are ignored.
Warning: This function is not translating the geometrical data-types. If a such data-type is encountered, it will considered as unknown and so, a VARCHAR TAP type will be returned.
dbmsTypeName
- Name of type, without the eventual parameters.params
- The eventual type parameters (e.g. char string length).dbms
- The targeted DBMS.UNKNOWN
type is returned in case no match can be found.