List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:com.vmware.bdd.service.impl.ClusterLdapUserMgmtCfgService.java
public void configureUserMgmt(String clusterName) { List<NodeEntity> nodeEntityList = clusterEntityManager.findAllNodes(clusterName); ArrayList<String> nodeMgmtIpList = new ArrayList<>(); for (NodeEntity nodeEntity : nodeEntityList) { nodeMgmtIpList.add(nodeEntity.getPrimaryMgtIpV4()); }/*from w ww .j a v a 2s .c om*/ String[] nodeMgmtIps = new String[nodeEntityList.size()]; nodeMgmtIpList.toArray(nodeMgmtIps); configureUserMgmt(clusterName, nodeEntityList); }
From source file:es.pode.modificador.presentacion.configurar.objetos.ruta.IndicarRutaControllerImpl.java
/** * @see es.pode.modificador.presentacion.configurar.objetos.ruta.IndicarRutaController#aadirObjeto(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.objetos.ruta.AAdirObjetoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from w w w . ja va 2 s . co m*/ public final void aadirObjeto(ActionMapping mapping, es.pode.modificador.presentacion.configurar.objetos.ruta.AAdirObjetoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (form != null && form.getPath() != null && !(form.getPath().equals(""))) { String path = form.getPath(); ConfiguracionTarea configuracion = getConfigurarModificacionSession(request).getConfiguracion(); if (configuracion == null) { ConfiguracionTarea tarea = new ConfiguracionTarea(); tarea.setObjetos(new Objects()); tarea.setCambios(new Changes()); tarea.getObjetos().setObjetos(new ODE[0]); tarea.getObjetos().setPaths(new Folder[0]); tarea.getCambios().setCambios(new Change[0]); getConfigurarModificacionSession(request).setConfiguracion(tarea); configuracion = tarea; } // Folder nuevosObjetos[]; Folder objetos[] = null; if (configuracion.getObjetos() != null && configuracion.getObjetos().getPaths() != null) { objetos = configuracion.getObjetos().getPaths(); } // nuevosObjetos = new Folder[objetos.length + 1]; // } else { // nuevosObjetos = new Folder[1]; // } Folder nuevo = new Folder(path.trim(), null); if (objetos != null) { // Comprobamos si el objeto ya estaba en la lista. ArrayList listaObjetos = new ArrayList(Arrays.asList(objetos)); if (!listaObjetos.contains(nuevo)) { //Aado nuevo path a la lista listaObjetos.add(nuevo); configuracion.getObjetos().setPaths((Folder[]) listaObjetos.toArray(new Folder[] {})); } else { throw new ValidatorException("{indicarRuta.repeated}"); } } } else { throw new ValidatorException("{indicarRuta.empty}"); } }
From source file:com.baidu.android.voicedemo.ActivityTouch.java
@Override public void onResults(Bundle results) { long end2finish = System.currentTimeMillis() - speechEndTime; ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); print("?" + Arrays.toString(nbest.toArray(new String[nbest.size()]))); String json_res = results.getString("origin_result"); try {/* w ww . ja va 2s . com*/ print("origin_result=\n" + new JSONObject(json_res).toString(4)); } catch (Exception e) { print("origin_result=[warning: bad json]\n" + json_res); } btn.setText(""); String strEnd2Finish = ""; if (end2finish < 60 * 1000) { strEnd2Finish = "(waited " + end2finish + "ms)"; } txtResult.setText(nbest.get(0) + strEnd2Finish); }
From source file:com.jgeppert.struts2.jquery.showcase.Autocompleter.java
@Actions({ @Action(value = "/autocompleter-select", results = { @Result(location = "autocompleter-select.jsp", name = "success") }), @Action(value = "/autocompleter", results = { @Result(location = "autocompleter.jsp", name = "success") }), @Action(value = "/jsonlanguages", results = { @Result(type = "json", name = "success", params = { "root", "languages" }) }), @Action(value = "/jsoncustomers", results = { @Result(type = "json", name = "success") }) }) public String execute() throws Exception { if (term != null && term.length() > 1) { ArrayList<String> tmp = new ArrayList<String>(); for (int i = 0; i < staticLanguages.length; i++) { if (StringUtils.contains(staticLanguages[i].toLowerCase(), term.toLowerCase())) { tmp.add(staticLanguages[i]); }/*from ww w . j av a 2 s . c o m*/ } languages = tmp.toArray(new String[tmp.size()]); } return SUCCESS; }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
private static String[] getDrugSymbol(String demographic, String[] dins) { String[] ret = new String[dins.length]; ArrayList<String> list = new ArrayList<String>(); oscar.oscarRx.data.RxPrescriptionData prescriptData = new oscar.oscarRx.data.RxPrescriptionData(); for (String din : dins) { oscar.oscarRx.data.RxPrescriptionData.Prescription[] arr = prescriptData .getPrescriptionScriptsByPatientRegionalIdentifier(Integer.parseInt(demographic), din); list.add(arr[0].getBrandName()); }/*from ww w. j ava2 s. c om*/ ret = list.toArray(new String[list.size()]); return ret; }
From source file:com.espertech.esper.support.util.ArrayAssertionUtil.java
public static void compare(Iterator<EventBean> iterator, List<Map<String, Object>> expectedValues) { ArrayList<EventBean> values = new ArrayList<EventBean>(); while (iterator.hasNext()) { values.add(iterator.next());//from w w w . j a v a2s . c o m } try { iterator.next(); TestCase.fail(); } catch (NoSuchElementException ex) { // Expected exception - next called after hasNext returned false, for testing } EventBean[] data = null; if (values.size() > 0) { data = values.toArray(new EventBean[0]); } compare(data, expectedValues); }
From source file:ldn.cInicio.java
public boolean esSeguido(int id, int ids) throws Exception { if (seguidos == null) { ArrayList<Integer> list = new ArrayList<>(); BD.cDatos sql = new BD.cDatos(bd); sql.conectar();/* w ww.j a v a 2 s. co m*/ ResultSet gatito = sql.consulta("call _obtenlistaseguidos(" + id + ");"); while (gatito.next()) { list.add(gatito.getInt("idCuenta")); } seguidos = list.toArray(new Integer[list.size()]); } if (seguidos.length == 0) return false; else for (int i = 0; i < seguidos.length; i++) if (seguidos[i] == ids) return true; return false; }
From source file:net.robotmedia.billing.BillingController.java
/** * Called after the response to a// w w w . ja v a 2 s . c om * {@link net.robotmedia.billing.request.GetPurchaseInformation} request is * received. Registers all transactions in local memory and confirms those * who can be confirmed automatically. * * @param context * @param signedData * signed JSON data received from the Market Billing service. * @param signature * data signature. */ protected static void onPurchaseStateChanged(Context context, String signedData, String signature) { debug("Purchase state changed"); if (TextUtils.isEmpty(signedData)) { Log.w(LOG_TAG, "Signed data is empty"); return; } else { debug(signedData); } if (!debug) { if (TextUtils.isEmpty(signature)) { Log.w(LOG_TAG, "Empty signature requires debug mode"); return; } final ISignatureValidator validator = BillingController.validator != null ? BillingController.validator : new DefaultSignatureValidator(BillingController.configuration); if (!validator.validate(signedData, signature)) { Log.w(LOG_TAG, "Signature does not match data."); return; } } List<Transaction> purchases; try { JSONObject jObject = new JSONObject(signedData); if (!verifyNonce(jObject)) { Log.w(LOG_TAG, "Invalid nonce"); return; } purchases = parsePurchases(jObject); } catch (JSONException e) { Log.e(LOG_TAG, "JSON exception: ", e); return; } ArrayList<String> confirmations = new ArrayList<String>(); for (Transaction p : purchases) { if (p.notificationId != null && automaticConfirmations.contains(p.productId)) { confirmations.add(p.notificationId); } else { // TODO: Discriminate between purchases, cancellations and // refunds. addManualConfirmation(p.productId, p.notificationId); } storeTransaction(context, p); notifyPurchaseStateChange(p.productId, p.purchaseState); } if (!confirmations.isEmpty()) { final String[] notifyIds = confirmations.toArray(new String[confirmations.size()]); confirmNotifications(context, notifyIds); } }
From source file:graph.inference.module.GenlPredTransitiveWorker.java
@Override public void queryInternal(QueryObject queryObj) throws IllegalArgumentException { // Find related edges for args ArrayList<Object> nonPreds = new ArrayList<>(); Node[] nodes = queryObj.getNodes(); for (int i = 1; i < nodes.length; i++) { if (!(nodes[i] instanceof VariableNode)) { nonPreds.add(nodes[i]);//from ww w. j a va2s. c o m nonPreds.add(i + 1); } } Collection<Edge> nonPredEdges = relatedModule_.execute(nonPreds.toArray(new Object[nonPreds.size()])); // Sub preds VariableNode varNode = new VariableNode("?SUB_PREDS"); Collection<Substitution> subPreds = querier_.execute(CommonConcepts.GENLPREDS.getNode(dag_), varNode, queryObj.getNode(0)); if (subPreds.isEmpty()) subPreds.add(new Substitution(varNode, (DAGNode) queryObj.getNode(0))); for (Substitution sub : subPreds) { Node subPred = sub.getSubstitution(varNode); Collection<Edge> predEdges = relatedModule_.findEdgeByNodes(subPred); Collection<Edge> intersect = CollectionUtils.retainAll(nonPredEdges, predEdges); for (Edge interEdge : intersect) { Node[] edgeNodes = Arrays.copyOf(interEdge.getNodes(), interEdge.getNodes().length); if (queryObj.addResult(edgeNodes)) return; } } }
From source file:filterviewplugin.FilterViewSettings.java
ProgramFilter[] getActiveFiltersWithIcon() { if (mActiveFiltersWithIcon == null) { ArrayList<ProgramFilter> list = new ArrayList<ProgramFilter>(); for (ProgramFilter filter : getActiveFilters()) { if (getFilterIcon(filter) != null) { list.add(filter);//from w w w. ja v a 2s .c om } } mActiveFiltersWithIcon = list.toArray(new ProgramFilter[list.size()]); } return mActiveFiltersWithIcon; }