Clover Coverage Report - AnCal Coverage Report
Coverage timestamp: gio dic 18 2014 12:18:42 EST
../../../../../img/srcFileCovDistChart8.png 73% of files have more coverage
35   131   24   2,5
16   99   0,69   14
14     1,71  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  DataRow       Line # 9 35 24 72,3% 0.72307694
 
No Tests
 
1   
2    package pl.magot.vetch.ancal.database;
3   
4   
5    import android.content.ContentValues;
6    import android.database.Cursor;
7   
8   
 
9    public abstract class DataRow
10    {
11    //fields
12    protected Database userdb = null;
13    private DataField[] vecTableDef = null;
14    private ContentValues values = new ContentValues();
15   
16   
17    //methods
 
18  140 toggle public DataRow(Database userdb)
19    {
20  140 this.userdb = userdb;
21    }
22   
 
23  193 toggle public Database GetUserDb()
24    {
25  193 return userdb;
26    }
27   
 
28  140 toggle public void SetTableDefinition(DataField[] vecTableDef)
29    {
30  140 this.vecTableDef = vecTableDef;
31    //initialize field parent
32  140 UpdateDataFieldsParentRow(this);
33    }
34   
 
35  140 toggle public void UpdateDataFieldsParentRow(DataRow row)
36    {
37  959 for (int i = 0; i < vecTableDef.length; i++)
38  819 vecTableDef[i].SetParentRow(row);
39    }
40   
 
41  0 toggle public void CopyTableDefinition(DataRow data)
42    {
43  0 SetTableDefinition(data.vecTableDef);
44    }
45   
 
46  4 toggle public DataField[] GetTableDef()
47    {
48  4 return vecTableDef;
49    }
50   
 
51  0 toggle public boolean Validate()
52    {
53  0 return false;
54    }
55   
 
56  21 toggle public void ClearContentValues()
57    {
58  21 values.clear();
59    }
60   
 
61  840 toggle public ContentValues GetContentValues()
62    {
63  840 return values;
64    }
65   
 
66  0 toggle public void SetContentValues(ContentValues values)
67    {
68  0 this.values = values;
69  0 UpdateDataFieldsParentRow(this);
70    }
71   
 
72  0 toggle public boolean CopyContentValues(ContentValues values)
73    {
74  0 this.values = values;
75  0 UpdateDataFieldsParentRow(this);
76  0 try
77    {
78  0 GetValuesFromDataRow();
79  0 return true;
80    } catch (Exception e) {
81    }
82  0 return false;
83    }
84   
 
85  294 toggle public DataField Value(int idx)
86    {
87  294 return vecTableDef[idx];
88    }
89   
 
90  0 toggle public String fieldName(int idx)
91    {
92  0 return vecTableDef[idx].GetName();
93    }
94   
 
95  15 toggle public boolean GetValuesFromCursor(Cursor cr)
96    {
97  15 if ((cr != null) && (cr.getPosition() != -1))
98    {
99  106 for (int idx = 0; idx < vecTableDef.length; idx++)
100    {
101  91 DataField field = Value(idx);
102    //check if null value
103  91 if (cr.isNull(idx))
104    {
105  3 field.setNull();
106    } else {
107  88 final DataField.Type t = field.GetType();
108    //parse value by type
109  88 if (t == DataField.Type.INT)
110  61 field.set(cr.getLong(idx));
111  88 if (t == DataField.Type.TEXT)
112  15 field.set(cr.getString(idx));
113  88 if (t == DataField.Type.BOOL)
114  12 field.set((cr.getInt(idx) == 1)?true:false);
115    }
116    }
117  15 return true;
118    }
119  0 return false;
120    }
121   
122    //sets fields values data (ContentValues values contener) from parent object fields
123    public abstract void SetValuesForDataRow();
124   
125    //gets data from fields values (ContentValues values contener) to parent object fields
126    public abstract void GetValuesFromDataRow();
127   
128    public abstract String GetTableName();
129   
130    }
131