⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datatable.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        /**     * @param colName the name of the column that you want to retrieve     * @return the DataColumn with the given name. If the given name does not     * map to a DataColumn in this DataTable, then null is returned.     */    public DataColumn getColumn(String colName) {        return columns.get(colName);    }        /**     * @return an unmodifiable list of all of the rows in this DataTable. The     * individual DataRow elements are modifiable, but the List is not.     * This includes all rows, regardless of status--inserted, updated, deleted     * and unchanged.     */    public List<DataRow> getRows() {        return Collections.unmodifiableList(rows);    }        /**     * @param index the Index in this table associated with the DataRow to be     * retrieved. This must be &gt;0, and &lt;rows.size()     * @return the DataRow at the given 0 based index. The index must be valid     */    public DataRow getRow(int index) {        assert index >= 0 && index < rows.size();        return rows.get(index);    }        /**     * @return the number of DataRows in this DataTable; this includes all rows, regardless     * of status--inserted, updated, deleted and unchanged.     */    public int getRowCount() {        return rows.size();    }        /**     * Creates and returns a selector. The DataSelector will have a generated     * name by default.     * @return a selector on the table.     */    public DataSelector createSelector() {        return createSelector(null);    }        /**     * Creates and returns a selector with the given name. If the name is     * invalid, an assertion will be raised     * @param name the name for the new DataSelector     */    public DataSelector createSelector(String name) {        DataSelector sel = new DataSelector(this);        if (name != null) {            sel.setName(name);        }        if (rows.size() > 0) {            sel.setRowIndex(0);        }        selectors.put(sel.getName(),  sel);        sel.addPropertyChangeListener("name", nameChangeListener);        return sel;    }        /**     * @return a List of DataSelectors associated with this DataTable.     */    public List<DataSelector> getSelectors() {        return Collections.unmodifiableList(new ArrayList<DataSelector>(selectors.values()));    }        /**     * @param name the name of the selector to create or return     * @return the DataSelector with the given name. If no such DataSelector     * exists, then a new DataSelector will be created and added to this     * DataTable by the given name.     */    public DataSelector getSelector(String name) {        //if the given selector doesn't exist, create it implicitly        if (!selectors.containsKey(name)) {            return createSelector(name);        } else {            return selectors.get(name);        }    }        /**     * Drop the given selector     * @param selector the selector to drop     */    public void dropSelector(DataSelector selector) {        dropSelector(selector.getName());    }        /**     * drops the given named selector. If a selector by that name does not     * exist, then do nothing     * @param selectorName the name of the selector to drop     */    public void dropSelector(String selectorName) {        DataSelector sel = selectors.remove(selectorName);        if (sel != null) {            sel.removePropertyChangeListener("name",  nameChangeListener);        }    }        /**     * Sets the given name to be the name of this DataTable     * @param name The new name of the table; should be unique within the table's DataSet.     */    public void setName(String name) {        if (this.name != name) {            assert DataSetUtils.isValidName(name);            assert !dataSet.hasElement(name);            String oldName = this.name;            this.name = name;            pcs.firePropertyChange("name", oldName, name);        }    }        /**     * Returns the name of this <CODE>DataTable</CODE>.     * @return the name of this DataTable     */    public String getName() {        return name;    }        /**     * Returns true if rows in this table compare reference with current values     * using the Java identity comparison (==); see class     * JavaDocs, and docs for {@link DataRow}.     * @return true if rows in this table compare reference with current values     * using the Java identity comparison (==); see class     * JavaDocs, and docs for {@link DataRow}.     */    public boolean isIdentityComparisonEnabled() {        return identityComparisonEnabled;    }        /**     * Sets whether rows in this table compare reference with current values     * using the Java identity comparison (==); see class     * JavaDocs, and docs for {@link DataRow}.     * @param identityComparisonEnabled if true, table will use identity (<CODE>==</CODE>) comparison in checking for row changes.     */    public void setIdentityComparisonEnabled(boolean identityComparisonEnabled) {        this.identityComparisonEnabled = identityComparisonEnabled;    }        /**     * Assigns a Comparator to use in comparing current and reference values     * in DataRow cells, according to a DataColumn's type/class; see class     * JavaDocs, and docs for {@link DataRow}. Only one Comparator can be assigned     * per class; calling this multiple times on the same class will overwrite     * the Comparator assignment.     *     * @param klass The Class to bind the Comparator with.     * @param comp The Comparator used.     */    public void setClassComparator(Class klass, Comparator comp) {        assert klass != null;        assert comp != null;        classComparators.put(klass, comp);    }        /**     * Removes assignment of a Comparator for a DataColumn type/class; see class     * JavaDocs, and docs for {@link DataRow}.     *     * @param klass The class for which the Comparator will be removed. Fails silently     * if none is assigned.     */    public void removeClassComparator(Class klass) {        assert klass != null;        classComparators.remove(klass);    }        /**     * @return true if the given Class has a Comparator assigned; see class     * JavaDocs, and docs for {@link DataRow}.     */    public boolean hasClassComparator(Class klass) {        return classComparators.get(klass) != null;    }        /**     * Returns a Comparator bound to a given Class for comparison of     * current and reference values in a DataRow. Will return a     * default Comparator that uses .equals() comparison if none     * was explicitly assigned.     *     * @param klass The class for which to retrieve a Comparator     * @return The Comparator bound to the Class, or a default Comparator.     */    public Comparator getClassComparator(Class klass) {        Comparator comp = classComparators.get(klass);        if ( comp == null ) {            comp = EQUALS_COMPARATOR;        }        return comp;    }        /**     * Assigns a specific Comparator to a DataColumn, for use in comparing     * changes to DataRow cells; see class     * JavaDocs, and docs for {@link DataRow}.     *     * @param col The DataColumn to which the Comparator is bound.     * @param comp The Comparator instance.     */    public void setColumnComparator(DataColumn col, Comparator comp) {        assert col != null;        assert comp != null;        columnComparators.put(col, comp);    }        /**     * Removes the specific Comparator assigned to the column, if any; fails     * silently if none assigned; see class     * JavaDocs, and docs for {@link DataRow}.     *     * @param col The DataColumn for which to remove the bound Comparator.     */    public void removeColumnComparator(DataColumn col) {        assert col != null;        columnComparators.remove(col);    }        /**     * Returns true if the column has a specific comparator assigned to it;     * with {@link setColumnComparator(DataColumn, Comparator)}; see class     * JavaDocs, and docs for {@link DataRow}.     *     * @param col The DataColumn to find a Comparator for.     * @return true if a Comparator has been bound to this DataColumn.     */    public boolean hasColumnComparator(DataColumn col) {        return columnComparators.get(col) != null;    }        /**     * Returns a Comparator bound to a given Column. Will return the comparator     * for the column's class if no specific comparator was assigned to the column; see class     * JavaDocs, and docs for {@link DataRow}.     *     * @param col The DataColumn for which to find the Comparator.     * @return The Comparator bound to this column, or the Comparator bound to the     * column's class; see {@link #getClassComparator(Class klass)}     */    public Comparator getColumnComparator(DataColumn col) {        assert col != null;        Comparator comp = columnComparators.get(col);        if ( comp == null ) {            comp = getClassComparator(col.getType());        }        return comp;    }        /**     * Returns true if deletion of rows is supported.     * @return true if deletion of rows is supported     */    public boolean isDeleteRowSupported() {        return deleteRowSupported;    }        /**     * Sets the deleteRowSupported flag     * @param deleteRowSupported the new value for deleteRowSupported     */    public void setDeleteRowSupported(boolean deleteRowSupported) {        if (this.deleteRowSupported != deleteRowSupported) {            boolean oldValue = this.deleteRowSupported;            this.deleteRowSupported = deleteRowSupported;            pcs.firePropertyChange("deleteRowSupported", oldValue, deleteRowSupported);        }    }        /**     * Returns true if appending rows is supported.     * @return true if appending rows is supported     */    public boolean isAppendRowSupported() {        return appendRowSupported;    }        /**     * Sets whether appending rows is supported     * @param appendRowSupported the new value for appendRowSupported     */    public void setAppendRowSupported(boolean appendRowSupported) {        if (this.appendRowSupported != appendRowSupported) {            boolean oldValue = this.appendRowSupported;            this.appendRowSupported = appendRowSupported;            pcs.firePropertyChange("appendRowSupported", oldValue, appendRowSupported);        }    }        /**     * Returns the {@link DataProvider} for this <CODE>DataTable</CODE>. May be null.     * @return the DataProvider for this DataTable. May be null.     */    public DataProvider getDataProvider() {        return dataProvider;    }        /**     * Sets the DataProvider for this DataTable.     * @param dataProvider the DataProvider for this DataTable. This may be null.     */    public void setDataProvider(DataProvider dataProvider) {        if (this.dataProvider != dataProvider) {            DataProvider oldValue = this.dataProvider;            this.dataProvider = dataProvider;            pcs.firePropertyChange("dataProvider", oldValue, dataProvider);        }    }        /**     * Returns the {@link DataSet} that is associated with this <CODE>DataTable</CODE>.     * @return the DataSet that is associated with this DataTable     */    public DataSet getDataSet() {        return dataSet;    }    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -