Mercurial > hg > audiodb
comparison bindings/java/src/org/omras2/AudioDB.java @ 725:7e1fa27b67ee
* Full status support
* Insert support (not fully tested)
* Unit tests for create + initial insert
author | mas01mj |
---|---|
date | Wed, 21 Jul 2010 14:27:07 +0000 |
parents | 11fd16e1d8b3 |
children | fe2282b9bfb0 |
comparison
equal
deleted
inserted
replaced
724:11fd16e1d8b3 | 725:7e1fa27b67ee |
---|---|
4 | 4 |
5 public class AudioDB | 5 public class AudioDB |
6 { | 6 { |
7 public native boolean audiodb_create(String path, int datasize, int ntracks, int datadim); | 7 public native boolean audiodb_create(String path, int datasize, int ntracks, int datadim); |
8 public native boolean audiodb_open(String path, Mode mode); | 8 public native boolean audiodb_open(String path, Mode mode); |
9 public native void audiodb_close(); | |
9 public native Status audiodb_status(); | 10 public native Status audiodb_status(); |
10 | 11 public native boolean audiodb_insert_path(String key, String features, String power, String times); |
11 // public native void insert(); | |
12 // public native void query(); | 12 // public native void query(); |
13 | 13 |
14 public enum Mode { O_RDONLY, O_RDRW } | 14 public enum Mode { O_RDONLY, O_RDWR } |
15 | 15 |
16 private File path; | 16 private File path; |
17 private long adbHandle; | 17 private long adbHandle; |
18 | 18 |
19 public AudioDB(File path) | 19 public AudioDB(File path) |
20 { | 20 { |
21 this.path = path; | 21 this.path = path; |
22 } | 22 } |
23 | |
24 public void close() | |
25 { | |
26 audiodb_close(); | |
27 } | |
28 | |
29 public boolean insert(File features) | |
30 { | |
31 return audiodb_insert_path(null, features.getPath(), null, null); | |
32 } | |
33 | |
34 public boolean insert(String key, File features) | |
35 { | |
36 return audiodb_insert_path(key, features.getPath(), null, null); | |
37 } | |
38 | |
39 public boolean insert(String key, File features, File power, File times) | |
40 { | |
41 return audiodb_insert_path(key, features.getPath(), (power == null ? null : power.getPath()), (times == null ? null : times.getPath())); | |
42 } | |
43 | |
23 | 44 |
24 public boolean create(int datasize, int ntracks, int datadim) | 45 public boolean create(int datasize, int ntracks, int datadim) |
25 { | 46 { |
26 return audiodb_create(path.toString(), datasize, ntracks, datadim); | 47 return audiodb_create(path.toString(), datasize, ntracks, datadim); |
27 } | 48 } |
43 | 64 |
44 public static void main(String args[]) | 65 public static void main(String args[]) |
45 { | 66 { |
46 AudioDB testDB = new AudioDB(new File("test.adb")); | 67 AudioDB testDB = new AudioDB(new File("test.adb")); |
47 testDB.create(5, 5, 12); | 68 testDB.create(5, 5, 12); |
48 // testDB.open(Mode.O_RDRW); | 69 testDB.open(Mode.O_RDWR); |
70 testDB.insert(new File("testfiles/testfeature")); | |
49 Status status = testDB.getStatus(); | 71 Status status = testDB.getStatus(); |
50 System.out.println("Num files: "+status.getNumFiles()); | 72 System.out.println("Num files: "+status.getNumFiles()); |
73 testDB.close(); | |
51 } | 74 } |
52 } | 75 } |
53 | 76 |
54 | 77 |