public class VOTableIterator extends java.lang.Object implements TableIterator
TableIterator
which lets iterate over a VOTable input stream using STIL.
getColType()
will return TAP type based on the type declared in the VOTable metadata part.
Modifier and Type | Class and Description |
---|---|
protected static class |
VOTableIterator.StreamVOTableSink
This class lets consume the metadata and rows of a VOTable document.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
endReached
Indicate whether the last row has already been reached.
|
protected int |
indCol
|
protected java.io.InputStream |
input
Stream containing the VOTable on which this
TableIterator is iterating. |
protected boolean |
iterationStarted
Indicate whether the row iteration has already started.
|
protected int |
nbCol
Number of columns available according to the metadata.
|
protected java.lang.Object[] |
row
The last read row.
|
protected VOTableIterator.StreamVOTableSink |
sink
The StarTable consumer which is used to iterate on each row.
|
protected static java.lang.String |
STREAM_ABORTED_MESSAGE
Message of the IOException sent when the streaming is aborted.
|
Constructor and Description |
---|
VOTableIterator(java.io.InputStream input)
Build a TableIterator able to read rows and columns inside the given VOTable input stream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkReadState()
Check the row iteration state.
|
void |
close()
Close the stream or input over which this class iterates.
|
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.
|
boolean |
nextRow()
Go to the next row if there is one.
|
static VotType |
resolveVotType(java.lang.String datatype,
java.lang.String arraysize,
java.lang.String xtype)
Resolve a VOTable field type by using the datatype, arraysize and xtype strings as specified in a VOTable document.
|
protected static final java.lang.String STREAM_ABORTED_MESSAGE
protected final java.io.InputStream input
TableIterator
is iterating.protected final VOTableIterator.StreamVOTableSink sink
protected boolean iterationStarted
protected boolean endReached
protected java.lang.Object[] row
protected int indCol
protected int nbCol
public VOTableIterator(java.io.InputStream input) throws DataReadException
input
- Input stream over a VOTable document.java.lang.NullPointerException
- If NULL is given in parameter.DataReadException
- If the given VOTable can not be parsed.public TAPColumn[] getMetadata() throws DataReadException
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.DataReadException
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
TableIterator
Return the value of the next column.
Note: The column type can be fetched using TableIterator.getColType()
after a call to TableIterator.nextCol()
.
nextCol
in interface TableIterator
java.util.NoSuchElementException
- If no more column value is available.java.lang.IllegalStateException
- If TableIterator.nextRow()
has not yet been called.DataReadException
- If an error occurs while reading the table dataset.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.public void close() throws DataReadException
TableIterator
close
in interface TableIterator
DataReadException
- If any error occurs while closing it.protected void checkReadState() throws java.lang.IllegalStateException
Check the row iteration state. That's to say whether:
nextRow()
has been donejava.lang.IllegalStateException
public static VotType resolveVotType(java.lang.String datatype, java.lang.String arraysize, java.lang.String xtype) throws DataReadException
datatype
- Attribute value of VOTable corresponding to the datatype.arraysize
- Attribute value of VOTable corresponding to the arraysize.xtype
- Attribute value of VOTable corresponding to the xtype.DataReadException
- If a field datatype is unknown or missing.