0N/A/*
2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing.table;
0N/A
0N/Aimport java.io.Serializable;
0N/Aimport java.util.Vector;
0N/Aimport java.util.Enumeration;
0N/Aimport javax.swing.event.TableModelEvent;
0N/A
0N/A
0N/A/**
0N/A * This is an implementation of <code>TableModel</code> that
0N/A * uses a <code>Vector</code> of <code>Vectors</code> to store the
0N/A * cell value objects.
0N/A * <p>
0N/A * <strong>Warning:</strong> <code>DefaultTableModel</code> returns a
0N/A * column class of <code>Object</code>. When
0N/A * <code>DefaultTableModel</code> is used with a
0N/A * <code>TableRowSorter</code> this will result in extensive use of
0N/A * <code>toString</code>, which for non-<code>String</code> data types
0N/A * is expensive. If you use <code>DefaultTableModel</code> with a
0N/A * <code>TableRowSorter</code> you are strongly encouraged to override
0N/A * <code>getColumnClass</code> to return the appropriate type.
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @author Philip Milne
0N/A *
0N/A * @see TableModel
0N/A * @see #getDataVector
0N/A */
0N/Apublic class DefaultTableModel extends AbstractTableModel implements Serializable {
0N/A
0N/A//
0N/A// Instance Variables
0N/A//
0N/A
0N/A /**
0N/A * The <code>Vector</code> of <code>Vectors</code> of
0N/A * <code>Object</code> values.
0N/A */
0N/A protected Vector dataVector;
0N/A
0N/A /** The <code>Vector</code> of column identifiers. */
0N/A protected Vector columnIdentifiers;
0N/A
0N/A//
0N/A// Constructors
0N/A//
0N/A
0N/A /**
0N/A * Constructs a default <code>DefaultTableModel</code>
0N/A * which is a table of zero columns and zero rows.
0N/A */
0N/A public DefaultTableModel() {
0N/A this(0, 0);
0N/A }
0N/A
0N/A private static Vector newVector(int size) {
0N/A Vector v = new Vector(size);
0N/A v.setSize(size);
0N/A return v;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>DefaultTableModel</code> with
0N/A * <code>rowCount</code> and <code>columnCount</code> of
0N/A * <code>null</code> object values.
0N/A *
0N/A * @param rowCount the number of rows the table holds
0N/A * @param columnCount the number of columns the table holds
0N/A *
0N/A * @see #setValueAt
0N/A */
0N/A public DefaultTableModel(int rowCount, int columnCount) {
0N/A this(newVector(columnCount), rowCount);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>DefaultTableModel</code> with as many columns
0N/A * as there are elements in <code>columnNames</code>
0N/A * and <code>rowCount</code> of <code>null</code>
0N/A * object values. Each column's name will be taken from
0N/A * the <code>columnNames</code> vector.
0N/A *
0N/A * @param columnNames <code>vector</code> containing the names
0N/A * of the new columns; if this is
0N/A * <code>null</code> then the model has no columns
0N/A * @param rowCount the number of rows the table holds
0N/A * @see #setDataVector
0N/A * @see #setValueAt
0N/A */
0N/A public DefaultTableModel(Vector columnNames, int rowCount) {
0N/A setDataVector(newVector(rowCount), columnNames);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>DefaultTableModel</code> with as many
0N/A * columns as there are elements in <code>columnNames</code>
0N/A * and <code>rowCount</code> of <code>null</code>
0N/A * object values. Each column's name will be taken from
0N/A * the <code>columnNames</code> array.
0N/A *
0N/A * @param columnNames <code>array</code> containing the names
0N/A * of the new columns; if this is
0N/A * <code>null</code> then the model has no columns
0N/A * @param rowCount the number of rows the table holds
0N/A * @see #setDataVector
0N/A * @see #setValueAt
0N/A */
0N/A public DefaultTableModel(Object[] columnNames, int rowCount) {
0N/A this(convertToVector(columnNames), rowCount);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>DefaultTableModel</code> and initializes the table
0N/A * by passing <code>data</code> and <code>columnNames</code>
0N/A * to the <code>setDataVector</code> method.
0N/A *
0N/A * @param data the data of the table, a <code>Vector</code>
0N/A * of <code>Vector</code>s of <code>Object</code>
0N/A * values
0N/A * @param columnNames <code>vector</code> containing the names
0N/A * of the new columns
0N/A * @see #getDataVector
0N/A * @see #setDataVector
0N/A */
0N/A public DefaultTableModel(Vector data, Vector columnNames) {
0N/A setDataVector(data, columnNames);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>DefaultTableModel</code> and initializes the table
0N/A * by passing <code>data</code> and <code>columnNames</code>
0N/A * to the <code>setDataVector</code>
0N/A * method. The first index in the <code>Object[][]</code> array is
0N/A * the row index and the second is the column index.
0N/A *
0N/A * @param data the data of the table
0N/A * @param columnNames the names of the columns
0N/A * @see #getDataVector
0N/A * @see #setDataVector
0N/A */
0N/A public DefaultTableModel(Object[][] data, Object[] columnNames) {
0N/A setDataVector(data, columnNames);
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>Vector</code> of <code>Vectors</code>
0N/A * that contains the table's
0N/A * data values. The vectors contained in the outer vector are
0N/A * each a single row of values. In other words, to get to the cell
0N/A * at row 1, column 5: <p>
0N/A *
0N/A * <code>((Vector)getDataVector().elementAt(1)).elementAt(5);</code><p>
0N/A *
0N/A * @return the vector of vectors containing the tables data values
0N/A *
0N/A * @see #newDataAvailable
0N/A * @see #newRowsAdded
0N/A * @see #setDataVector
0N/A */
0N/A public Vector getDataVector() {
0N/A return dataVector;
0N/A }
0N/A
0N/A private static Vector nonNullVector(Vector v) {
0N/A return (v != null) ? v : new Vector();
0N/A }
0N/A
0N/A /**
0N/A * Replaces the current <code>dataVector</code> instance variable
0N/A * with the new <code>Vector</code> of rows, <code>dataVector</code>.
0N/A * Each row is represented in <code>dataVector</code> as a
0N/A * <code>Vector</code> of <code>Object</code> values.
0N/A * <code>columnIdentifiers</code> are the names of the new
0N/A * columns. The first name in <code>columnIdentifiers</code> is
0N/A * mapped to column 0 in <code>dataVector</code>. Each row in
0N/A * <code>dataVector</code> is adjusted to match the number of
0N/A * columns in <code>columnIdentifiers</code>
0N/A * either by truncating the <code>Vector</code> if it is too long,
0N/A * or adding <code>null</code> values if it is too short.
0N/A * <p>Note that passing in a <code>null</code> value for
0N/A * <code>dataVector</code> results in unspecified behavior,
0N/A * an possibly an exception.
0N/A *
0N/A * @param dataVector the new data vector
0N/A * @param columnIdentifiers the names of the columns
0N/A * @see #getDataVector
0N/A */
0N/A public void setDataVector(Vector dataVector, Vector columnIdentifiers) {
0N/A this.dataVector = nonNullVector(dataVector);
0N/A this.columnIdentifiers = nonNullVector(columnIdentifiers);
0N/A justifyRows(0, getRowCount());
0N/A fireTableStructureChanged();
0N/A }
0N/A
0N/A /**
0N/A * Replaces the value in the <code>dataVector</code> instance
0N/A * variable with the values in the array <code>dataVector</code>.
0N/A * The first index in the <code>Object[][]</code>
0N/A * array is the row index and the second is the column index.
0N/A * <code>columnIdentifiers</code> are the names of the new columns.
0N/A *
0N/A * @param dataVector the new data vector
0N/A * @param columnIdentifiers the names of the columns
0N/A * @see #setDataVector(Vector, Vector)
0N/A */
0N/A public void setDataVector(Object[][] dataVector, Object[] columnIdentifiers) {
0N/A setDataVector(convertToVector(dataVector), convertToVector(columnIdentifiers));
0N/A }
0N/A
0N/A /**
0N/A * Equivalent to <code>fireTableChanged</code>.
0N/A *
0N/A * @param event the change event
0N/A *
0N/A */
0N/A public void newDataAvailable(TableModelEvent event) {
0N/A fireTableChanged(event);
0N/A }
0N/A
0N/A//
0N/A// Manipulating rows
0N/A//
0N/A
0N/A private void justifyRows(int from, int to) {
0N/A // Sometimes the DefaultTableModel is subclassed
0N/A // instead of the AbstractTableModel by mistake.
0N/A // Set the number of rows for the case when getRowCount
0N/A // is overridden.
0N/A dataVector.setSize(getRowCount());
0N/A
0N/A for (int i = from; i < to; i++) {
0N/A if (dataVector.elementAt(i) == null) {
0N/A dataVector.setElementAt(new Vector(), i);
0N/A }
0N/A ((Vector)dataVector.elementAt(i)).setSize(getColumnCount());
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Ensures that the new rows have the correct number of columns.
0N/A * This is accomplished by using the <code>setSize</code> method in
0N/A * <code>Vector</code> which truncates vectors
0N/A * which are too long, and appends <code>null</code>s if they
0N/A * are too short.
0N/A * This method also sends out a <code>tableChanged</code>
0N/A * notification message to all the listeners.
0N/A *
0N/A * @param e this <code>TableModelEvent</code> describes
0N/A * where the rows were added.
0N/A * If <code>null</code> it assumes
0N/A * all the rows were newly added
0N/A * @see #getDataVector
0N/A */
0N/A public void newRowsAdded(TableModelEvent e) {
0N/A justifyRows(e.getFirstRow(), e.getLastRow() + 1);
0N/A fireTableChanged(e);
0N/A }
0N/A
0N/A /**
0N/A * Equivalent to <code>fireTableChanged</code>.
0N/A *
0N/A * @param event the change event
0N/A *
0N/A */
0N/A public void rowsRemoved(TableModelEvent event) {
0N/A fireTableChanged(event);
0N/A }
0N/A
0N/A /**
0N/A * Obsolete as of Java 2 platform v1.3. Please use <code>setRowCount</code> instead.
0N/A */
0N/A /*
0N/A * Sets the number of rows in the model. If the new size is greater
0N/A * than the current size, new rows are added to the end of the model
0N/A * If the new size is less than the current size, all
0N/A * rows at index <code>rowCount</code> and greater are discarded. <p>
0N/A *
0N/A * @param rowCount the new number of rows
0N/A * @see #setRowCount
0N/A */
0N/A public void setNumRows(int rowCount) {
0N/A int old = getRowCount();
0N/A if (old == rowCount) {
0N/A return;
0N/A }
0N/A dataVector.setSize(rowCount);
0N/A if (rowCount <= old) {
0N/A fireTableRowsDeleted(rowCount, old-1);
0N/A }
0N/A else {
0N/A justifyRows(old, rowCount);
0N/A fireTableRowsInserted(old, rowCount-1);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the number of rows in the model. If the new size is greater
0N/A * than the current size, new rows are added to the end of the model
0N/A * If the new size is less than the current size, all
0N/A * rows at index <code>rowCount</code> and greater are discarded. <p>
0N/A *
0N/A * @see #setColumnCount
0N/A * @since 1.3
0N/A */
0N/A public void setRowCount(int rowCount) {
0N/A setNumRows(rowCount);
0N/A }
0N/A
0N/A /**
0N/A * Adds a row to the end of the model. The new row will contain
0N/A * <code>null</code> values unless <code>rowData</code> is specified.
0N/A * Notification of the row being added will be generated.
0N/A *
0N/A * @param rowData optional data of the row being added
0N/A */
0N/A public void addRow(Vector rowData) {
0N/A insertRow(getRowCount(), rowData);
0N/A }
0N/A
0N/A /**
0N/A * Adds a row to the end of the model. The new row will contain
0N/A * <code>null</code> values unless <code>rowData</code> is specified.
0N/A * Notification of the row being added will be generated.
0N/A *
0N/A * @param rowData optional data of the row being added
0N/A */
0N/A public void addRow(Object[] rowData) {
0N/A addRow(convertToVector(rowData));
0N/A }
0N/A
0N/A /**
0N/A * Inserts a row at <code>row</code> in the model. The new row
0N/A * will contain <code>null</code> values unless <code>rowData</code>
0N/A * is specified. Notification of the row being added will be generated.
0N/A *
0N/A * @param row the row index of the row to be inserted
0N/A * @param rowData optional data of the row being added
0N/A * @exception ArrayIndexOutOfBoundsException if the row was invalid
0N/A */
0N/A public void insertRow(int row, Vector rowData) {
0N/A dataVector.insertElementAt(rowData, row);
0N/A justifyRows(row, row+1);
0N/A fireTableRowsInserted(row, row);
0N/A }
0N/A
0N/A /**
0N/A * Inserts a row at <code>row</code> in the model. The new row
0N/A * will contain <code>null</code> values unless <code>rowData</code>
0N/A * is specified. Notification of the row being added will be generated.
0N/A *
0N/A * @param row the row index of the row to be inserted
0N/A * @param rowData optional data of the row being added
0N/A * @exception ArrayIndexOutOfBoundsException if the row was invalid
0N/A */
0N/A public void insertRow(int row, Object[] rowData) {
0N/A insertRow(row, convertToVector(rowData));
0N/A }
0N/A
0N/A private static int gcd(int i, int j) {
0N/A return (j == 0) ? i : gcd(j, i%j);
0N/A }
0N/A
0N/A private static void rotate(Vector v, int a, int b, int shift) {
0N/A int size = b - a;
0N/A int r = size - shift;
0N/A int g = gcd(size, r);
0N/A for(int i = 0; i < g; i++) {
0N/A int to = i;
0N/A Object tmp = v.elementAt(a + to);
0N/A for(int from = (to + r) % size; from != i; from = (to + r) % size) {
0N/A v.setElementAt(v.elementAt(a + from), a + to);
0N/A to = from;
0N/A }
0N/A v.setElementAt(tmp, a + to);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Moves one or more rows from the inclusive range <code>start</code> to
0N/A * <code>end</code> to the <code>to</code> position in the model.
0N/A * After the move, the row that was at index <code>start</code>
0N/A * will be at index <code>to</code>.
0N/A * This method will send a <code>tableChanged</code> notification
0N/A * message to all the listeners. <p>
0N/A *
0N/A * <pre>
0N/A * Examples of moves:
0N/A * <p>
0N/A * 1. moveRow(1,3,5);
0N/A * a|B|C|D|e|f|g|h|i|j|k - before
0N/A * a|e|f|g|h|B|C|D|i|j|k - after
0N/A * <p>
0N/A * 2. moveRow(6,7,1);
0N/A * a|b|c|d|e|f|G|H|i|j|k - before
0N/A * a|G|H|b|c|d|e|f|i|j|k - after
0N/A * <p>
0N/A * </pre>
0N/A *
0N/A * @param start the starting row index to be moved
0N/A * @param end the ending row index to be moved
0N/A * @param to the destination of the rows to be moved
0N/A * @exception ArrayIndexOutOfBoundsException if any of the elements
0N/A * would be moved out of the table's range
0N/A *
0N/A */
0N/A public void moveRow(int start, int end, int to) {
0N/A int shift = to - start;
0N/A int first, last;
0N/A if (shift < 0) {
0N/A first = to;
0N/A last = end;
0N/A }
0N/A else {
0N/A first = start;
0N/A last = to + end - start;
0N/A }
0N/A rotate(dataVector, first, last + 1, shift);
0N/A
0N/A fireTableRowsUpdated(first, last);
0N/A }
0N/A
0N/A /**
0N/A * Removes the row at <code>row</code> from the model. Notification
0N/A * of the row being removed will be sent to all the listeners.
0N/A *
0N/A * @param row the row index of the row to be removed
0N/A * @exception ArrayIndexOutOfBoundsException if the row was invalid
0N/A */
0N/A public void removeRow(int row) {
0N/A dataVector.removeElementAt(row);
0N/A fireTableRowsDeleted(row, row);
0N/A }
0N/A
0N/A//
0N/A// Manipulating columns
0N/A//
0N/A
0N/A /**
0N/A * Replaces the column identifiers in the model. If the number of
0N/A * <code>newIdentifier</code>s is greater than the current number
0N/A * of columns, new columns are added to the end of each row in the model.
0N/A * If the number of <code>newIdentifier</code>s is less than the current
0N/A * number of columns, all the extra columns at the end of a row are
0N/A * discarded. <p>
0N/A *
0N/A * @param columnIdentifiers vector of column identifiers. If
0N/A * <code>null</code>, set the model
0N/A * to zero columns
0N/A * @see #setNumRows
0N/A */
0N/A public void setColumnIdentifiers(Vector columnIdentifiers) {
0N/A setDataVector(dataVector, columnIdentifiers);
0N/A }
0N/A
0N/A /**
0N/A * Replaces the column identifiers in the model. If the number of
0N/A * <code>newIdentifier</code>s is greater than the current number
0N/A * of columns, new columns are added to the end of each row in the model.
0N/A * If the number of <code>newIdentifier</code>s is less than the current
0N/A * number of columns, all the extra columns at the end of a row are
0N/A * discarded. <p>
0N/A *
0N/A * @param newIdentifiers array of column identifiers.
0N/A * If <code>null</code>, set
0N/A * the model to zero columns
0N/A * @see #setNumRows
0N/A */
0N/A public void setColumnIdentifiers(Object[] newIdentifiers) {
0N/A setColumnIdentifiers(convertToVector(newIdentifiers));
0N/A }
0N/A
0N/A /**
0N/A * Sets the number of columns in the model. If the new size is greater
0N/A * than the current size, new columns are added to the end of the model
0N/A * with <code>null</code> cell values.
0N/A * If the new size is less than the current size, all columns at index
0N/A * <code>columnCount</code> and greater are discarded.
0N/A *
0N/A * @param columnCount the new number of columns in the model
0N/A *
0N/A * @see #setColumnCount
0N/A * @since 1.3
0N/A */
0N/A public void setColumnCount(int columnCount) {
0N/A columnIdentifiers.setSize(columnCount);
0N/A justifyRows(0, getRowCount());
0N/A fireTableStructureChanged();
0N/A }
0N/A
0N/A /**
0N/A * Adds a column to the model. The new column will have the
0N/A * identifier <code>columnName</code>, which may be null. This method
0N/A * will send a
0N/A * <code>tableChanged</code> notification message to all the listeners.
0N/A * This method is a cover for <code>addColumn(Object, Vector)</code> which
0N/A * uses <code>null</code> as the data vector.
0N/A *
0N/A * @param columnName the identifier of the column being added
0N/A */
0N/A public void addColumn(Object columnName) {
0N/A addColumn(columnName, (Vector)null);
0N/A }
0N/A
0N/A /**
0N/A * Adds a column to the model. The new column will have the
0N/A * identifier <code>columnName</code>, which may be null.
0N/A * <code>columnData</code> is the
0N/A * optional vector of data for the column. If it is <code>null</code>
0N/A * the column is filled with <code>null</code> values. Otherwise,
0N/A * the new data will be added to model starting with the first
0N/A * element going to row 0, etc. This method will send a
0N/A * <code>tableChanged</code> notification message to all the listeners.
0N/A *
0N/A * @param columnName the identifier of the column being added
0N/A * @param columnData optional data of the column being added
0N/A */
0N/A public void addColumn(Object columnName, Vector columnData) {
0N/A columnIdentifiers.addElement(columnName);
0N/A if (columnData != null) {
0N/A int columnSize = columnData.size();
0N/A if (columnSize > getRowCount()) {
0N/A dataVector.setSize(columnSize);
0N/A }
0N/A justifyRows(0, getRowCount());
0N/A int newColumn = getColumnCount() - 1;
0N/A for(int i = 0; i < columnSize; i++) {
0N/A Vector row = (Vector)dataVector.elementAt(i);
0N/A row.setElementAt(columnData.elementAt(i), newColumn);
0N/A }
0N/A }
0N/A else {
0N/A justifyRows(0, getRowCount());
0N/A }
0N/A
0N/A fireTableStructureChanged();
0N/A }
0N/A
0N/A /**
0N/A * Adds a column to the model. The new column will have the
0N/A * identifier <code>columnName</code>. <code>columnData</code> is the
0N/A * optional array of data for the column. If it is <code>null</code>
0N/A * the column is filled with <code>null</code> values. Otherwise,
0N/A * the new data will be added to model starting with the first
0N/A * element going to row 0, etc. This method will send a
0N/A * <code>tableChanged</code> notification message to all the listeners.
0N/A *
0N/A * @see #addColumn(Object, Vector)
0N/A */
0N/A public void addColumn(Object columnName, Object[] columnData) {
0N/A addColumn(columnName, convertToVector(columnData));
0N/A }
0N/A
0N/A//
0N/A// Implementing the TableModel interface
0N/A//
0N/A
0N/A /**
0N/A * Returns the number of rows in this data table.
0N/A * @return the number of rows in the model
0N/A */
0N/A public int getRowCount() {
0N/A return dataVector.size();
0N/A }
0N/A
0N/A /**
0N/A * Returns the number of columns in this data table.
0N/A * @return the number of columns in the model
0N/A */
0N/A public int getColumnCount() {
0N/A return columnIdentifiers.size();
0N/A }
0N/A
0N/A /**
0N/A * Returns the column name.
0N/A *
0N/A * @return a name for this column using the string value of the
0N/A * appropriate member in <code>columnIdentifiers</code>.
0N/A * If <code>columnIdentifiers</code> does not have an entry
0N/A * for this index, returns the default
0N/A * name provided by the superclass.
0N/A */
0N/A public String getColumnName(int column) {
0N/A Object id = null;
0N/A // This test is to cover the case when
0N/A // getColumnCount has been subclassed by mistake ...
0N/A if (column < columnIdentifiers.size() && (column >= 0)) {
0N/A id = columnIdentifiers.elementAt(column);
0N/A }
0N/A return (id == null) ? super.getColumnName(column)
0N/A : id.toString();
0N/A }
0N/A
0N/A /**
0N/A * Returns true regardless of parameter values.
0N/A *
0N/A * @param row the row whose value is to be queried
0N/A * @param column the column whose value is to be queried
0N/A * @return true
0N/A * @see #setValueAt
0N/A */
0N/A public boolean isCellEditable(int row, int column) {
0N/A return true;
0N/A }
0N/A
0N/A /**
0N/A * Returns an attribute value for the cell at <code>row</code>
0N/A * and <code>column</code>.
0N/A *
0N/A * @param row the row whose value is to be queried
0N/A * @param column the column whose value is to be queried
0N/A * @return the value Object at the specified cell
0N/A * @exception ArrayIndexOutOfBoundsException if an invalid row or
0N/A * column was given
0N/A */
0N/A public Object getValueAt(int row, int column) {
0N/A Vector rowVector = (Vector)dataVector.elementAt(row);
0N/A return rowVector.elementAt(column);
0N/A }
0N/A
0N/A /**
0N/A * Sets the object value for the cell at <code>column</code> and
0N/A * <code>row</code>. <code>aValue</code> is the new value. This method
0N/A * will generate a <code>tableChanged</code> notification.
0N/A *
0N/A * @param aValue the new value; this can be null
0N/A * @param row the row whose value is to be changed
0N/A * @param column the column whose value is to be changed
0N/A * @exception ArrayIndexOutOfBoundsException if an invalid row or
0N/A * column was given
0N/A */
0N/A public void setValueAt(Object aValue, int row, int column) {
0N/A Vector rowVector = (Vector)dataVector.elementAt(row);
0N/A rowVector.setElementAt(aValue, column);
0N/A fireTableCellUpdated(row, column);
0N/A }
0N/A
0N/A//
0N/A// Protected Methods
0N/A//
0N/A
0N/A /**
0N/A * Returns a vector that contains the same objects as the array.
0N/A * @param anArray the array to be converted
0N/A * @return the new vector; if <code>anArray</code> is <code>null</code>,
0N/A * returns <code>null</code>
0N/A */
0N/A protected static Vector convertToVector(Object[] anArray) {
0N/A if (anArray == null) {
0N/A return null;
0N/A }
625N/A Vector<Object> v = new Vector<Object>(anArray.length);
625N/A for (Object o : anArray) {
625N/A v.addElement(o);
0N/A }
0N/A return v;
0N/A }
0N/A
0N/A /**
0N/A * Returns a vector of vectors that contains the same objects as the array.
0N/A * @param anArray the double array to be converted
0N/A * @return the new vector of vectors; if <code>anArray</code> is
0N/A * <code>null</code>, returns <code>null</code>
0N/A */
0N/A protected static Vector convertToVector(Object[][] anArray) {
0N/A if (anArray == null) {
0N/A return null;
0N/A }
625N/A Vector<Vector> v = new Vector<Vector>(anArray.length);
625N/A for (Object[] o : anArray) {
625N/A v.addElement(convertToVector(o));
0N/A }
0N/A return v;
0N/A }
0N/A
0N/A} // End of class DefaultTableModel