List of usage examples for org.apache.commons.lang ArrayUtils addAll
public static double[] addAll(double[] array1, double[] array2)
Adds all the elements of the given arrays into a new array.
From source file:org.dspace.statistics.Dataset.java
public ByteArrayOutputStream exportAsCSV() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); CSVWriter ecsvp = new CSVWriter(new OutputStreamWriter(baos), ';'); //Generate the item row List<String> colLabels = getColLabels(); colLabels.add(0, ""); ecsvp.writeNext(colLabels.toArray(new String[colLabels.size()])); List<String> rowLabels = getRowLabels(); String[][] matrix = getMatrix(); for (int i = 0; i < rowLabels.size(); i++) { String rowLabel = rowLabels.get(i); ecsvp.writeNext((String[]) ArrayUtils.addAll(new String[] { rowLabel }, matrix[i])); }//w w w. j a va 2 s . com ecsvp.flush(); ecsvp.close(); return baos; }
From source file:org.eclairjs.nashorn.JSBaseFunction.java
@SuppressWarnings({ "null", "unchecked" }) protected Object callScript(Object params[]) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); if (this.args != null && this.args.length > 0) { this.argsJS = new Object[this.args.length]; for (int i = 0; i < this.args.length; i++) this.argsJS[i] = Utils.javaToJs(this.args[i], e); }/*from w ww. j av a 2 s . c o m*/ } Invocable invocable = (Invocable) e; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } for (int i = 0; i < params.length; i++) params[i] = Utils.javaToJs(params[i], e); Object ret = ((ScriptObjectMirror) this.fn).call(null, params); ret = Utils.jsToJava(ret); return ret; }
From source file:org.eclairjs.nashorn.JSComparator.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from w ww. ja v a 2s . c om public int compare(Object o, Object o2) { int ret = -1; try { ScriptEngine e = NashornEngineSingleton.getEngine(); // if (this.fn == null) { /* if we try to save teh evaluated function for future use we get serialization exception, why Comparators are different than java.api.functions ? */ Object fn = e.eval(func); //} Invocable invocable = (Invocable) e; Object params[] = { fn, o, o2 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } //Tuple2<String, String> s = new Tuple2("foo", "bar"); //scala.collection.Iterator<Object> i = s.productIterator(); ret = Integer.valueOf(invocable.invokeFunction("Utils_invoke", params).toString()); return ret; } catch (Exception exc) { exc.printStackTrace(); } return ret; }
From source file:org.eclairjs.nashorn.JSComparator.java
@SuppressWarnings({ "null", "unchecked" }) @Override/*from w ww.j a v a 2 s . c om*/ public boolean equals(Object o) { boolean ret = false; try { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } ret = Boolean.valueOf(invocable.invokeFunction(this.functionName, params).toString()); } catch (Exception exc) { // do nothing for now } return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF1.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from w w w.j a v a 2s .c om public Object call(Object o) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF10.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from ww w.j a v a 2 s . co m public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o, o2, o3, o4, o5, o6, o7, o8, o9, o10 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF11.java
@SuppressWarnings({ "null", "unchecked" }) @Override/*from w w w .jav a 2 s . c om*/ public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10, Object o11) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF12.java
@SuppressWarnings({ "null", "unchecked" }) @Override// ww w .j av a 2s . c om public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10, Object o11, Object o12) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF13.java
@SuppressWarnings({ "null", "unchecked" }) @Override/*w w w .j a v a 2s.co m*/ public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10, Object o11, Object o12, Object o13) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF14.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from www.ja va 2 s. c o m public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10, Object o11, Object o12, Object o13, Object o14) throws Exception { ScriptEngine e = NashornEngineSingleton.getEngine(); if (this.fn == null) { this.fn = e.eval(func); } Invocable invocable = (Invocable) e; Object params[] = { this.fn, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14 }; if (this.args != null && this.args.length > 0) { params = ArrayUtils.addAll(params, this.args); } Object ret = invocable.invokeFunction("Utils_invoke", params); ret = this.castValueToReturnType(ret); return ret; }