-
Notifications
You must be signed in to change notification settings - Fork 47
/
REXPString.java
60 lines (50 loc) · 1.44 KB
/
REXPString.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
51
52
53
54
55
56
57
58
59
60
package org.rosuda.REngine;
/** REXPString represents a character vector in R. */
public class REXPString extends REXPVector {
/** payload */
private String[] payload;
/** create a new character vector of the length one
* @param load first (and only) element of the vector */
public REXPString(String load) {
super();
payload=new String[] { load };
}
/** create a new character vector
* @param load string elements of the vector */
public REXPString(String[] load) {
super();
payload=(load==null)?new String[0]:load;
}
/** create a new character vector with attributes
* @param load string elements of the vector
* @param attr attributes */
public REXPString(String[] load, REXPList attr) {
super(attr);
payload=(load==null)?new String[0]:load;
}
public int length() { return payload.length; }
public boolean isString() { return true; }
public Object asNativeJavaObject() {
return payload;
}
public String[] asStrings() {
return payload;
}
public boolean[] isNA() {
boolean a[] = new boolean[payload.length];
int i = 0;
while (i < a.length) { a[i] = (payload[i]==null); i++; }
return a;
}
public String toDebugString() {
StringBuffer sb = new StringBuffer(super.toDebugString()+"{");
int i = 0;
while (i < payload.length && i < maxDebugItems) {
if (i>0) sb.append(",");
sb.append("\""+payload[i]+"\"");
i++;
}
if (i < payload.length) sb.append(",..");
return sb.toString()+"}";
}
}