• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package SQLite;
2 
3 /**
4  * Class wrapping an SQLite backup object.
5  */
6 
7 public class Backup {
8 
9     /**
10      * Internal handle for the native SQLite API.
11      */
12 
13     protected long handle = 0;
14 
15     /**
16      * Finish a backup.
17      */
18 
finish()19     protected void finish() throws SQLite.Exception {
20 	synchronized(this) {
21 	    _finalize();
22 	}
23     }
24 
25     /**
26      * Destructor for object.
27      */
28 
finalize()29     protected void finalize() {
30 	synchronized(this) {
31 	    try {
32 		_finalize();
33 	    } catch (SQLite.Exception e) {
34 	    }
35 	}
36     }
37 
_finalize()38     protected native void _finalize() throws SQLite.Exception;
39 
40     /**
41      * Perform a backup step.
42      *
43      * @param n number of pages to backup
44      * @return true when backup completed
45      */
46 
step(int n)47     public boolean step(int n) throws SQLite.Exception {
48 	synchronized(this) {
49 	    return _step(n);
50 	}
51     }
52 
_step(int n)53     private native boolean _step(int n) throws SQLite.Exception;
54 
55     /**
56      * Perform the backup in one step.
57      */
58 
backup()59     public void backup() throws SQLite.Exception {
60 	synchronized(this) {
61 	    _step(-1);
62 	}
63     }
64 
65     /**
66      * Return number of remaining pages to be backed up.
67      */
68 
remaining()69     public int remaining() throws SQLite.Exception {
70 	synchronized(this) {
71 	    return _remaining();
72 	}
73     }
74 
_remaining()75     private native int _remaining() throws SQLite.Exception;
76 
77     /**
78      * Return the total number of pages in the backup source database.
79      */
80 
pagecount()81     public int pagecount() throws SQLite.Exception {
82 	synchronized(this) {
83 	    return _pagecount();
84 	}
85     }
86 
_pagecount()87     private native int _pagecount() throws SQLite.Exception;
88 
89     /**
90      * Internal native initializer.
91      */
92 
internal_init()93     private static native void internal_init();
94 
95     static {
internal_init()96 	internal_init();
97     }
98 }
99 
100