public class DefaultDataSource extends Object implements DataSource
Modifier and Type | Field and Description |
---|---|
protected Number[][] |
data |
protected String[] |
headerColumn |
protected String[] |
headerRow |
Constructor and Description |
---|
DefaultDataSource()
This no-arg constructor creates an empty data source with no headers.
|
DefaultDataSource(Number[][] data)
This constructor creates a data source with no headers
|
DefaultDataSource(Number[][] data,
String[] headerRow,
String[] headerColumn)
This constructor creates a data source with the given data and headers
|
Modifier and Type | Method and Description |
---|---|
Number[][] |
getAllCells() |
Number |
getCell(int rowIndex,
int colIndex) |
Number[] |
getColumn(int colIndex) |
int |
getColumnCount()
The number of columns of this data source
|
String[] |
getHeaderColumn() |
String |
getHeaderColumnValue(int rowIndex) |
String[] |
getHeaderRow() |
String |
getHeaderRowValue(int columnIndex) |
Number[] |
getRow(int rowIndex) |
int |
getRowCount()
The number of rows of this data source
|
boolean |
hasHeaderColumn() |
boolean |
hasHeaderRow() |
void |
setCell(int rowIndex,
int colIndex,
Number content)
Sets the value of a single cell
|
protected Number[][] data
protected String[] headerRow
protected String[] headerColumn
public DefaultDataSource()
public DefaultDataSource(Number[][] data)
data
- A matrix containing the values of the data sourcepublic DefaultDataSource(Number[][] data, String[] headerRow, String[] headerColumn)
data
- A matrix containing the values of the data sourceheaderRow
- The header row with headerRow.length == data[x].length, for x=0,data.length-1headerColumn
- The header column with headerColumn.length == data.lengthIllegalArgumentException
- Thrown when the conditions above are not satisfiedpublic int getRowCount()
getRowCount
in interface DataSource
public int getColumnCount()
getColumnCount
in interface DataSource
public Number getCell(int rowIndex, int colIndex) throws DataSourceException
getCell
in interface DataSource
RowIndexOutOfBoundsException
ColumnIndexOutOfBoundsException
DataSourceException
public void setCell(int rowIndex, int colIndex, Number content) throws DataSourceException
public Number[] getRow(int rowIndex) throws DataSourceException
getRow
in interface DataSource
RowIndexOutOfBoundsException
DataSourceException
public Number[] getColumn(int colIndex) throws DataSourceException
getColumn
in interface DataSource
ColumnIndexOutOfBoundsException
DataSourceException
public Number[][] getAllCells() throws DataSourceException
getAllCells
in interface DataSource
DataSourceException
public boolean hasHeaderRow() throws DataSourceException
hasHeaderRow
in interface DataSource
DataSourceException
public boolean hasHeaderColumn() throws DataSourceException
hasHeaderColumn
in interface DataSource
DataSourceException
public String getHeaderRowValue(int columnIndex) throws DataSourceException
getHeaderRowValue
in interface DataSource
NoHeaderRowException
ColumnIndexOutOfBoundsException
DataSourceException
public String[] getHeaderRow() throws DataSourceException
getHeaderRow
in interface DataSource
NoHeaderRowException
DataSourceException
public String getHeaderColumnValue(int rowIndex) throws DataSourceException
getHeaderColumnValue
in interface DataSource
NoHeaderColumnException
RowIndexOutOfBoundsException
DataSourceException
public String[] getHeaderColumn() throws DataSourceException
getHeaderColumn
in interface DataSource
NoHeaderColumnException
DataSourceException
Copyright © 2004–2019 XWiki. All rights reserved.