1 package org.rosuda.REngine;
3 /** REXPString represents a character vector in R. */
4 public class REXPString extends REXPVector {
6 public String[] payload;
8 /** create a new character vector of the length one
9 * @param load first (and only) element of the vector */
10 public REXPString(String load) {
12 payload=new String[] { load };
15 /** create a new character vector
16 * @param load string elements of the vector */
17 public REXPString(String[] load) {
19 payload=(load==null)?new String[0]:load;
22 /** create a new character vector with attributes
23 * @param load string elements of the vector
24 * @param attr attributes */
25 public REXPString(String[] load, REXPList attr) {
27 payload=(load==null)?new String[0]:load;
30 public int length() { return payload.length; }
32 public boolean isString() { return true; }
34 public Object asNativeJavaObject() {
38 public String[] asStrings() {
42 public boolean[] isNA() {
43 boolean a[] = new boolean[payload.length];
45 while (i < a.length) { a[i] = (payload[i]==null); i++; }
49 public String toDebugString() {
50 StringBuffer sb = new StringBuffer(super.toDebugString()+"{");
52 while (i < payload.length && i < maxDebugItems) {
53 if (i>0) sb.append(",");
54 sb.append("\""+payload[i]+"\"");
57 if (i < payload.length) sb.append(",..");
58 return sb.toString()+"}";