Package rstatistics

Source Code of rstatistics.RLocalConnector

package rstatistics;

import rstatistics.interfaces.IRService;
import org.rosuda.JRI.Rengine;

/**
*
* @author vaio
*/
public final class RLocalConnector extends Singleton implements IRService {

    private Rengine rConnection;

    private RLocalConnector() {
        rConnection = new Rengine(null, false, null);
        if (!rConnection.waitForR()) {
            System.out.println("Cannot load R");
            return;
        }
    }

    /**
     *
     * @return
     */
    public static IRService getResource() {
        if (resource == null) {
            resource = new RLocalConnector();
        }
        return resource;
    }

    /**
     *
     * @param cmd
     * @return
     */
    @Override
    public RExpressionLocal eval(String cmd) {
        return new RExpressionLocal(rConnection.eval(cmd));
    }

    /**
     *
     * @param cmd
     */
    @Override
    public void voidEval(String cmd) {
        rConnection.eval(cmd);
    }

    /**
     *
     * @return
     */
    @Override
    public boolean isConnected() {
        return rConnection.isAlive();
    }

    /**
     *
     * @return
     */
    @Override
    public IRService getRService() {
        return this;
    }
}
TOP

Related Classes of rstatistics.RLocalConnector

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.