diff --git a/RCaller/.classpath b/RCaller/.classpath
deleted file mode 100644
index f362f73..0000000
--- a/RCaller/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/RCaller/src/main/java/com/github/rcaller/JavaObject.java b/RCaller/src/main/java/com/github/rcaller/JavaObject.java
index 0255f64..6a875ba 100644
--- a/RCaller/src/main/java/com/github/rcaller/JavaObject.java
+++ b/RCaller/src/main/java/com/github/rcaller/JavaObject.java
@@ -57,7 +57,7 @@ public void setName(String name) {
public static String ConvertToRCode(String name, Object javaobject, boolean useList, boolean useEquals) throws IllegalAccessException {
StringBuilder builder = new StringBuilder();
- StringBuffer tempbuffer = new StringBuffer();
+ StringBuilder tempbuffer = new StringBuilder();
String className, varName;
Object o;
Field f;
diff --git a/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java b/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java
index 66dc5dd..1775a17 100644
--- a/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java
+++ b/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java
@@ -39,12 +39,12 @@
public class RCode {
- private StringBuffer code;
+ private StringBuilder code;
private TempFileService tempFileService = null;
private RCode() {
- this.code = new StringBuffer();
+ this.code = new StringBuilder();
}
public static RCode create() {
@@ -56,17 +56,23 @@ public static RCode create() {
public static RCode create(StringBuffer stringBuffer) {
RCode rCode = RCode.create();
rCode.clear();
- rCode.getCode().append(stringBuffer);
+ rCode.getCode().append(stringBuffer.toString());
return rCode;
}
public void setCode(StringBuffer sb) {
- this.code = new StringBuffer();
+ this.code = new StringBuilder();
+ clear();
+ this.code.append(sb.toString());
+ }
+
+ public void setCode(StringBuilder sb) {
+ this.code = new StringBuilder();
clear();
this.code.append(sb);
}
- public StringBuffer getCode() {
+ public StringBuilder getCode() {
return (this.code);
}
diff --git a/RCaller/src/main/java/com/github/rcaller/scriptengine/RCallerScriptEngine.java b/RCaller/src/main/java/com/github/rcaller/scriptengine/RCallerScriptEngine.java
index a39901c..c21d06a 100644
--- a/RCaller/src/main/java/com/github/rcaller/scriptengine/RCallerScriptEngine.java
+++ b/RCaller/src/main/java/com/github/rcaller/scriptengine/RCallerScriptEngine.java
@@ -109,7 +109,7 @@ public Object eval(Reader reader, Bindings bindings) throws ScriptException {
@Override
public void put(String name, Object o) {
rcode.clearOnline();
- StringBuffer code = new StringBuffer();
+ StringBuilder code = new StringBuilder();
RCodeUtils.addRespectToType(code, name, o, false);
rcode.addRCode("result <- list(a=0)");
rcode.setCode(code);
diff --git a/RCaller/src/main/java/com/github/rcaller/util/RCodeUtils.java b/RCaller/src/main/java/com/github/rcaller/util/RCodeUtils.java
index 57fc24a..c6ff345 100644
--- a/RCaller/src/main/java/com/github/rcaller/util/RCodeUtils.java
+++ b/RCaller/src/main/java/com/github/rcaller/util/RCodeUtils.java
@@ -39,31 +39,31 @@
public class RCodeUtils {
- public static void addIntArray(StringBuffer rCode, String name, int[] arr, boolean useEquals) {
+ public static void addIntArray(StringBuilder rCode, String name, int[] arr, boolean useEquals) {
addArray(rCode, name, ArrayUtils.toObject(arr), useEquals, false);
}
- public static void addLongArray(StringBuffer rCode, String name, long[] arr, boolean useEquals) {
+ public static void addLongArray(StringBuilder rCode, String name, long[] arr, boolean useEquals) {
addArray(rCode, name, ArrayUtils.toObject(arr), useEquals, false);
}
- public static void addFloatArray(StringBuffer rCode, String name, float[] arr, boolean useEquals) {
+ public static void addFloatArray(StringBuilder rCode, String name, float[] arr, boolean useEquals) {
addArray(rCode, name, ArrayUtils.toObject(arr), useEquals, false);
}
- public static void addDoubleArray(StringBuffer rCode, String name, double[] arr, boolean useEquals) {
+ public static void addDoubleArray(StringBuilder rCode, String name, double[] arr, boolean useEquals) {
addArray(rCode, name, ArrayUtils.toObject(arr), useEquals, false);
}
- public static void addStringArray(StringBuffer rCode, String name, String[] arr, boolean useEquals) {
+ public static void addStringArray(StringBuilder rCode, String name, String[] arr, boolean useEquals) {
addArray(rCode, name, arr, useEquals, true);
}
- public static void addShortArray(StringBuffer rCode, String name, short[] arr, boolean useEquals) {
+ public static void addShortArray(StringBuilder rCode, String name, short[] arr, boolean useEquals) {
addArray(rCode, name, ArrayUtils.toObject(arr), useEquals, false);
}
- public static void addLogicalArray(StringBuffer rCode, String name, boolean[] arr, boolean useEquals) {
+ public static void addLogicalArray(StringBuilder rCode, String name, boolean[] arr, boolean useEquals) {
String[] stringArray = new String[arr.length];
for (int i = 0; i < arr.length; i++) {
stringArray[i] = String.valueOf(arr[i]).toUpperCase();
@@ -71,7 +71,7 @@ public static void addLogicalArray(StringBuffer rCode, String name, boolean[] ar
addArray(rCode, name, stringArray, useEquals, false);
}
- public static void addArray(StringBuffer rCode, String name, T[] array, boolean useEquals, boolean isString) {
+ public static void addArray(StringBuilder rCode, String name, T[] array, boolean useEquals, boolean isString) {
if (!name.equals("")) {
if (useEquals) {
rCode.append(name).append("=");
@@ -98,14 +98,14 @@ public static void addArray(StringBuffer rCode, String name, T[] array, bool
}
}
- public static void addJavaObject(StringBuffer rCode, Object o, boolean useEquals) throws IllegalAccessException {
+ public static void addJavaObject(StringBuilder rCode, Object o, boolean useEquals) throws IllegalAccessException {
rCode.append(((JavaObject) o).produceRCode(useEquals));
if (!useEquals) {
rCode.append("\n");
}
}
- public static void addDoubleMatrix(StringBuffer rCode, String name, double[][] matrix, boolean useEquals) {
+ public static void addDoubleMatrix(StringBuilder rCode, String name, double[][] matrix, boolean useEquals) {
int dim2 = matrix[0].length;
int counter = 0;
if (!name.equals("")) {
@@ -131,31 +131,31 @@ public static void addDoubleMatrix(StringBuffer rCode, String name, double[][] m
}
}
- public static void addDouble(StringBuffer rCode, String name, double d, boolean useEquals) {
+ public static void addDouble(StringBuilder rCode, String name, double d, boolean useEquals) {
addValue(rCode, name, d, useEquals);
}
- public static void addInt(StringBuffer rCode, String name, int i, boolean useEquals) {
+ public static void addInt(StringBuilder rCode, String name, int i, boolean useEquals) {
addValue(rCode, name, i, useEquals);
}
- public static void addLong(StringBuffer rCode, String name, long l, boolean useEquals) {
+ public static void addLong(StringBuilder rCode, String name, long l, boolean useEquals) {
addValue(rCode, name, l, useEquals);
}
- public static void addFloat(StringBuffer rCode, String name, float f, boolean useEquals) {
+ public static void addFloat(StringBuilder rCode, String name, float f, boolean useEquals) {
addValue(rCode, name, String.valueOf(f).toUpperCase(), useEquals);
}
- public static void addShort(StringBuffer rCode, String name, short s, boolean useEquals) {
+ public static void addShort(StringBuilder rCode, String name, short s, boolean useEquals) {
addValue(rCode, name, s, useEquals);
}
- public static void addBoolean(StringBuffer rCode, String name, boolean b, boolean useEquals) {
+ public static void addBoolean(StringBuilder rCode, String name, boolean b, boolean useEquals) {
addValue(rCode, name, String.valueOf(b).toUpperCase(), useEquals);
}
- public static void addString(StringBuffer rCode, String name, String value, boolean useEquals) {
+ public static void addString(StringBuilder rCode, String name, String value, boolean useEquals) {
if (!name.equals("")) {
if (useEquals) {
rCode.append(name).append("=");
@@ -173,7 +173,7 @@ public static void addString(StringBuffer rCode, String name, String value, bool
}
}
- private static void addValue(StringBuffer rCode, String name, Object value, boolean useEquals) {
+ private static void addValue(StringBuilder rCode, String name, Object value, boolean useEquals) {
if (!name.equals("")) {
if (useEquals) {
rCode.append(name).append("=").append(value);
@@ -189,7 +189,7 @@ private static void addValue(StringBuffer rCode, String name, Object value, bool
}
}
- public static void addRespectToType(StringBuffer rCode, String name, Object o, boolean useEquals) {
+ public static void addRespectToType(StringBuilder rCode, String name, Object o, boolean useEquals) {
if (o instanceof double[]) {
RCodeUtils.addDoubleArray(rCode, name, (double[]) o, useEquals);
} else if (o instanceof int[]) {
@@ -230,7 +230,7 @@ public static void addRespectToType(StringBuffer rCode, String name, Object o, b
}
- public static void addDataFrame(StringBuffer rCode, String name, DataFrame dataFrame) {
+ public static void addDataFrame(StringBuilder rCode, String name, DataFrame dataFrame) {
try {
File file = File.createTempFile("dataFrame", ".csv");
CSVFileWriter csvFileWriter = CSVFileWriter.create(file.getAbsolutePath());
diff --git a/RCaller/src/test/java/com/github/rcaller/RunOnlineTest.java b/RCaller/src/test/java/com/github/rcaller/RunOnlineTest.java
index f6fe7b8..d0a210f 100644
--- a/RCaller/src/test/java/com/github/rcaller/RunOnlineTest.java
+++ b/RCaller/src/test/java/com/github/rcaller/RunOnlineTest.java
@@ -146,6 +146,7 @@ public void errorHandlerTest() {
@Test
public void timeoutTest() {
System.out.println("TIMEOUT TEST");
+ System.out.println("*** This must throw an exception:");
RCaller rcaller = RCaller.create(RCallerOptions.create(FailurePolicy.CONTINUE, 100)); //don't retry
RCode code = RCode.create();