forked from s-u/rJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRBool.java
More file actions
32 lines (26 loc) · 1.02 KB
/
RBool.java
File metadata and controls
32 lines (26 loc) · 1.02 KB
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
package org.rosuda.JRI;
// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/
// Copyright (C) 2004 Simon Urbanek
// --- for licensing information see LICENSE file in the original JRclient distribution ---
/** Implementation of tri-state logical data type in R.
The three states are TRUE, FALSE and NA. To obtain truly boolean
value, you'll need to use {@link #isTRUE} or {@link #isFALSE} since there is
no canonical representation of RBool in boolean
@version $Id: RBool.java 2720 2007-03-15 17:35:42Z urbanek $
*/
public class RBool extends Object {
int val;
public RBool(boolean b) {
val=(b)?1:0;
};
public RBool(RBool r) {
val=r.val;
};
public RBool(int i) { /* 0=FALSE, 2=NA, anything else = TRUE */
val=(i==0||i==2)?i:1;
};
public boolean isNA() { return (val==2); };
public boolean isTRUE() { return (val==1); };
public boolean isFALSE() { return (val==0); };
public String toString() { return (val==0)?"FALSE":((val==2)?"NA":"TRUE"); };
}