List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:keel.Algorithms.Preprocess.Basic.C45.C45.java
/** Constructor * * @param confArray Configuration array. * * @throws Exception If the algorithm cannot be executed. *//* w w w . jav a2s . c om*/ public C45(Vector confArray) { modelDataset = (Dataset) confArray.get(0); //trainDataset = (Dataset) confArray[1]; trainDataset = (Dataset) confArray.get(0); testDataset = (Dataset) confArray.get(1); prune = (Boolean) confArray.get(2); confidence = (Float) confArray.get(3); minItemsets = (Integer) confArray.get(4); priorsProbabilities = new double[modelDataset.numClasses()]; try { priorsProbabilities(); } catch (Exception ex) { Logger.getLogger(C45.class.getName()).log(Level.SEVERE, null, ex); } marginCounts = new double[marginResolution + 1]; }
From source file:de.uniluebeck.itm.spyglass.gui.wizard.WisebedPacketReaderConfigurationWizard.java
private String tryToAutoDetectLocalControllerEndpointUrl() { Vector<String> externalHostIps = BeanShellHelper.getExternalHostIps(); final String localControllerEndpointUrl; String host = externalHostIps.get(0); int port = UrlUtils.getRandomUnprivilegedPort(); int tries = 0; while (!checkIfServerSocketCanBeOpened(host, port)) { if (++tries == 3) { break; }// w w w . ja va2 s .c o m int oldPort = port; port = UrlUtils.getRandomUnprivilegedPort(); log.warn("Could not open ServerSocket on {}:{}. Retrying on port {}!", new Object[] { host, oldPort, port }); } localControllerEndpointUrl = "http://" + host + ":" + port + "/controller"; return tries == 3 ? null : localControllerEndpointUrl; }
From source file:eionet.gdem.qa.XQueryService.java
private String getExtension(Vector outputTypes, String content_type) { String ret = "html"; if (outputTypes == null) { return ret; }//from ww w. j a va 2 s. c om if (content_type == null) { return ret; } for (int i = 0; i < outputTypes.size(); i++) { Hashtable outType = (Hashtable) outputTypes.get(i); if (outType == null) { continue; } if (!outType.containsKey("conv_type") || !outType.containsKey("file_ext") || outType.get("conv_type") == null || outType.get("file_ext") == null) { continue; } String typeId = (String) outType.get("conv_type"); if (!content_type.equalsIgnoreCase(typeId)) { continue; } ret = (String) outType.get("file_ext"); } return ret; }
From source file:edu.pdx.cecs.orcycle.TripUploader.java
private String getPostData(long tripId) throws JSONException { JSONObject coords = getCoordsJSON(tripId); JSONArray pauses = getPausesJSON(tripId); //JSONObject user = getUserJSON(); JSONArray tripResponses = getTripResponsesJSON(tripId); String deviceId = userId;// w w w. j a v a2 s . c o m Vector<String> tripData = getTripData(tripId); String notes = tripData.get(0); String purpose = tripData.get(1); String startTime = tripData.get(2); String codedPostData = "purpose=" + purpose + "&tripid=" + String.valueOf(tripId) + // "&user=" + user.toString() + "¬es=" + notes + "&coords=" + coords.toString() + "&pauses=" + pauses.toString() + "&version=" + String.valueOf(kSaveProtocolVersion) + "&start=" + startTime + "&device=" + deviceId + "&tripResponses=" + tripResponses.toString(); return codedPostData; }
From source file:admin.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from www . j a va2 s . co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); response.setContentType("application/json;charset=UTF-8"); String id = ""; String nama = ""; String email = ""; String link = ""; String admin = ""; String icw = ""; try { JSONObject userAccount = (JSONObject) session.getAttribute("userAccount"); id = userAccount.get("id").toString(); nama = userAccount.get("name").toString(); email = userAccount.get("email").toString(); link = userAccount.get("link").toString(); admin = userAccount.get("admin").toString(); icw = userAccount.get("icw").toString(); } catch (Exception ex1) { } if (admin.equalsIgnoreCase("Y")) { try (PrintWriter out = response.getWriter()) { Vector dataPosisi = new Vector(); dataPosisi.addElement("Menteri"); dataPosisi.addElement("Pejabat Setingkat Menteri"); dataPosisi.addElement("Duta Besar"); JSONArray obj1 = new JSONArray(); for (int i = 0; i < dataPosisi.size(); i++) { String FilterKey = "", FilterValue = ""; String key = "posisi", keyValue = dataPosisi.get(i).toString().toLowerCase().replaceAll(" ", ""); String table = "posisi"; DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); //Filter linkFilter = new FilterPredicate(FilterKey, FilterOperator.EQUAL, FilterValue); Key AlasanStarCalonKey = KeyFactory.createKey(key, keyValue); Query query = new Query(table, AlasanStarCalonKey); PreparedQuery pq = datastore.prepare(query); JSONArray obj11 = new JSONArray(); getData(obj11, table, key, keyValue, dataPosisi.get(i).toString(), Query.SortDirection.ASCENDING); LinkedHashMap record = new LinkedHashMap(); record.put("posisi", keyValue); record.put("nama", dataPosisi.get(i).toString()); record.put("child", obj11); obj1.add(record); } out.print(JSONValue.toJSONString(obj1)); out.flush(); } } }
From source file:net.sf.javaml.clustering.AQBC.java
private double[] mean(Vector<TaggedInstance> a) { double[] out = new double[a.get(0).inst.noAttributes()]; for (int i = 0; i < a.size(); i++) { // System.out.println("Instance "+i+" = "+a.get(i)); for (int j = 0; j < a.get(0).inst.noAttributes(); j++) out[j] += a.get(i).inst.value(j); }// www . j a v a 2s. c o m // System.out.println("OUT = "+Arrays.toString(out)); for (int j = 0; j < a.get(0).inst.noAttributes(); j++) { out[j] /= a.size(); } return out; }
From source file:it.ms.theing.loquitur.functions.Brain.java
private boolean match(Vector<Vector<Member>> r, String[] tokens, Stack<Result> results) { for (Vector<Member> phrase : root) { index = 0;/*from ww w.ja va2 s .c om*/ results.clear(); if ((phrase.get(0).match(phrase, 0, results))) return true; } return false; }
From source file:gsn.http.ac.MyDataSourceCandidateWaitingListServlet.java
/******************************************************************************************************/ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); // Get the session HttpSession session = req.getSession(); ConnectToDB ctdb = null;//from w w w. j av a2s . com User user = (User) session.getAttribute("user"); if (user == null) { this.redirectToLogin(req, res); } else { this.checkSessionScheme(req, res); if (user.isAdmin() == false) { res.sendError(WebConstants.ACCESS_DENIED, "Access denied."); } else { this.printHeader(out); this.printLayoutMastHead(out, user); this.printLayoutContent(out); try { ctdb = new ConnectToDB(); Vector v = ctdb.getDataSourceCandidates(); if (v.size() == 0) { out.println("<p><B>There is no entry in the waiting list !</p></B>"); } for (int i = 0; i < v.size(); i++) { //printForm(out,(DataSource)(v.get(i))); printNewEntry(out, (DataSource) (v.get(i))); } } catch (Exception e) { out.println("<p><B>Can not print the form !</p></B>"); logger.error("ERROR IN doGet"); logger.error(e.getMessage(), e); } finally { if (ctdb != null) { ctdb.closeStatement(); ctdb.closeConnection(); } } this.printLayoutFooter(out); } } }
From source file:net.sf.jabref.exporter.layout.LayoutEntry.java
public LayoutEntry(Vector<StringInt> parsedEntries, final String classPrefix_, int layoutType) { classPrefix = classPrefix_;//from ww w . jav a 2s. co m Vector<StringInt> blockEntries = null; Vector<LayoutEntry> tmpEntries = new Vector<>(); LayoutEntry le; String blockStart = parsedEntries.get(0).s; String blockEnd = parsedEntries.get(parsedEntries.size() - 1).s; if (!blockStart.equals(blockEnd)) { LOGGER.warn("Field start and end entry must be equal."); } type = layoutType; text = blockEnd; for (StringInt parsedEntry : parsedEntries.subList(1, parsedEntries.size() - 1)) { if ((parsedEntry.i == LayoutHelper.IS_LAYOUT_TEXT) || (parsedEntry.i == LayoutHelper.IS_SIMPLE_FIELD)) { // Do nothing } else if ((parsedEntry.i == LayoutHelper.IS_FIELD_START) || (parsedEntry.i == LayoutHelper.IS_GROUP_START)) { blockEntries = new Vector<>(); blockStart = parsedEntry.s; } else if ((parsedEntry.i == LayoutHelper.IS_FIELD_END) || (parsedEntry.i == LayoutHelper.IS_GROUP_END)) { if (blockStart.equals(parsedEntry.s)) { blockEntries.add(parsedEntry); if (parsedEntry.i == LayoutHelper.IS_GROUP_END) { le = new LayoutEntry(blockEntries, classPrefix, LayoutHelper.IS_GROUP_START); } else { le = new LayoutEntry(blockEntries, classPrefix, LayoutHelper.IS_FIELD_START); } tmpEntries.add(le); blockEntries = null; } else { LOGGER.warn("Nested field entries are not implemented !!!"); } } else if (parsedEntry.i == LayoutHelper.IS_OPTION_FIELD) { // Do nothing } if (blockEntries == null) { tmpEntries.add(new LayoutEntry(parsedEntry, classPrefix)); } else { blockEntries.add(parsedEntry); } } layoutEntries = new LayoutEntry[tmpEntries.size()]; for (int i = 0; i < tmpEntries.size(); i++) { layoutEntries[i] = tmpEntries.get(i); // Note if one of the entries has an invalid formatter: if (layoutEntries[i].isInvalidFormatter()) { if (invalidFormatter == null) { invalidFormatter = new ArrayList<>(1); } invalidFormatter.addAll(layoutEntries[i].getInvalidFormatters()); } } }
From source file:com.linkedin.databus.core.TestDbusEventBufferPersistence.java
private void pushEventsToBuffer(DbusEventBuffer dbusBuf, int numEvents) { dbusBuf.start(1);/* www .jav a 2 s .c o m*/ dbusBuf.startEvents(); DbusEventGenerator generator = new DbusEventGenerator(); Vector<DbusEvent> events = new Vector<DbusEvent>(); generator.generateEvents(numEvents, 1, 100, 10, events); // set end of windows for (int i = 0; i < numEvents - 1; ++i) { long scn = events.get(i).sequence(); ++i; DbusEventInternalWritable writableEvent; try { writableEvent = DbusEventCorrupter.makeWritable(events.get(i)); } catch (InvalidEventException ie) { LOG.error("Exception trace is " + ie); Assert.fail(); return; } writableEvent.setSrcId((short) -2); writableEvent.setSequence(scn); writableEvent.applyCrc(); assertTrue("invalid event #" + i, writableEvent.isValid(true)); } // set up the ReadChannel with 2 events ByteArrayOutputStream oStream = new ByteArrayOutputStream(); WritableByteChannel oChannel = Channels.newChannel(oStream); for (int i = 0; i < numEvents; ++i) { ((DbusEventInternalReadable) events.get(i)).writeTo(oChannel, Encoding.BINARY); } byte[] writeBytes = oStream.toByteArray(); ByteArrayInputStream iStream = new ByteArrayInputStream(writeBytes); ReadableByteChannel rChannel = Channels.newChannel(iStream); try { dbusBuf.readEvents(rChannel); } catch (InvalidEventException ie) { LOG.error("Exception trace is " + ie); Assert.fail(); return; } }