List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:gda.device.scannable.scannablegroup.ScannableGroup.java
@Override public void asynchronousMoveTo(Object position) throws DeviceException { //TODO must check if the number of inputs match with number of members Vector<Object[]> targets = extractPositionsFromObject(position); // send out moves for (int i = 0; i < groupMembers.size(); i++) { // Don't try to move zero-input-extra name scannables if ((groupMembers.get(i).getInputNames().length + groupMembers.get(i).getExtraNames().length) == 0) { continue; }//from ww w. j a v a2 s. co m Object[] thisTarget = targets.get(i); if (thisTarget.length == 1) { if (targets.get(i)[0] != null) { groupMembers.get(i).asynchronousMoveTo(targets.get(i)[0]); } } else { groupMembers.get(i).asynchronousMoveTo(targets.get(i)); } } }
From source file:edu.ku.brc.specify.toycode.RegPivot.java
/** * /*from w w w . j av a2s .co m*/ */ public void crossMapCC() { Statement stmt = null; try { stmt = connection.createStatement(); BasicSQLUtils.setDBConnection(connection); String sql = "SELECT TrkID, id from trk"; String lkSQL = "SELECT lookup, Country, City FROM reg WHERE id = '%s'"; PreparedStatement pStmt = connection.prepareStatement( String.format("UPDATE %s SET lookup=?, Country=?, City=? WHERE %s = ?", "trk", "TrkID")); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { int trkId = rs.getInt(1); String idStr = rs.getString(2); Vector<Object[]> rows = BasicSQLUtils.query(String.format(lkSQL, idStr)); if (rows != null && rows.size() > 0) { Object[] row = rows.get(0); pStmt.setString(1, (String) row[0]); pStmt.setString(2, (String) row[1]); pStmt.setString(3, (String) row[2]); pStmt.setInt(4, trkId); pStmt.executeUpdate(); } } pStmt.close(); stmt.close(); System.out.println("Done."); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Update the time left on the server monitors of the given session with the given amount */ public void updateTimeLeft(int sessionId, int timeLeft) { Vector monitors = getMonitors(sessionId); if (monitors == null) { log.warn("Cannot update MonitorTransmitters with new time left status for session " + sessionId + " -- that session does not exist!"); return;// w w w. j a v a2s . co m } for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.setTimeLeft(timeLeft); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(sessionId, ui); } } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Set the start button, end button, and status message to the session running or not running state for * each monitor associated with the given session id */ public void setSessionRunning(int sessionId, boolean running) { Vector monitors = getMonitors(sessionId); if (monitors == null) { log.warn("Cannot update MonitorTransmitters with start button status for session " + sessionId + " -- that session does not exist!"); return;// w w w . ja v a2 s. c o m } for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.setStartExpButtonEnabled(!running); ui.setStopExpButtonEnabled(running); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(sessionId, ui); } } }
From source file:com.bailen.radioOnline.recursos.REJA.java
public Cancion[] getRatings(String apiKey) throws IOException { HttpHeaders header = new HttpHeaders(); header.set("Authorization", apiKey); HttpEntity entity = new HttpEntity(header); String lista = new String(); HttpEntity<String> response; response = new RestTemplate().exchange("http://ceatic.ujaen.es:8075/radioapi/v2/ratings", HttpMethod.GET, entity, String.class, lista); String canc = response.getBody(); StringTokenizer st = new StringTokenizer(canc, "[", true); st.nextToken();/*from ww w . j a v a2s . co m*/ if (!st.hasMoreTokens()) { return null; } st.nextToken(); canc = "[" + st.nextToken(); try { ObjectMapper a = new ObjectMapper(); ItemPuntu[] listilla = a.readValue(canc, ItemPuntu[].class); Vector<Integer> ids = new Vector<>(); Vector<Cancion> punt = new Vector<>(); //como jamendo solo devuelve 10 canciones llamamos las veces necesarias for (int i = 0; i < (listilla.length / 10) + 1; ++i) { ids.clear(); //aunque le mandemos mas ids de la cuenta solo devolvera las 10 primeras canciones y //de esta forma controlamos el desborde for (int j = i * 10; j < listilla.length; ++j) { ids.add(listilla[j].getId()); } Cancion[] listilla1 = jamendo.canciones(ids); for (int k = 0; k < listilla1.length; ++k) { punt.add(listilla1[k]); } } for (int i = 0; i < punt.size(); ++i) { punt.get(i).setRating(listilla[i].getRating()); punt.get(i).setFav(listilla[i].getFav()); } return punt.toArray(new Cancion[punt.size()]); } catch (Exception e) { //return null; throw new IOException("no se han recibido canciones"); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Update the status string on each of the server monitors associated with the given session ID to the * given string *///from ww w . j a v a 2 s .c om public void updateExpStatus(int sessionId, String msg) { Vector monitors = getMonitors(sessionId); if (monitors == null) { log.warn("Cannot update MonitorTransmitters with new experiment status for session " + sessionId + " -- that session does not exist!"); return; } for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.updateExpStatus(msg); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(sessionId, ui); } } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Update the connection status of the given client in the given session. This takes client ID * number, not database ID number */ public void updateConnectionStatus(int sessionId, int subjectId, boolean connected) { Vector monitors = getMonitors(sessionId); if (monitors == null) { log.warn("Cannot update MonitorTransmitters with new connection status for session " + sessionId + " -- that session does not exist!"); return;//from w ww . jav a 2 s. co m } for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.setConnected(subjectId, connected); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(sessionId, ui); } } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Terminate the given session in the monitor interface by removing all monitors associated * with the given session. Also disable the stop button in all the montiors of that session */ public void terminateSession(int sessionId) { Vector monitors = getMonitors(sessionId); if (monitors == null) { log.warn("Cannot update MonitorTransmitters with session terminated status for session " + sessionId + " -- that session does not exist!"); return;//from w w w . j a v a 2 s . com } for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.setStopExpButtonEnabled(false); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(sessionId, ui); } } sessionMonitors.remove(new Integer(sessionId)); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectClinicalRawFileListener.java
public boolean createTabFileFromSoft(File rawFile, File newFile) { Vector<String> columns = new Vector<String>(); Vector<HashMap<String, String>> lines = new Vector<HashMap<String, String>>(); try {/* w w w. j a va 2s. c o m*/ BufferedReader br = new BufferedReader(new FileReader(rawFile)); String line; Pattern p1 = Pattern.compile(".SAMPLE = .*"); Pattern p2 = Pattern.compile("!Sample_characteristics_ch. = .*: .*"); while ((line = br.readLine()) != null) { if (line.compareTo("") != 0) { Matcher m1 = p1.matcher(line); Matcher m2 = p2.matcher(line); if (m1.matches()) { lines.add(new HashMap<String, String>()); if (!columns.contains("sample")) { columns.add("sample"); } lines.get(lines.size() - 1).put("sample", line.split(".SAMPLE = ", -1)[1]); } else if (m2.matches()) { String s = line.split("!Sample_characteristics_ch. = ", -1)[1]; String tag = s.split(": ", -1)[0]; if (!columns.contains(tag)) { columns.add(tag); } lines.get(lines.size() - 1).put(tag, s.split(": ", -1)[1]); } } } br.close(); } catch (Exception e) { selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage()); e.printStackTrace(); } if (columns.size() <= 1) { selectRawFilesUI.setMessage("Wrong soft format: no characteristics"); selectRawFilesUI.setIsLoading(false); return false; } FileWriter fw; try { fw = new FileWriter(newFile); BufferedWriter out = new BufferedWriter(fw); for (int i = 0; i < columns.size() - 1; i++) { out.write(columns.get(i) + "\t"); } out.write(columns.get(columns.size() - 1) + "\n"); for (HashMap<String, String> sample : lines) { for (int i = 0; i < columns.size() - 1; i++) { String value = sample.get(columns.get(i)); if (value == null) value = ""; out.write(value + "\t"); } String value = sample.get(columns.get(columns.size() - 1)); if (value == null) value = ""; out.write(value + "\n"); } out.close(); return true; } catch (IOException e) { // TODO Auto-generated catch block selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage()); selectRawFilesUI.setIsLoading(false); e.printStackTrace(); return false; } }
From source file:fr.inrialpes.exmo.align.cli.GroupEval.java
public void printLATEX(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far int correctVect[]; // correct so far long timeVect[]; // time so far Formatter formatter = new Formatter(writer); fsize = format.length();/*w ww . j a v a 2 s . c o m*/ // JE: the h-means computation should be put out as well // Print the header writer.println("\\documentclass[11pt]{book}"); writer.println(); writer.println("\\begin{document}"); writer.println("\\date{today}"); writer.println(""); writer.println("\n%% Plot generated by GroupEval of alignapi"); writer.println("\\setlength{\\tabcolsep}{3pt} % May be changed"); writer.println("\\begin{table}"); writer.print("\\begin{tabular}{|l||"); for (int i = size; i > 0; i--) { for (int j = fsize; j > 0; j--) writer.print("c"); writer.print("|"); } writer.println("}"); writer.println("\\hline"); // For each file do a writer.print("algo"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.print(" & \\multicolumn{" + fsize + "}{c|}{" + m + "}"); } writer.println(" \\\\ \\hline"); writer.print("test"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { writer.print("Prec."); } else if (format.charAt(i) == 'f') { writer.print("FMeas."); } else if (format.charAt(i) == 'o') { writer.print("Over."); } else if (format.charAt(i) == 't') { writer.print("Time"); } else if (format.charAt(i) == 'r') { writer.print("Rec."); } } } writer.println(" \\\\ \\hline"); foundVect = new int[size]; correctVect = new int[size]; timeVect = new long[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; } for (Vector<Object> test : result) { int nexpected = -1; // Print the directory writer.print((String) test.get(0)); // For each record print the values Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { PRecEvaluator eval = (PRecEvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { expected += eval.getExpected(); nexpected = 0; } foundVect[k] += eval.getFound(); correctVect[k] += eval.getCorrect(); timeVect[k] += eval.getTime(); for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecision()); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", eval.getFmeasure()); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", eval.getOverall()); } else if (format.charAt(i) == 't') { if (eval.getTime() == 0) { writer.print("-"); } else { formatter.format("%1.2f", eval.getTime()); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecall()); } } } else { writer.print(" & \\multicolumn{" + fsize + "}{c|}{n/a}"); } } writer.println(" \\\\"); } writer.print("H-mean"); // Here we are computing a sheer average. // While in the column results we print NaN when the returned // alignment is empty, // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; // ??? for (String m : listAlgo) { double precision = (double) correctVect[k] / foundVect[k]; double recall = (double) correctVect[k] / expected; for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { formatter.format("%1.2f", precision); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", recall * (2 - (1 / precision))); } else if (format.charAt(i) == 't') { if (timeVect[k] == 0) { writer.print("-"); } else { formatter.format("%1.2f", timeVect[k]); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recall); } } ; k++; } writer.println(" \\\\ \\hline"); writer.println("\\end{tabular}"); writer.println( "\\caption{Plot generated by GroupEval of alignapi \\protect\\footnote{n/a: result alignment not provided or not readable -- NaN: division per zero, likely due to empty alignment.}}"); writer.println("\\end{table}"); writer.println("\\end{document}"); }