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.eclairjs.nashorn.sql.JSUDF4.java
@SuppressWarnings({ "null", "unchecked" }) @Override/*from w ww . j a v a 2 s. c om*/ public Object call(Object o, Object o2, Object o3, Object o4) 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 }; 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.JSUDF5.java
@SuppressWarnings({ "null", "unchecked" }) @Override/* w w w .ja v a2 s . c om*/ public Object call(Object o, Object o2, Object o3, Object o4, Object o5) 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 }; 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.JSUDF6.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from w w w .j a va2s . c o m public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6) 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); } } Invocable invocable = (Invocable) e; Object params[] = { o, o2, o3, o4, o5, o6 }; 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 = invocable.invokeFunction("myTestFunc", params); Object ret = ((ScriptObjectMirror) this.fn).call(null, params); // Object ret = invocable.invokeFunction("Utils_invoke", params); //ret = Utils.jsToJava(ret); ret = this.castValueToReturnType(ret); return ret; }
From source file:org.eclairjs.nashorn.sql.JSUDF7.java
@SuppressWarnings({ "null", "unchecked" }) @Override//from w w w . java 2 s. c o m public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7) 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 }; 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.JSUDF8.java
@SuppressWarnings({ "null", "unchecked" }) @Override// w ww. ja 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) 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 }; 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.JSUDF9.java
@SuppressWarnings({ "null", "unchecked" }) @Override/*w w w . j a va 2s . c o m*/ public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9) 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 }; 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.eclipse.jubula.client.ui.rcp.provider.contentprovider.TestCaseBrowserContentProvider.java
/** * {@inheritDoc}/*from ww w . jav a 2 s . com*/ */ public Object[] getChildren(Object parentElement) { if (parentElement instanceof ISpecObjContPO[]) { return new Object[] { ((ISpecObjContPO[]) parentElement)[0] }; } if (parentElement instanceof ISpecObjContPO) { ISpecObjContPO specObjects = (ISpecObjContPO) parentElement; List<Object> elements = new ArrayList<Object>(); elements.addAll(specObjects.getSpecObjList()); IProjectPO activeProject = GeneralStorage.getInstance().getProject(); if (activeProject != null) { elements.addAll(activeProject.getUsedProjects()); } else { LOG.error(Messages.TestCaseBrowser_NoActiveProject); } return elements.toArray(); } if (parentElement instanceof IExecTestCasePO) { ISpecTestCasePO referencedTestCase = ((IExecTestCasePO) parentElement).getSpecTestCase(); if (referencedTestCase != null) { return ArrayUtils.addAll( Collections.unmodifiableCollection(referencedTestCase.getAllEventEventExecTC()).toArray(), referencedTestCase.getUnmodifiableNodeList().toArray()); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } if (parentElement instanceof INodePO) { INodePO parentNode = ((INodePO) parentElement); Object[] children = parentNode.getUnmodifiableNodeList().toArray(); if (parentElement instanceof ISpecTestCasePO) { children = ArrayUtils.addAll(Collections .unmodifiableCollection(((ISpecTestCasePO) parentElement).getAllEventEventExecTC()) .toArray(), children); } return children; } if (parentElement instanceof IReusedProjectPO) { try { IProjectPO reusedProject = ProjectPM .loadReusedProjectInMasterSession((IReusedProjectPO) parentElement); if (reusedProject != null) { return reusedProject.getSpecObjCont().getSpecObjList().toArray(); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } catch (JBException e) { ErrorHandlingUtil.createMessageDialog(e, null, null); return ArrayUtils.EMPTY_OBJECT_ARRAY; } } return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:org.eclipse.jubula.client.ui.rcp.provider.contentprovider.TestSuiteBrowserContentProvider.java
/** * @param parentElement Object/* ww w .ja va 2s .c o m*/ * @return object array */ public Object[] getChildren(Object parentElement) { if (parentElement instanceof IProjectPO) { return new Object[] { ((IProjectPO) parentElement).getExecObjCont() }; } if (parentElement instanceof IExecObjContPO) { IExecObjContPO execObjects = (IExecObjContPO) parentElement; List<Object> elements = new ArrayList<Object>(); elements.addAll(execObjects.getExecObjList()); return elements.toArray(); } if (parentElement instanceof IExecTestCasePO) { ISpecTestCasePO referencedTestCase = ((IExecTestCasePO) parentElement).getSpecTestCase(); if (referencedTestCase != null) { Collection<IEventExecTestCasePO> eventTCs = Collections .unmodifiableCollection(referencedTestCase.getAllEventEventExecTC()); List<INodePO> nodes = referencedTestCase.getUnmodifiableNodeList(); return ArrayUtils.addAll(eventTCs.toArray(), nodes.toArray()); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } if (parentElement instanceof ITestSuitePO) { ITestSuitePO testSuite = (ITestSuitePO) parentElement; WorkingLanguageBP workLangBP = WorkingLanguageBP.getInstance(); Locale workLang = workLangBP.getWorkingLanguage(); if (testSuite.getAut() != null && !workLangBP.isTestSuiteLanguage(workLang, testSuite)) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } // fall through } if (parentElement instanceof INodePO) { List<INodePO> nodes = ((INodePO) parentElement).getUnmodifiableNodeList(); return nodes.toArray(); } LOG.error("Wrong type for parent element: " + parentElement); //$NON-NLS-1$ return ArrayUtils.EMPTY_OBJECT_ARRAY; }
From source file:org.eclipse.mylyn.internal.reviews.ui.providers.GenericTreeContentProvider.java
protected Object[] getCollectionChildren(Object element) { if (element instanceof Collection) { Collection<?> collection = (Collection<?>) element; Object[] elements = new Object[] {}; for (Object member : collection) { elements = ArrayUtils.addAll(elements, getElements(member)); }//from w ww. ja va 2 s . c o m return elements; } return new Object[0]; }
From source file:org.eclipse.scanning.test.scan.nexus.MandelbrotRemoteTest.java
private void testScan(int... shape) throws Exception { IRunnableDevice<ScanModel> scanner = createGridScan(detector, shape); // Outer scan of another scannable, for instance temp. ((AbstractRunnableDevice<ScanModel>) scanner).start(null); // Does the scan in a thread. // We now connect a remote dataset looking at the scan file and see if we get information about it. final ScanModel mod = ((AbstractRunnableDevice<ScanModel>) scanner).getModel(); String filePath = ((AbstractRunnableDevice<ScanModel>) scanner).getModel().getFilePath(); IDatasetConnector remote = dataService.createRemoteDataset("localhost", server.getPort()); remote.setPath(filePath);//from www. ja va 2 s . co m remote.setDatasetName("/entry/instrument/" + mod.getDetectors().get(0).getName() + "/data"); remote.setWritingExpected(true); // We know that we are writing to this file, so we declare it. remote.connect(); scanner.latch(1, TimeUnit.SECONDS); try { final List<DataEvent> events = new ArrayList<DataEvent>(7); remote.addDataListener(new IDataListener() { @Override public void dataChangePerformed(DataEvent evt) { System.out.println("Data change notified for " + evt.getFilePath()); System.out.println("Shape is " + Arrays.toString(evt.getShape())); events.add(evt); } }); // Wait until the scan end. final CountDownLatch latch = new CountDownLatch(1); ((AbstractRunnableDevice<ScanModel>) scanner).addRunListener(new IRunListener() { @Override public void runPerformed(RunEvent evt) throws ScanningException { try { scanner.latch(500, TimeUnit.MILLISECONDS); // Finish off writing nexus file. The Remote dataset event lags slightly while nexus flushes. } catch (TimeoutException | ExecutionException | InterruptedException e) { e.printStackTrace(); } latch.countDown(); } }); latch.await(); assertTrue("There should be some events, there were: " + events.size(), events.size() > 0); // There won't be the full 40 but there should be a lot of them. int[] fshape = ArrayUtils.addAll(shape, new int[] { model.getRows(), model.getColumns() }); int[] eshape = events.get(events.size() - 1).getShape(); assertTrue(Arrays.equals(fshape, eshape)); } finally { remote.disconnect(); } // Check we reached ready (it will normally throw an exception on error) checkNexusFile(scanner, shape); // Step model is +1 on the size }