JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table.data
Class JCVectorDataSource

java.lang.Object
  |
  +--com.klg.jclass.table.data.AbstractDataSource
        |
        +--com.klg.jclass.table.data.AbstractVectorDataSource
              |
              +--com.klg.jclass.table.data.JCVectorDataSource
All Implemented Interfaces:
JCTableDataModel, Serializable, TableDataModel
Direct Known Subclasses:
JCEditableVectorDataSource, JCInputStreamDataSource, JCResultSetDataSource

public class JCVectorDataSource
extends AbstractVectorDataSource
implements Serializable

JCVectorDataSource is the main data source of JCTable from which most other datasources are derived. It stores label and cell values in a Vector of Vectors and provides a range of methods for getting and setting the cell values.

See Also:
Serialized Form

Field Summary
protected  Vector cells
           
protected  Vector column_labels
           
protected  int columns
           
protected  boolean is_moving
           
protected  Vector row_labels
           
protected  int rows
           
 
Fields inherited from class com.klg.jclass.table.data.AbstractDataSource
listeners
 
Constructor Summary
JCVectorDataSource()
          Creates a new JCVectorDataSource instance.
JCVectorDataSource(int r, int c, Vector rowLabels, Vector columnLabels, Vector data)
          Creates a new JCVectorDataSource instance.
 
Method Summary
 boolean addColumn(int position, Object label, Vector values)
          Inserts a new column into the data source, shifting any cell values to the right of the insertion.
protected  boolean addColumn(int position, Object label, Vector values, boolean shift_labels)
           
 boolean addRow(int position, Object label, Vector values)
          Inserts a new row into the data source, shifting any cell values below the insertion.
protected  boolean addRow(int position, Object label, Vector values, boolean shift_labels)
           
 void clearCells()
          Clears the values of all cells by setting them to null.
 boolean deleteColumns(int position, int num_columns)
          Deletes columns from the data source.
protected  boolean deleteColumns(int position, int num_columns, boolean shift_labels)
           
 boolean deleteRows(int position, int num_rows)
          Deletes rows from the data source.
protected  boolean deleteRows(int position, int num_rows, boolean shift_labels)
           
 Vector getCells()
          Returns the internal cell values of the table.
 Vector getColumnLabels()
          Gets the data source's ColumnLabels value.
protected  Object getLabelValue(int row, int column)
          Private method gets the label value.
 int getNumColumns()
          Gets the number of columns in the table from the data source's NumColumns value.
 int getNumRows()
          Gets the number of rows in the table by retrieving the value of the data source's NumRows property.
 Vector getRowLabels()
          Gets the data source's RowLabels value.
 Object getTableColumnLabel(int column)
          Gets the label of a given column in the data source.
 Object getTableDataItem(int row, int column)
          Returns the value for the cell at the specified location.
 Object getTableRowLabel(int row)
          Gets the label of a given row in the data source.
static boolean isCell(int row, int column)
          Returns true if the row and column constitute a valid cell.
static boolean isColumnLabel(int row, int column)
          Returns true if the row and column constitute a valid column label.
static boolean isLabel(int row, int column)
          Returns true if the row and column constitute a valid label.
static boolean isRowLabel(int row, int column)
          Returns true if the row and column constitute a valid row label.
 boolean isValidCell(int row, int column)
          Returns true if the row and column constitute a valid cell.
 boolean isValidLabel(int r, int c)
          Returns true if the row and column constitute a valid label.
 boolean moveColumns(int source, int num_columns, int destination)
          Moves a range of columns in the data source.
protected  boolean moveColumns(int source, int num_columns, int destination, boolean shift_labels)
           
 boolean moveRows(int source, int num_rows, int destination)
          Moves a range of rows.
protected  boolean moveRows(int source, int num_rows, int destination, boolean shift_labels)
           
 void setCell(int row, int column, Object v)
          Sets the value of a cell.
 void setCells(String[][] v)
          Sets the cell values as a matrix of Strings.
 void setCells(Vector v)
          Sets the cell values as a Vector of Vectors.
 void setColumnLabel(int column, Object value)
          Specifies the contents of a column label in the data source.
 void setColumnLabels(String[] labels)
          Sets the column labels as an array of Strings.
 void setColumnLabels(Vector labels)
          Sets the column labels as a Vector.
 void setDataChanged(int row, int column, int num_affected, int destination, int command)
          Notifies all registered TableDataListeners of a data source change.
protected  void setLabelValue(int row, int column, Object value)
          Private method sets the label value.
 void setNumColumns(int value)
          Sets the current number of columns in the data source (default is 5).
 void setNumRows(int value)
          Sets the current number of rows in the data source (default is 10).
 void setRowLabel(int row, Object value)
          Specifies the contents a row label in the data source.
 void setRowLabels(String[] labels)
          Sets the row labels as an array of Strings.
 void setRowLabels(Vector labels)
          Sets the row labels as a Vector.
 
