Class DefaultDataSource
- java.lang.Object
-
- com.xpn.xwiki.plugin.charts.source.DefaultDataSource
-
- All Implemented Interfaces:
DataSource
public class DefaultDataSource extends Object implements DataSource
-
-
Constructor Summary
Constructors Constructor 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 headersDefaultDataSource(Number[][] data, String[] headerRow, String[] headerColumn)
This constructor creates a data source with the given data and headers
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Number[][]
getAllCells()
Number
getCell(int rowIndex, int colIndex)
Number[]
getColumn(int colIndex)
int
getColumnCount()
The number of columns of this data sourceString[]
getHeaderColumn()
String
getHeaderColumnValue(int rowIndex)
String[]
getHeaderRow()
String
getHeaderRowValue(int columnIndex)
Number[]
getRow(int rowIndex)
int
getRowCount()
The number of rows of this data sourceboolean
hasHeaderColumn()
boolean
hasHeaderRow()
void
setCell(int rowIndex, int colIndex, Number content)
Sets the value of a single cell
-
-
-
Constructor Detail
-
DefaultDataSource
public DefaultDataSource()
This no-arg constructor creates an empty data source with no headers.
-
DefaultDataSource
public DefaultDataSource(Number[][] data)
This constructor creates a data source with no headers- Parameters:
data
- A matrix containing the values of the data source
-
DefaultDataSource
public DefaultDataSource(Number[][] data, String[] headerRow, String[] headerColumn)
This constructor creates a data source with the given data and headers- Parameters:
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.length- Throws:
IllegalArgumentException
- Thrown when the conditions above are not satisfied
-
-
Method Detail
-
getRowCount
public int getRowCount()
The number of rows of this data source- Specified by:
getRowCount
in interfaceDataSource
-
getColumnCount
public int getColumnCount()
The number of columns of this data source- Specified by:
getColumnCount
in interfaceDataSource
-
getCell
public Number getCell(int rowIndex, int colIndex) throws DataSourceException
- Specified by:
getCell
in interfaceDataSource
- Returns:
- The value of a single cell
- Throws:
RowIndexOutOfBoundsException
ColumnIndexOutOfBoundsException
DataSourceException
-
setCell
public void setCell(int rowIndex, int colIndex, Number content) throws DataSourceException
Sets the value of a single cell
-
getRow
public Number[] getRow(int rowIndex) throws DataSourceException
- Specified by:
getRow
in interfaceDataSource
- Returns:
- A whole row
- Throws:
RowIndexOutOfBoundsException
DataSourceException
-
getColumn
public Number[] getColumn(int colIndex) throws DataSourceException
- Specified by:
getColumn
in interfaceDataSource
- Returns:
- A whole column
- Throws:
ColumnIndexOutOfBoundsException
DataSourceException
-
getAllCells
public Number[][] getAllCells() throws DataSourceException
- Specified by:
getAllCells
in interfaceDataSource
- Returns:
- A matrix containing the all data source values
- Throws:
DataSourceException
-
hasHeaderRow
public boolean hasHeaderRow() throws DataSourceException
- Specified by:
hasHeaderRow
in interfaceDataSource
- Returns:
- true when this data source has a header row
- Throws:
DataSourceException
-
hasHeaderColumn
public boolean hasHeaderColumn() throws DataSourceException
- Specified by:
hasHeaderColumn
in interfaceDataSource
- Returns:
- true when this data source has a header column
- Throws:
DataSourceException
-
getHeaderRowValue
public String getHeaderRowValue(int columnIndex) throws DataSourceException
- Specified by:
getHeaderRowValue
in interfaceDataSource
- Returns:
- the value in the header row, given by columnIndex
- Throws:
NoHeaderRowException
ColumnIndexOutOfBoundsException
DataSourceException
-
getHeaderRow
public String[] getHeaderRow() throws DataSourceException
- Specified by:
getHeaderRow
in interfaceDataSource
- Returns:
- The whole header row
- Throws:
NoHeaderRowException
DataSourceException
-
getHeaderColumnValue
public String getHeaderColumnValue(int rowIndex) throws DataSourceException
- Specified by:
getHeaderColumnValue
in interfaceDataSource
- Returns:
- the value in the header column, given by rowIndex
- Throws:
NoHeaderColumnException
RowIndexOutOfBoundsException
DataSourceException
-
getHeaderColumn
public String[] getHeaderColumn() throws DataSourceException
- Specified by:
getHeaderColumn
in interfaceDataSource
- Returns:
- The whole header column
- Throws:
NoHeaderColumnException
DataSourceException
-
-