OW2 Consortium telosys

Rev

Blame | Last modification | View Log | RSS feed

package org.objectweb.telosys.common.data;

/**
 * DataSet with update capabilities 
 * 
 * @author Laurent GUERIN
 *  
 */
public abstract class UpdatableDataSet extends DataSet
{
    //-----------------------------------------------------------------------------
    //--- PRIVATE ATTRIBUTES
    //-----------------------------------------------------------------------------

    /**
     *  
     */
    public UpdatableDataSet()
    {
        super();
    }

    //-----------------------------------------------------------------------------
    //--- PUBLIC METHODS ( superclass methods with "public" visibility )
    //-----------------------------------------------------------------------------
    /**
     * Replaces the DataRow at the given position by a new one
     * @param iRow index of row to replace ( 1 to N )
     * @param dataRow the DataRow to be stored at the specified position
     * @return the DataRow previously at the specified position
     */
    public DataRow replaceRow(int iRow, DataRow dataRow)
    {
//        //--- Is the row position valid ?
//        if (iRow < 1 && iRow > _iRowCount)
//        {
//            return false;
//        }
//        if ( dr == null )
//        {
//            return false;            
//        }
//        //--- Is the column count compatible with the DataSet ?
//        if ( dr.getSize() != _iColCount )
//        {
//            return false;            
//        }
//        //--- Set the row at the given position 
//        _vDataRows.set(iRow, dr);
//        return true;
        return super.replaceRow(iRow, dataRow);
    }
    
//    /**
//     * Add a DataRow at the end of the DataSet
//     * @param dr the DataRow to add
//     * @return the number of rows in the DataSet with the new DataRow added
//     */
//    public int addRow(DataRow dr)
//    {
//        _vDataRows.add(dr);
//        _iRowCount++;
//        return _iRowCount;
//    }
    /**
     * Add a DataRow at the end of the DataSet
     * @param dataRow the DataRow to be added
     * @return
     */
    public int addRow(DataRow dataRow)
    {
        return super.addRow( dataRow ) ;
    }
    
    /**
     * Add a new void DataRow at the end of the DataSet
     * @return the number of rows in the DataSet with the new DataRow added
     */
    public int addRow()
    {
        //return super.addRow( new DataRow(_iColCount)) ;
        return super.addRow() ;
    }
    
    //-----------------------------------------------------------------------------
    /**
     * Replaces the object at the given position by a new one
     * @param iRow
     * @param iCol
     * @param newObject
     * @return true is OK, false if the object cannot be replace (ie the DataRow is null)
     */
    public boolean replaceObject(int iRow, int iCol, Object newObject)
    {
        DataRow dr = getDataRow(iRow);
        if ( dr == null )
        {
            return false ;
        } 
        dr.setObject(iCol, newObject);
        return true ;
    }

    //-----------------------------------------------------------------------------
}

Generated by GNU enscript 1.6.4.