equal
deleted
inserted
replaced
17 |
17 |
18 package com.nokia.mid.iapinfo; |
18 package com.nokia.mid.iapinfo; |
19 |
19 |
20 import com.nokia.mj.impl.rt.support.Finalizer; |
20 import com.nokia.mj.impl.rt.support.Finalizer; |
21 import com.nokia.mj.impl.gcf.utils.NativeError; |
21 import com.nokia.mj.impl.gcf.utils.NativeError; |
|
22 import com.nokia.mj.impl.utils.Logger; |
22 |
23 |
23 //import com.nokia.mj.impl.vmport.VmPort; |
24 //import com.nokia.mj.impl.vmport.VmPort; |
24 |
25 |
25 /** |
26 /** |
26 * <p> |
27 * <p> |
129 public CommsTable(String tableName) throws CommDBException |
130 public CommsTable(String tableName) throws CommDBException |
130 { |
131 { |
131 |
132 |
132 iTableName = tableName; |
133 iTableName = tableName; |
133 |
134 |
134 // create native peer |
|
135 iHandle = _construct(); |
|
136 if (iHandle < NativeError.KErrNone) |
|
137 { |
|
138 throw new CommDBException("Native constructor failed!", ERROR_NONE, |
|
139 iHandle); |
|
140 } |
|
141 // we need this so we can do some cleanup when we are garbage collected |
135 // we need this so we can do some cleanup when we are garbage collected |
142 iFinalizer = createFinalizer(); |
136 iFinalizer = createFinalizer(); |
143 state = CREATED; |
137 state = CREATED; |
144 } |
138 } |
145 |
139 |
146 /** |
140 /** |
147 * Opens the corresponding CommDB table. |
141 * Opens the corresponding CommDB table. |
148 */ |
142 */ |
149 public void open() throws CommDBException |
143 public void open(int aNativeSessionHandle) throws CommDBException |
150 { |
144 { |
151 |
145 |
152 int err = _open(iHandle, iTableName); |
146 iHandle = _open(aNativeSessionHandle, iTableName); |
153 if (NativeError.KErrNone == err) |
147 Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo, "iHandle ="+iHandle); |
|
148 |
|
149 if (iHandle > 0) |
154 { |
150 { |
155 state = OPENED; |
151 state = OPENED; |
156 readFieldValues(); |
152 readFieldValues(); |
157 } |
153 } |
158 else |
154 else |
159 { |
155 { |
160 throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, err); |
156 throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, iHandle); |
161 } |
157 } |
162 |
158 |
163 } |
159 } |
164 |
160 |
165 /** |
161 /** |
183 */ |
179 */ |
184 public int findByName(String recordName) throws CommDBException |
180 public int findByName(String recordName) throws CommDBException |
185 { |
181 { |
186 |
182 |
187 int rec = 0; |
183 int rec = 0; |
|
184 |
188 rec = _findByName(iHandle, recordName); |
185 rec = _findByName(iHandle, recordName); |
189 if (rec >= 0) |
186 if (rec >= 0) |
190 { |
187 { |
191 readFieldValues(); |
188 readFieldValues(); |
192 } |
189 } |
228 * |
225 * |
229 * @return with the number of records |
226 * @return with the number of records |
230 */ |
227 */ |
231 public int getRecordCount() throws CommDBException |
228 public int getRecordCount() throws CommDBException |
232 { |
229 { |
|
230 Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo,"+getRecordCount()"); |
233 return _getRecordCount(iHandle); |
231 return _getRecordCount(iHandle); |
234 } |
232 } |
235 |
233 |
236 /** |
234 /** |
237 * Retrieves data from the next record in the database. Throws |
235 * Retrieves data from the next record in the database. Throws |
324 } |
322 } |
325 /*----------------------------------------------------------------*/ |
323 /*----------------------------------------------------------------*/ |
326 /* Native funcions */ |
324 /* Native funcions */ |
327 /*----------------------------------------------------------------*/ |
325 /*----------------------------------------------------------------*/ |
328 /* |
326 /* |
329 * Creates native peer. |
|
330 * |
|
331 * @return handle for native peer |
|
332 */ |
|
333 private static native int _construct(); |
|
334 |
|
335 /* |
|
336 * Destructs native peer. |
327 * Destructs native peer. |
337 * |
328 * |
338 * @param aHandle - handle for native peer |
329 * @param aHandle - handle for native peer |
339 */ |
330 */ |
340 private static native void _destroy(int aHandle); |
331 private static native void _destroy(int aHandle); |
344 * |
335 * |
345 * @param table - the name of the current table. |
336 * @param table - the name of the current table. |
346 * |
337 * |
347 * @return - error code |
338 * @return - error code |
348 */ |
339 */ |
349 private static native int _open(int aHandle, String tableName); |
340 private static native int _open(int aSessionHandle, String tableName); |
350 |
341 |
351 /* |
342 /* |
352 * Close the actual CommDB table. |
343 * Close the actual CommDB table. |
353 * |
344 * |
354 * @param aHandle - handle for native peer |
345 * @param aHandle - handle for native peer |