List of usage examples for java.util ArrayList get
public E get(int index)
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void actualizarConvocatoria(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlAdmin.actualizarConvocatoria(Integer.parseInt(request.getParameter("0")), // id request.getParameter("1"), // nombre request.getParameter("2"), // descripcin request.getParameter("4"), // fin Integer.parseInt(request.getParameter("6")) // cupos );// w w w . j a v a2 s . co m response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); if (r.get(0) == "error") { JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", r.get(1)); out.print(obj); } else if (r.get(0) == "isExitoso") { JSONObject obj = new JSONObject(); obj.put("Exitoso", true); out.print(obj); } else Util.errordeRespuesta(r, out); }
From source file:jog.my.memory.gcm.ServerUtilities.java
/** * Convert images to the string representation * @param pics - pictures to send/*w w w . j a v a 2 s.c om*/ * @return arraylist of string representation of pictures */ public static ArrayList<String> convertPhotosToStringRepresentation(ArrayList<Picture> pics) { ArrayList<String> listPhotos = new ArrayList<>(); for (int i = 0; i < pics.size(); i++) { // String stringEncodedImage = // Base64.encodeToString(pics.get(i).getmImageAsByteArray(), Base64.DEFAULT); // listPhotos.add(stringEncodedImage); Bitmap bitmap = pics.get(i).getmImage(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); byte[] bitmapByte = outputStream.toByteArray(); listPhotos.add(Base64.encodeToString(bitmapByte, Base64.DEFAULT)); // try { // listPhotos.add(new String(bitmapByte)); // } // catch(Exception e){ // Log.d(TAG,"The encoding didn't work"); // } } return listPhotos; }
From source file:com.vk.sdk.payments.VKIInAppBillingService.java
private static Receipt getReceipt(@NonNull final Object iInAppBillingService, final int apiVersion, @NonNull final String packageName, @NonNull final String receiptOriginal) throws JSONException, RemoteException { JSONObject objectReceipt = new JSONObject(receiptOriginal); Receipt receipt = new Receipt(); receipt.receiptData = receiptOriginal; receipt.quantity = 1;//w w w.j a v a 2 s. c o m String sku = objectReceipt.getString(PRODUCT_ID); ArrayList<String> skuList = new ArrayList<>(); skuList.add(sku); Bundle queryBundle = new Bundle(); queryBundle.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList); Bundle responseBundle = getSkuDetails(iInAppBillingService, apiVersion, packageName, "inapp", queryBundle); ArrayList<String> responseList = responseBundle.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); if (responseList != null && !responseList.isEmpty()) { try { JSONObject object = new JSONObject(responseList.get(0)); receipt.priceValue = Float.parseFloat(object.optString(SKU_DETAIL_AMOUNT_MICROS)) / 1000000f; receipt.currency = object.optString(SKU_DETAIL_PRICE_CURRENCY_CODE); } catch (JSONException e) { // nothing } } return receipt; }
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.util.StatHelper.java
/** * Returns the mode statistic (String) of a frequency table as a Map object * whose responses (keys) are String and their corresponding frequencies are * Integers//w w w. j a va 2 s.c o m * * @param FrequencyTable the Map whose keys are String and values are * Integers * @return the mode statistic of the frequency table as a * String */ public static String getMode(Map<String, Integer> FrequencyTable) { ArrayList<Map.Entry<String, Integer>> entries = new ArrayList<Map.Entry<String, Integer>>( FrequencyTable.entrySet()); sortMapEntryListByValue(entries); return entries.get(0).getKey(); }
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.util.StatHelper.java
/** * Returns the mode statistic (int) of a frequency table as a Map object * whose responses (keys) are String and their corresponding frequencies are * Integers//from ww w . j av a 2s .co m * * @param FrequencyTable the Map whose keys are String and values are * Integers * @return the mode statistic of the frequency table as * an int */ public static int getMaxResponse(Map<String, Integer> FrequencyTable) { ArrayList<Map.Entry<String, Integer>> entries = new ArrayList<Map.Entry<String, Integer>>( FrequencyTable.entrySet()); sortMapEntryListByValue(entries); return entries.get(0).getValue(); }
From source file:Main.java
/** * Maps a coordinate in the root to a descendent. *///from www.j a va 2 s . c o m public static float mapCoordInSelfToDescendent(View descendant, View root, float[] coord, Matrix tmpInverseMatrix) { ArrayList<View> ancestorChain = new ArrayList<>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); tmpInverseMatrix.set(IDENTITY_MATRIX); for (int i = count - 1; i >= 0; i--) { View ancestor = ancestorChain.get(i); View next = i > 0 ? ancestorChain.get(i - 1) : null; pt[0] += ancestor.getScrollX(); pt[1] += ancestor.getScrollY(); if (next != null) { pt[0] -= next.getLeft(); pt[1] -= next.getTop(); next.getMatrix().invert(tmpInverseMatrix); tmpInverseMatrix.mapPoints(pt); scale *= next.getScaleX(); } } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:GenAppStoreSales.java
/** * Creates a dataset./*from www .java 2 s .co m*/ * * @return A dataset. */ public static CategoryDataset createDataset2(ArrayList<String> cLabels, ArrayList<ArrayList<Integer>> cUnits) { DefaultCategoryDataset result = new DefaultCategoryDataset(); periodUnits = 0; int sum = 0; for (int d = cUnits.get(0).size() - 1; d >= 0; d--) { for (int country = 0; country < cUnits.size(); country++) { sum += cUnits.get(country).get(d); } result.addValue(sum, "0", String.valueOf(cUnits.get(0).size() - d)); periodUnits += sum; sum = 0; } chartTitle = windowTitle + " @ Total Sales = " + String.valueOf(periodUnits) + " units"; return result; }
From source file:com.app.server.util.ClassLoaderUtil.java
public static CopyOnWriteArrayList closeClassLoader(ClassLoader cl) { CopyOnWriteArrayList jars = new CopyOnWriteArrayList(); boolean res = false; Class classURLClassLoader = null; if (cl instanceof URLClassLoader) { classURLClassLoader = URLClassLoader.class; if (cl instanceof WebClassLoader) { String url = ""; CopyOnWriteArrayList webCLUrl = ((WebClassLoader) cl).geturlS(); for (int index = 0; index < webCLUrl.size(); index++) { try { url = ((URL) webCLUrl.get(index)).toURI().toString(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); }// ww w . j a va2 s . co m jars.add(url.replace("file:", "").replace("/", "\\").toUpperCase()); } } } else if (cl instanceof VFSClassLoader) { classURLClassLoader = VFSClassLoader.class; } Field f = null; try { f = classURLClassLoader.getDeclaredField("ucp"); //log.info(f); } catch (NoSuchFieldException e1) { // e1.printStackTrace(); // log.info(e1.getMessage(), e1); } if (f != null) { f.setAccessible(true); Object obj = null; try { obj = f.get(cl); } catch (IllegalAccessException e1) { // e1.printStackTrace(); // log.info(e1.getMessage(), e1); } if (obj != null) { final Object ucp = obj; f = null; try { f = ucp.getClass().getDeclaredField("loaders"); //log.info(f); } catch (NoSuchFieldException e1) { // e1.printStackTrace(); // log.info(e1.getMessage(), e1); } if (f != null) { f.setAccessible(true); ArrayList loaders = null; try { loaders = (ArrayList) f.get(ucp); res = true; } catch (IllegalAccessException e1) { // e1.printStackTrace(); } for (int i = 0; loaders != null && i < loaders.size(); i++) { obj = loaders.get(i); f = null; try { f = obj.getClass().getDeclaredField("jar"); // log.info(f); } catch (NoSuchFieldException e) { // e.printStackTrace(); // log.info(e.getMessage(), e); } if (f != null) { f.setAccessible(true); try { obj = f.get(obj); } catch (IllegalAccessException e1) { // e1.printStackTrace(); // log.info(e1.getMessage(), e1); } if (obj instanceof JarFile) { final JarFile jarFile = (JarFile) obj; //log.info(jarFile.getName()); jars.add(jarFile.getName().replace("/", "\\").trim().toUpperCase()); // try { // jarFile.getManifest().clear(); // } catch (IOException e) { // // ignore // } try { jarFile.close(); } catch (IOException e) { e.printStackTrace(); // ignore // log.info(e.getMessage(), e); } } } } } } } return jars; }
From source file:edu.oregonstate.eecs.mcplan.domains.fuelworld.FuelWorldState.java
/** * This is the same as 'createDefault()', but it adds edges from each * main-line top node to a corresponding bottom-track node. This means * that the agent always has an action choice, and must continue making * the right choice to succeed.// w w w . j av a2 s . c o m * @param rng * @return */ public static FuelWorldState createDefaultWithChoices(final RandomGenerator rng) { int counter = 0; final ArrayList<TIntList> adjacency = new ArrayList<TIntList>(); final int start = counter++; adjacency.add(new TIntArrayList()); final int goal = counter++; adjacency.add(new TIntArrayList()); final TIntList fuel_depots = new TIntArrayList(); // Bottom path final int nuisance_begin = counter + 5; final int nuisance_end = counter + 7; adjacency.get(start).add(counter++); adjacency.add(new TIntArrayList()); final int first_bottom = counter - 1; for (int i = 0; i < 7; ++i) { adjacency.get(counter - 1).add(counter++); adjacency.add(new TIntArrayList()); } adjacency.get(counter - 1).add(goal); // Nuisance loop on bottom path adjacency.get(nuisance_begin).add(counter++); adjacency.add(new TIntArrayList()); for (int i = 0; i < 3; ++i) { adjacency.get(counter - 1).add(counter++); adjacency.add(new TIntArrayList()); } fuel_depots.add(counter); adjacency.get(counter - 1).add(counter++); adjacency.add(new TIntArrayList()); adjacency.get(counter - 1).add(nuisance_end); // Top main-line path adjacency.get(start).add(counter++); adjacency.add(new TIntArrayList()); final int first_top = counter - 1; for (int i = 0; i < 9; ++i) { if (i == 8) { fuel_depots.add(counter - 1); } adjacency.get(counter - 1).add(counter++); adjacency.add(new TIntArrayList()); } adjacency.get(counter - 1).add(goal); // Fuel depot loops int loop_begin = adjacency.get(adjacency.get(start).get(1)).get(0); for (int loop = 0; loop < 3; ++loop) { adjacency.get(loop_begin).add(counter++); adjacency.add(new TIntArrayList()); adjacency.get(counter - 1).add(counter++); adjacency.add(new TIntArrayList()); fuel_depots.add(counter - 1); adjacency.get(counter - 1).add(loop_begin + 1); loop_begin += 2; } // Paths from top -> bottom for (int i = 0; i < 8; ++i) { adjacency.get(first_top + i).add(first_bottom + i); } // for( int i = 0; i < adjacency.size(); ++i ) { // final TIntList list = adjacency.get( i ); // System.out.println( "V" + i + ": " + list ); // } // System.out.println( "Fuel: " + fuel_depots ); return new FuelWorldState(rng, adjacency, goal, new TIntHashSet(fuel_depots)); }
From source file:com.clustercontrol.jobmanagement.composite.WaitRuleComposite.java
public static JobObjectInfo array2JobObjectInfo(ArrayList<?> tableLineData) { Integer type = (Integer) tableLineData.get(GetWaitRuleTableDefine.JUDGMENT_OBJECT); JobObjectInfo info = new JobObjectInfo(); info.setValue(0);/*w ww . j av a2 s. c o m*/ info.setType(type); if (info.getType() == JudgmentObjectConstant.TYPE_JOB_END_STATUS) { info.setJobId((String) tableLineData.get(GetWaitRuleTableDefine.JOB_ID)); String value = (String) tableLineData.get(GetWaitRuleTableDefine.START_VALUE); info.setValue(EndStatusMessage.stringToType(value)); } else if (info.getType() == JudgmentObjectConstant.TYPE_JOB_END_VALUE) { info.setJobId((String) tableLineData.get(GetWaitRuleTableDefine.JOB_ID)); Integer value = (Integer) tableLineData.get(GetWaitRuleTableDefine.START_VALUE); info.setValue(value); } else if (info.getType() == JudgmentObjectConstant.TYPE_TIME) { Date value = (Date) tableLineData.get(GetWaitRuleTableDefine.START_VALUE); info.setTime(value.getTime()); } else if (info.getType() == JudgmentObjectConstant.TYPE_START_MINUTE) { Integer startMinute = (Integer) tableLineData.get(GetWaitRuleTableDefine.START_VALUE); info.setStartMinute(startMinute); } else if (info.getType() == JudgmentObjectConstant.TYPE_JOB_PARAMETER) { info.setDecisionValue01((String) tableLineData.get(GetWaitRuleTableDefine.DECISION_VALUE_1)); Integer condition = (Integer) tableLineData.get(GetWaitRuleTableDefine.DECISION_CONDITION); info.setDecisionCondition(condition); info.setDecisionValue02((String) tableLineData.get(GetWaitRuleTableDefine.DECISION_VALUE_2)); } String description = (String) tableLineData.get(GetWaitRuleTableDefine.DESCRIPTION); info.setDescription(description); return info; }