-
Notifications
You must be signed in to change notification settings - Fork 1
/
Observer.java
50 lines (43 loc) · 1.14 KB
/
Observer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class Observer {
private long pointer; // Pointer to the coco_observer_t object
private String name;
/**
* Constructs the observer from observerName and observerOptions.
* See http://numbbo.github.io/coco-doc/C/#observer-parameters for more information on
* valid observer parameters.
* @param observerName
* @param observerOptions
* @throws Exception
*/
public Observer(String observerName, String observerOptions) throws Exception {
super();
try {
this.pointer = CocoJNI.cocoGetObserver(observerName, observerOptions);
this.name = observerName;
} catch (Exception e) {
throw new Exception("Observer constructor failed.\n" + e.toString());
}
}
/**
* Finalizes the observer.
* @throws Exception
*/
public void finalizeObserver() throws Exception {
try {
CocoJNI.cocoFinalizeObserver(this.pointer);
} catch (Exception e) {
throw new Exception("Observer finalization failed.\n" + e.toString());
}
}
public long getPointer() {
return this.pointer;
}
public String getName() {
return this.name;
}
/* toString method */
@Override
public String toString() {
return getName();
}
}