Methods inherited from class com.klg.jclass.table.data.AbstractVectorDataSource
createVector, createVector, createVector, createVector, createVector, removeElementsAt, setElementAt, strip
 
Methods inherited from class com.klg.jclass.table.data.AbstractDataSource
addTableDataListener, dispose, fireColumnChanged, fireColumnLabelChanged, fireColumnsAdded, fireColumnsDeleted, fireColumnsMoved, fireDataReset, fireNumColumnsChanged, fireNumRowsChanged, fireRowChanged, fireRowDeleted, fireRowLabelChanged, fireRowsAdded, fireRowsMoved, fireTableDataEvent, fireValueChanged, hasListeners, removeTableDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cells

protected Vector cells

column_labels

protected Vector column_labels

row_labels

protected Vector row_labels

columns

protected int columns

rows

protected int rows

is_moving

protected boolean is_moving
Constructor Detail

JCVectorDataSource

public JCVectorDataSource()
Creates a new JCVectorDataSource instance.


JCVectorDataSource

public JCVectorDataSource(int r,
                          int c,
                          Vector rowLabels,
                          Vector columnLabels,
                          Vector data)
Creates a new JCVectorDataSource instance.

Parameters:
c -
columnLabels -
data -
r -
rowLabels -
Method Detail

getNumColumns

public int getNumColumns()
Gets the number of columns in the table from the data source's NumColumns value.

Specified by:
getNumColumns in interface JCTableDataModel
Returns:
See Also:
setNumColumns(int)

setNumColumns

public void setNumColumns(int value)
Sets the current number of columns in the data source (default is 5). This value does not affect the internal CellValues vector. The addColumn() and deleteColumns() methods update this property by the number of columns added/deleted. If set to zero, no cells are displayed.

Parameters:
value -

getNumRows

public int getNumRows()
Gets the number of rows in the table by retrieving the value of the data source's NumRows property.

Specified by:
getNumRows in interface JCTableDataModel
Returns:
See Also:
setNumRows(int)

setNumRows

public void setNumRows(int value)
Sets the current number of rows in the data source (default is 10). This value does not affect the internal CellValues vector. The addRow() and deleteRow() methods update this property by the number of rows added/deleted. If set to zero, no cells are displayed.

Parameters:
value -

getTableColumnLabel

public Object getTableColumnLabel(int column)
Gets the label of a given column in the data source.

Specified by:
getTableColumnLabel in interface JCTableDataModel
Parameters:
column -
Returns:
See Also:
setColumnLabel(int, java.lang.Object)

getTableRowLabel

public Object getTableRowLabel(int row)
Gets the label of a given row in the data source.

Specified by:
getTableRowLabel in interface JCTableDataModel
Parameters:
row -
Returns:
See Also:
setRowLabel(int, java.lang.Object)

getTableDataItem

public Object getTableDataItem(int row,
                               int column)
Returns the value for the cell at the specified location.

Specified by:
getTableDataItem in interface JCTableDataModel
Parameters:
column -
row -
Returns:
value for the cell at the specified location

clearCells

public void clearCells()
Clears the values of all cells by setting them to null.

See Also:
setCells(java.lang.String[][])

getCells

public Vector getCells()
Returns the internal cell values of the table.

Returns:
internal cell values
See Also:
setCells(java.lang.String[][])

getColumnLabels

public Vector getColumnLabels()
Gets the data source's ColumnLabels value.

Returns:
See Also:
setColumnLabels(java.lang.String[])

getRowLabels

public Vector getRowLabels()
Gets the data source's RowLabels value.

Returns:
See Also:
setRowLabels(java.lang.String[])

isCell

public static final boolean isCell(int row,
                                   int column)
Returns true if the row and column constitute a valid cell.

Parameters:
row - The row index
column - The column index
Returns:
true if the row and column constiture a valid cell

isColumnLabel

public static final boolean isColumnLabel(int row,
                                          int column)
Returns true if the row and column constitute a valid column label.

Parameters:
row - The row index
column - The column index
Returns:
true if the row and column constitute a valid column level

isLabel

public static final boolean isLabel(int row,
                                    int column)
Returns true if the row and column constitute a valid label.

Parameters:
row - The row index
column - The column index
Returns:
true if the row and column constitute a valid label

isRowLabel

public static final boolean isRowLabel(int row,
                                       int column)
Returns true if the row and column constitute a valid row label.

Parameters:
row - The row index
column - The column index
Returns:
true if the row and column constitute a valid row label

isValidCell

public final boolean isValidCell(int row,
                                 int column)
Returns true if the row and column constitute a valid cell.

Parameters:
row - The row index
column - The column index
Returns:
true if the row and column constitute a valid cell

isValidLabel

public final boolean isValidLabel(int r,
                                  int c)
Returns true if the row and column constitute a valid label.

Parameters:
r - The row index
c - The column index
Returns:
true if the row and column constitute a valid label

