All Downloads are FREE. Search and download functionalities are using the official Maven repository.

carosellini.rJava.REngine.0.9-7.source-code.REXPString Maven / Gradle / Ivy

Go to download

Rserve is a TCP/IP server which allows other programs to use facilities of R (see www.r-project.org) from various languages without the need to initialize R or link against R library. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++, PHP and Java. Rserve supports remote connection, authentication and file transfer. Typical use is to integrate R backend for computation of statstical models, plots etc. in other applications.

The newest version!
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()+"}";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy