com.xpn.xwiki.plugin.charts.source
Class DefaultDataSource

java.lang.Object
  extended by com.xpn.xwiki.plugin.charts.source.DefaultDataSource
All Implemented Interfaces:
DataSource
Direct Known Subclasses:
TableDataSource

public class DefaultDataSource
extends java.lang.Object
implements DataSource


Field Summary
protected  java.lang.Number[][] data
           
protected  java.lang.String[] headerColumn
           
protected  java.lang.String[] headerRow
           
 
Constructor Summary
DefaultDataSource()
          This no-arg constructor creates an empty data source with no headers.
DefaultDataSource(java.lang.Number[][] data)
          This constructor creates a data source with no headers
DefaultDataSource(java.lang.Number[][] data, java.lang.String[] headerRow, java.lang.String[] headerColumn)
          This constructor creates a data source with the given data and headers
 
Method Summary
private  void checkColumnIndex(int columnIndex)
           
private  void checkHeaderColumn()
           
private  void checkHeaderRow()
           
private  void checkRowIndex(int rowIndex)
           
 java.lang.Number[][] getAllCells()
           
 java.lang.Number getCell(int rowIndex, int colIndex)
           
 java.lang.Number[] getColumn(int colIndex)
           
 int getColumnCount()
          The number of columns of this data source
 java.lang.String[] getHeaderColumn()
           
 java.lang.String getHeaderColumnValue(int rowIndex)
           
 java.lang.String[] getHeaderRow()
           
 java.lang.String getHeaderRowValue(int columnIndex)
           
 java.lang.Number[] getRow(int rowIndex)
           
 int getRowCount()
          The number of rows of this data source
 boolean hasHeaderColumn()
           
 boolean hasHeaderRow()
           
 void setCell(int rowIndex, int colIndex, java.lang.Number content)
          Sets the value of a single cell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.lang.Number[][] data

headerRow

protected java.lang.String[] headerRow

headerColumn

protected java.lang.String[] headerColumn
Constructor Detail

DefaultDataSource

public DefaultDataSource()
This no-arg constructor creates an empty data source with no headers.


DefaultDataSource

public DefaultDataSource(java.lang.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(java.lang.Number[][] data,
                         java.lang.String[] headerRow,
                         java.lang.String[] headerColumn)
This constructor creates a data source with the given data and headers

Parameters:
data - A matrix containing the values of the data source
headerRow - The header row with headerRow.length == data[x].length, for x=0,data.length-1
headerColumn - The header column with headerColumn.length == data.length
Throws:
java.lang.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 interface DataSource

getColumnCount

public int getColumnCount()
The number of columns of this data source

Specified by:
getColumnCount in interface DataSource

getCell

public java.lang.Number getCell(int rowIndex,
                                int colIndex)
                         throws DataSourceException
Specified by:
getCell in interface DataSource
Returns:
The value of a single cell
Throws:
RowIndexOutOfBoundsException
ColumnIndexOutOfBoundsException
DataSourceException

setCell

public void setCell(int rowIndex,
                    int colIndex,
                    java.lang.Number content)
             throws DataSourceException
Sets the value of a single cell

Throws:
RowIndexOutOfBoundsException
ColumnIndexOutOfBoundsException
DataSourceException

getRow

public java.lang.Number[] getRow(int rowIndex)
                          throws DataSourceException
Specified by:
getRow in interface DataSource
Returns:
A whole row
Throws:
RowIndexOutOfBoundsException
DataSourceException

getColumn

public java.lang.Number[] getColumn(int colIndex)
                             throws DataSourceException
Specified by:
getColumn in interface DataSource
Returns:
A whole column
Throws:
ColumnIndexOutOfBoundsException
DataSourceException

getAllCells

public java.lang.Number[][] getAllCells()
                                 throws DataSourceException
Specified by:
getAllCells in interface DataSource
Returns:
A matrix containing the all data source values
Throws:
DataSourceException

hasHeaderRow

public boolean hasHeaderRow()
                     throws DataSourceException
Specified by:
hasHeaderRow in interface DataSource
Returns:
true when this data source has a header row
Throws:
DataSourceException

hasHeaderColumn

public boolean hasHeaderColumn()
                        throws DataSourceException
Specified by:
hasHeaderColumn in interface DataSource
Returns:
true when this data source has a header column
Throws:
DataSourceException

getHeaderRowValue

public java.lang.String getHeaderRowValue(int columnIndex)
                                   throws DataSourceException
Specified by:
getHeaderRowValue in interface DataSource
Returns:
the value in the header row, given by columnIndex
Throws:
NoHeaderRowException
ColumnIndexOutOfBoundsException
DataSourceException

getHeaderRow

public java.lang.String[] getHeaderRow()
                                throws DataSourceException
Specified by:
getHeaderRow in interface DataSource
Returns:
The whole header row
Throws:
NoHeaderRowException
DataSourceException

getHeaderColumnValue

public java.lang.String getHeaderColumnValue(int rowIndex)
                                      throws DataSourceException
Specified by:
getHeaderColumnValue in interface DataSource
Returns:
the value in the header column, given by rowIndex
Throws:
NoHeaderColumnException
RowIndexOutOfBoundsException
DataSourceException

getHeaderColumn

public java.lang.String[] getHeaderColumn()
                                   throws DataSourceException
Specified by:
getHeaderColumn in interface DataSource
Returns:
The whole header column
Throws:
NoHeaderColumnException
DataSourceException

checkRowIndex

private void checkRowIndex(int rowIndex)
                    throws RowIndexOutOfBoundsException
Throws:
RowIndexOutOfBoundsException

checkColumnIndex

private void checkColumnIndex(int columnIndex)
                       throws ColumnIndexOutOfBoundsException
Throws:
ColumnIndexOutOfBoundsException

checkHeaderRow

private void checkHeaderRow()
                     throws DataSourceException
Throws:
DataSourceException

checkHeaderColumn

private void checkHeaderColumn()
                        throws DataSourceException
Throws:
DataSourceException


Copyright 2003 Ludovic Dubost