setColumnLabel

public void setColumnLabel(int column,
                           Object value)
Specifies the contents of a column label in the data source.

Parameters:
column -
value -

setColumnLabels

public void setColumnLabels(String[] labels)
Sets the column labels as an array of Strings.

Parameters:
labels -

setColumnLabels

public void setColumnLabels(Vector labels)
Sets the column labels as a Vector. Each element of the vector may be an instance of a String, Image, Component, or other Object. To clear the labels, call this method with a null argument.

Parameters:
labels -

setRowLabel

public void setRowLabel(int row,
                        Object value)
Specifies the contents a row label in the data source.

Parameters:
row -
value -

setRowLabels

public void setRowLabels(String[] labels)
Sets the row labels as an array of Strings.

Parameters:
labels -

setRowLabels

public void setRowLabels(Vector labels)
Sets the row labels as a Vector. Each element of the vector may be an instance of a String, Image, Component, or other Object. To clear the labels, call this method with a null argument.

Parameters:
labels -

setCell

public void setCell(int row,
                    int column,
                    Object v)
Sets the value of a cell.

Parameters:
column -
row -
v -

setCells

public void setCells(String[][] v)
Sets the cell values as a matrix of Strings. To remove all values, call clearCells().

Parameters:
v -
See Also:
clearCells()

setCells

public void setCells(Vector v)
Sets the cell values as a Vector of Vectors. To remove all values, call clearCells().

Parameters:
v -

getLabelValue

protected Object getLabelValue(int row,
                               int column)
Private method gets the label value.

Parameters:
column -
row -
Returns:

setLabelValue

protected void setLabelValue(int row,
                             int column,
                             Object value)
Private method sets the label value.

Parameters:
column -
row -
value -

setDataChanged

public void setDataChanged(int row,
                           int column,
                           int num_affected,
                           int destination,
                           int command)
Notifies all registered TableDataListeners of a data source change.

Parameters:
column -
command -
destination -
num_affected -
row -

addColumn

public boolean addColumn(int position,
                         Object label,
                         Vector values)
Inserts a new column into the data source, shifting any cell values to the right of the insertion.

Parameters:
position - this is the column index before which to add the new column (if set to JCTableEnum.MAXINT, the column is added after the last column)
label - this is the column label (can be null)
values - an array of objects to be inserted (can be null)
Returns:
false if any argument is invalid

addColumn

protected boolean addColumn(int position,
                            Object label,
                            Vector values,
                            boolean shift_labels)

addRow

public boolean addRow(int position,
                      Object label,
                      Vector values)
Inserts a new row into the data source, shifting any cell values below the insertion. The row labels will be shifted unless a JCLabelValueListener has been registered.

Parameters:
position - this is the row index before which to add the new row (if set to JCTableEnum.MAXINT, the row is added after the last row)
label - this is the row label (can be null)
values - an array of objects to be inserted (can be null)
Returns:
false if any argument is invalid

addRow

protected boolean addRow(int position,
                         Object label,
                         Vector values,
                         boolean shift_labels)

deleteColumns

public boolean deleteColumns(int position,
                             int num_columns)
Deletes columns from the data source. The column labels will be shifted unless a JCLabelValueListener has been registered.

Parameters:
position - this is the first column number to delete
num_columns - this is the number of columns to be deleted
Returns:
false if any argument is invalid

deleteColumns

protected boolean deleteColumns(int position,
                                int num_columns,
                                boolean shift_labels)

deleteRows

public boolean deleteRows(int position,
                          int num_rows)
Deletes rows from the data source. The row labels will be shifted unless a JCLabelValueListener has been registered.

Parameters:
position - this is the first row number to delete
num_rows - this is the number of rows to be deleted
Returns:
false if any argument is invalid

deleteRows

protected boolean deleteRows(int position,
                             int num_rows,
                             boolean shift_labels)

moveColumns

public boolean moveColumns(int source,
                           int num_columns,
                           int destination)
Moves a range of columns in the data source. The column labels will be moved unless a JCLabelValueListener has been registered.

Parameters:
source - this is the first column in the range
num_columns - this is the number of columns to move
destination - this is the column number before which to insert the moved columns
Returns:
false if any argument is invalid

moveColumns

protected boolean moveColumns(int source,
                              int num_columns,
                              int destination,
                              boolean shift_labels)

moveRows

public boolean moveRows(int source,
                        int num_rows,
                        int destination)
Moves a range of rows. The row labels will be shifted unless a JCLabelValueListener has been registered.

Parameters:
source - this is the first row in the range
num_rows - this is the number of rows to move
destination - this is the row number before which to insert the moved rows
Returns:
false if any argument is invalid

moveRows

protected boolean moveRows(int source,
                           int num_rows,
                           int destination,
                           boolean shift_labels)

Copyright © 2004 Quest Software Inc..
All rights reserved.