OW2 Consortium telosys

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13 lguerin 1
package org.objectweb.telosys.common.data;
2
 
3
/**
4
 * DataSet with update capabilities
5
 *
6
 * @author Laurent GUERIN
7
 *
8
 */
9
public abstract class UpdatableDataSet extends DataSet
10
{
11
    //-----------------------------------------------------------------------------
12
    //--- PRIVATE ATTRIBUTES
13
    //-----------------------------------------------------------------------------
14
 
15
    /**
16
     *
17
     */
18
    public UpdatableDataSet()
19
    {
20
        super();
21
    }
22
 
23
    //-----------------------------------------------------------------------------
24
    //--- PUBLIC METHODS ( superclass methods with "public" visibility )
25
    //-----------------------------------------------------------------------------
26
    /**
27
     * Replaces the DataRow at the given position by a new one
28
     * @param iRow index of row to replace ( 1 to N )
29
     * @param dataRow the DataRow to be stored at the specified position
30
     * @return the DataRow previously at the specified position
31
     */
32
    public DataRow replaceRow(int iRow, DataRow dataRow)
33
    {
34
//        //--- Is the row position valid ?
35
//        if (iRow < 1 && iRow > _iRowCount)
36
//        {
37
//            return false;
38
//        }
39
//        if ( dr == null )
40
//        {
41
//            return false;
42
//        }
43
//        //--- Is the column count compatible with the DataSet ?
44
//        if ( dr.getSize() != _iColCount )
45
//        {
46
//            return false;
47
//        }
48
//        //--- Set the row at the given position
49
//        _vDataRows.set(iRow, dr);
50
//        return true;
51
        return super.replaceRow(iRow, dataRow);
52
    }
53
 
54
//    /**
55
//     * Add a DataRow at the end of the DataSet
56
//     * @param dr the DataRow to add
57
//     * @return the number of rows in the DataSet with the new DataRow added
58
//     */
59
//    public int addRow(DataRow dr)
60
//    {
61
//        _vDataRows.add(dr);
62
//        _iRowCount++;
63
//        return _iRowCount;
64
//    }
65
    /**
66
     * Add a DataRow at the end of the DataSet
67
     * @param dataRow the DataRow to be added
68
     * @return
69
     */
70
    public int addRow(DataRow dataRow)
71
    {
72
        return super.addRow( dataRow ) ;
73
    }
74
 
75
    /**
76
     * Add a new void DataRow at the end of the DataSet
77
     * @return the number of rows in the DataSet with the new DataRow added
78
     */
79
    public int addRow()
80
    {
81
        //return super.addRow( new DataRow(_iColCount)) ;
82
        return super.addRow() ;
83
    }
84
 
85
    //-----------------------------------------------------------------------------
86
    /**
87
     * Replaces the object at the given position by a new one
88
     * @param iRow
89
     * @param iCol
90
     * @param newObject
91
     * @return true is OK, false if the object cannot be replace (ie the DataRow is null)
92
     */
93
    public boolean replaceObject(int iRow, int iCol, Object newObject)
94
    {
95
        DataRow dr = getDataRow(iRow);
96
        if ( dr == null )
97
        {
98
            return false ;
99
        }
100
        dr.setObject(iCol, newObject);
101
        return true ;
102
    }
103
 
104
    //-----------------------------------------------------------------------------
105
}