List of usage examples for java.util ArrayList get
public E get(int index)
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void quitarUsuarioTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.abandonarTallerUsuario(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); //1. idUsuario, 2. idEvento 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);// w w w. j a va 2 s . c om } 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:de.fau.amos.FileDownload.java
/** * Creates a .csv file containing the data of the passed "ArrayList<ArrayList<String>> data" and saves it into the "userdir.location" directory * @param data// w w w . j av a2s . com * @param fileName */ private static void createCsvFile(ArrayList<ArrayList<String>> data, String fileName) { try { String lines = ""; //using Buffered Writer to write a file into the "userdir.location" directory BufferedWriter bw = new BufferedWriter( new FileWriter(new File(System.getProperty("userdir.location"), fileName))); //every single value will be written down into the file separated by a semicolon for (int i = 0; i < data.size(); i++) { for (int j = 0; j < data.get(i).size(); j++) { lines = data.get(i).get(j) + "; "; bw.write(lines); } bw.newLine(); } bw.flush(); bw.close(); System.out.println("Success!"); } catch (IOException e) { System.out.println("Couldn't create File!"); } }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void crearConvocatoria(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlAdmin.crearConvocatoria(request.getParameter("1"), // nombre request.getParameter("2"), // descripcin request.getParameter("4"), // fin Integer.parseInt(request.getParameter("6")) // cupos );//w w w.jav a 2s . c o 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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarATallerDocenteByDoc(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.registrarATallerDocenteByDoc(request.getParameter("1"), Integer.parseInt(request.getParameter("2"))); // parameter 1: documentoDocente param2: idTaller 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);/*from ww w .java2 s .c o m*/ } 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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void quitarUsuarioConvocatoria(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.abandonarConvocatoria(Integer.parseInt(request.getParameter("1")), //1. idUsuario Integer.parseInt(request.getParameter("2"))// 2. idEvento );/* w w w .j av a 2 s . c o 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:com.hpe.nv.samples.basic.BasicComparisonWithoutNV.java
public static void printTimes(ExportableResult analyzeResult) throws InterruptedException { ArrayList<ExportableSummary> transactionSummaries = analyzeResult.getTransactionSummaries(); ExportableSummary firstTransactionSummary = transactionSummaries.get(0); DocumentProperties firstTransactionProperties = firstTransactionSummary.getProperties(); if (!debug) { SpinnerStatus.getInstance().pauseThread(); System.out.print("\b "); }// www . j a v a 2 s . com System.out.println(""); System.out.println("Site navigation time in seconds:"); double timeWithoutNV = (stopNoNV - startNoNV) / 1000; double timeWithNV = (firstTransactionProperties.getNetworkTime() / 1000); System.out.println("--- Time to navigate to the site without NV emulation: " + timeWithoutNV + "s"); System.out.println( "--- Time to navigate to the site with the NV \"3G Busy\" network scenario: " + timeWithNV + "s"); System.out.println("--------- (Running this transaction with network emulation increased the time by: " + (timeWithNV - timeWithoutNV) + "s)"); if (!debug) { SpinnerStatus.getInstance().resumeThread(); } }
From source file:de.tud.kom.p2psim.impl.network.gnp.topology.GnpSpace.java
/** * Static method generates a new GnpSpace according to the downhill simplex * operator/*from w ww . ja v a 2s . com*/ * * @param solutions * @return center solution */ private static GnpSpace getCenterSolution(ArrayList<GnpSpace> solutions) { GnpSpace returnValue = new GnpSpace(solutions.get(0).getNoOfDimensions(), solutions.get(0).getMapRef()); for (int c = 0; c < returnValue.getNumberOfMonitors(); c++) { ArrayList<GnpPosition> coords = new ArrayList<GnpPosition>(); for (int d = 0; d < solutions.size(); d++) { coords.add(solutions.get(d).getMonitorPosition(c)); } returnValue.setMonitorPosition(c, GnpPosition.getCenterSolution(coords)); } return returnValue; }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarUsuarioTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.registrarATallerUsuario(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuario param2: idTaller 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);// www .j a v a 2 s . c om } 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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarDocenteTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.registrarATallerDocente(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuarioDocente param2: idTaller 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);// w w w .ja va2 s . c o m } 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:Main.java
/** * Given an un-encoded URI query string, this will return a normalized, properly encoded URI query string. * <b>Important:</b> This method uses java's URLEncoder, which returns things that are * application/x-www-form-urlencoded, instead of things that are properly octet-esacped as the URI spec * requires. As a result, some substitutions are made to properly translate space characters to meet the * URI spec.//from w w w .j a v a 2 s . com * @param queryString * @return */ private static String normalizeQueryString(String queryString) throws UnsupportedEncodingException { if ("".equals(queryString) || queryString == null) return queryString; String[] pieces = queryString.split("&"); HashMap<String, String> kvp = new HashMap<String, String>(); StringBuffer builder = new StringBuffer(""); for (int x = 0; x < pieces.length; x++) { String[] bs = pieces[x].split("=", 2); bs[0] = URLEncoder.encode(bs[0], "UTF-8"); if (bs.length == 1) kvp.put(bs[0], null); else { kvp.put(bs[0], URLEncoder.encode(bs[1], "UTF-8").replaceAll("\\+", "%20")); } } // Sort the keys alphabetically, ignoring case. ArrayList<String> keys = new ArrayList<String>(kvp.keySet()); Collections.sort(keys, new Comparator<String>() { public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); // With the alphabetic list of parameter names, re-build the query string. for (int x = 0; x < keys.size(); x++) { // Some parameters have no value, and are simply present. If so, we put null in kvp, // and we just put the parameter name, no "=value". if (kvp.get(keys.get(x)) == null) builder.append(keys.get(x)); else builder.append(keys.get(x) + "=" + kvp.get(keys.get(x))); if (x < (keys.size() - 1)) builder.append("&"); } return builder.toString(); }