List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.UploadField.java
/** * //from w ww. j ava 2s . c o m */ public void determinePrecisionAndScale() { if (field != null && field.getFieldInfo() != null && field.getFieldInfo().getType().equals("java.math.BigDecimal")) { String dbName = ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getDatabaseName(); String tblName = field.getFieldInfo().getTableInfo().getName(); String fldName = field.getFieldInfo().getName(); String colType = null; Vector<Object[]> rows = BasicSQLUtils.query(DBConnection.getInstance().getConnection(), "SELECT COLUMN_TYPE FROM `information_schema`.`COLUMNS` where TABLE_SCHEMA = '" + dbName + "' and TABLE_NAME = '" + tblName + "' and COLUMN_NAME = '" + fldName + "'"); if (rows.size() == 1) { colType = rows.get(0)[0].toString().toLowerCase().trim(); } if (colType != null && colType.startsWith("decimal")) { //"DECIMAL(19,2)" String psStr = colType.substring(8).replace(")", ""); String[] ps = psStr.split(","); if (ps.length == 2) { this.precision = Integer.valueOf(ps[0]); this.scale = Integer.valueOf(ps[1]); } } } this.precisionAndScaleDetermined = true; }
From source file:com.ibm.xsp.webdav.repository.DAVRepositoryDominoDocuments.java
private Base findDocumentInCollection(Base notesObj, String key, boolean isLast) { try {/* w w w .j a v a2 s.c o m*/ key = URLDecoder.decode(key, "UTF-8"); // // LOGGER.info("Start findDocumentInCollection Key="+key); if (notesObj instanceof View) { // // LOGGER.info("isView"); View notesView = (View) notesObj; if (notesView.getEntryCount() > 0) { // // LOGGER.info("Has "+new // Integer(notesView.getEntryCount()).toString()+" entries"); for (int i = 0; i < notesView.getEntryCount(); i++) { Document doc = notesView.getNthDocument(i + 1); if (doc != null) { // // LOGGER.info("Doc "+new // Integer(i).toString()+" is not null and has Unid="+doc.getUniversalID()); if ((isLast) && (doc.hasEmbedded())) { // // LOGGER.info("Doc has embedded"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", doc); String curAttName = allEmbedded.get(0).toString(); // // LOGGER.info("Embedded name="+curAttName); if (curAttName.equals(key)) { // // // LOGGER.info("Has view with doc unid="+doc.getUniversalID()); return doc; } } else { if (!isLast) { if (doc.getItemValueString(getDirectoryField()).equals(key)) { return doc; } } } } } } } else { if (notesObj instanceof Document) { // // LOGGER.info("isDoc"); Document doc = (Document) notesObj; DocumentCollection docColl = doc.getResponses(); if (docColl.getCount() > 0) { // // LOGGER.info("Has "+new // Integer(docColl.getCount()).toString()+" responses"); for (int i = 0; i < docColl.getCount(); i++) { Document docResp = docColl.getNthDocument(i + 1); if (docResp != null) { if ((isLast) && (docResp.hasEmbedded())) { // // // LOGGER.info("DocResp "+docResp.getUniversalID()+"has embedded"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp); String curAttName = allEmbedded.get(0).toString(); // // LOGGER.info("Curattname="+curAttName); if (curAttName.equals(key)) { // // // LOGGER.info("Has doc resp with doc unid="+docResp.getUniversalID()); return docResp; } } else { if (!isLast) { if (docResp.getItemValueString(getDirectoryField()).equals(key)) { return docResp; } } } } } } } } } catch (NotesException ne) { LOGGER.error("Error:" + ne.getMessage()); } catch (UnsupportedEncodingException ue) { LOGGER.error("Error:" + ue.getMessage()); } return null; }
From source file:com.projity.exchange.ServerFileImporter.java
protected void prepareResources(List srcResources, Predicate resourceFilter, boolean resourceDescriptorsOnly) throws Exception { ResourceMappingForm form = getResourceMapping(); if (form == null) return;/* www . ja va 2 s. c o m*/ //server resources Vector projityResources = new Vector(); EnterpriseResourceData unassigned = new EnterpriseResourceData(); unassigned.setUniqueId(EnterpriseResource.UNASSIGNED_ID); unassigned.setName(Messages.getString("Text.Unassigned")); //$NON-NLS-1$ form.setUnassignedResource(unassigned); projityResources.add(unassigned); try { Session session = SessionFactory.getInstance().getSession(false); projityResources.addAll((Collection) SessionFactory.call(session, resourceDescriptorsOnly ? "retrieveResourceDescriptors" : "retrieveResourceHierarchy", null, null)); if (projityResources != null && projityResources.size() > 0) form.setUnassignedResource(projityResources.get(0)); } catch (Exception e) { form.setLocal(true); return; } form.setResources(projityResources); //imported resources List resourcesToMap = new ArrayList(); Object resource; if (srcResources != null) for (Iterator i = srcResources.iterator(); i.hasNext();) { resource = i.next(); if (resourceFilter == null || resourceFilter.evaluate(resource)) resourcesToMap.add(resource); } form.setImportedResources(resourcesToMap); MergeField mergeField = new ResourceMappingForm.MergeField("name", "name", "name"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ form.addMergeField(mergeField); // if (!form.isJunit()) //claur // form.setMergeField(mergeField); mergeField = new ResourceMappingForm.MergeField("emailAddress", "emailAddress", "email"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ form.addMergeField(mergeField); mergeField = new ResourceMappingForm.MergeField("uniqueId", "externalId", "id"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ form.addMergeField(mergeField); }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Works like MetricsUpdates, except for offer backlog updates. These updates tell the server administrator * how many offers are waiting to be processed. When this number reaches some critical amount, the server * should temporarily stop accepting offers */ private void startOfferBacklogThread() { offerBacklogUpdates = new Vector(); Runnable updater = new Runnable() { public void run() { try { while (!offerBacklogDone) { OfferBacklogUpdate update = getNextUpdate(); if (update.backlog == -1) { log.debug("Shutting down auxiliary offer backlog update thread"); break; }/*from ww w . j a va2 s .com*/ Enumeration sessionIds = sessionMonitors.keys(); while (sessionIds.hasMoreElements()) { Integer key = (Integer) sessionIds.nextElement(); Vector monitors = (Vector) sessionMonitors.get(key); for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.setOfferBacklog(update.backlog, update.rejecting); } catch (MonitorDisconnectedException e) { log.error( "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); disconnectMonitor(key.intValue(), ui); } } } } } catch (Exception e) { log.error("MonitorServ failed to update admin screen with offer backlog information", e); } } private synchronized OfferBacklogUpdate getNextUpdate() throws InterruptedException { try { if (offerBacklogDone) { log.info("offerBacklogUpdate ending... returning from getNextUpdate()..."); return new OfferBacklogUpdate(0, false); } if (!offerBacklogUpdates.isEmpty() && offerBacklogUpdates.size() > 0) return (OfferBacklogUpdate) offerBacklogUpdates.remove(0); else wait(1000); return getNextUpdate(); } catch (Exception e) { log.debug("Offer backlog updates lost synchronization -- resynchronizing"); return getNextUpdate(); } } }; Thread updateThr = new Thread(updater); updateThr.setDaemon(true); updateThr.start(); }
From source file:edu.umn.cs.spatialHadoop.nasa.StockQuadTree.java
/** * Creates a full spatio-temporal hierarchy for a source folder * @throws ParseException //from w w w .j ava 2 s .c o m * @throws InterruptedException */ public static void directoryIndexer(final OperationsParams params) throws IOException, ParseException, InterruptedException { Path inputDir = params.getInputPath(); FileSystem sourceFs = inputDir.getFileSystem(params); final Path sourceDir = inputDir.makeQualified(sourceFs); Path destDir = params.getOutputPath(); final FileSystem destFs = destDir.getFileSystem(params); TimeRange timeRange = params.get("time") != null ? new TimeRange(params.get("time")) : null; // Create daily indexes that do not exist final Path dailyIndexDir = new Path(destDir, "daily"); FileStatus[] mathcingDays = timeRange == null ? sourceFs.listStatus(inputDir) : sourceFs.listStatus(inputDir, timeRange); final Vector<Path> sourceFiles = new Vector<Path>(); for (FileStatus matchingDay : mathcingDays) { for (FileStatus matchingTile : sourceFs.listStatus(matchingDay.getPath())) { sourceFiles.add(matchingTile.getPath()); } } // Shuffle the array for better load balancing across threads Collections.shuffle(sourceFiles); final String datasetName = params.get("dataset"); Parallel.forEach(sourceFiles.size(), new RunnableRange<Object>() { @Override public Object run(int i1, int i2) { LOG.info("Worker [" + i1 + "," + i2 + ") started"); for (int i = i1; i < i2; i++) { Path sourceFile = sourceFiles.get(i); try { Path relativeSourceFile = makeRelative(sourceDir, sourceFile); Path destFilePath = new Path(dailyIndexDir, relativeSourceFile); if (!destFs.exists(destFilePath)) { LOG.info("Worker [" + i1 + "," + i2 + ") indexing: " + sourceFile.getName()); Path tmpFile; do { tmpFile = new Path((int) (Math.random() * 1000000) + ".tmp"); } while (destFs.exists(tmpFile)); tmpFile = tmpFile.makeQualified(destFs); if (datasetName == null) throw new RuntimeException( "Please provide the name of dataset you would like to index"); AggregateQuadTree.build(params, sourceFile, datasetName, tmpFile); synchronized (destFs) { Path destDir = destFilePath.getParent(); if (!destFs.exists(destDir)) destFs.mkdirs(destDir); } destFs.rename(tmpFile, destFilePath); } } catch (IOException e) { throw new RuntimeException("Error building an index for " + sourceFile, e); } } LOG.info("Worker [" + i1 + "," + i2 + ") finished"); return null; } }); LOG.info("Done generating daily indexes"); // Merge daily indexes into monthly indexes Path monthlyIndexDir = new Path(destDir, "monthly"); final SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy.MM.dd"); final SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy.MM"); mergeIndexes(destFs, dailyIndexDir, monthlyIndexDir, dayFormat, monthFormat, params); LOG.info("Done generating monthly indexes"); // Merge daily indexes into monthly indexes Path yearlyIndexDir = new Path(destDir, "yearly"); final SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); mergeIndexes(destFs, monthlyIndexDir, yearlyIndexDir, monthFormat, yearFormat, params); LOG.info("Done generating yearly indexes"); }
From source file:edu.ku.brc.specify.datamodel.Address.java
@Override @Transient/*from www.j ava 2s .c o m*/ public Integer getParentId() { if (agent != null) { parentTblId = Agent.getClassTableId(); return agent.getId(); } Vector<Object> ids = BasicSQLUtils .querySingleCol("SELECT InstitutionID FROM institution WHERE AddressID = " + addressId); if (ids.size() == 1) { parentTblId = Institution.getClassTableId(); return (Integer) ids.get(0); } ids = BasicSQLUtils.querySingleCol("SELECT DivisionID FROM division WHERE AddressID = " + addressId); if (ids.size() == 1) { parentTblId = Division.getClassTableId(); return (Integer) ids.get(0); } parentTblId = null; return null; }
From source file:gda.device.scannable.scannablegroup.ScannableGroup.java
@Override public String checkPositionValid(Object illDefinedPosObject) throws DeviceException { Vector<Object[]> targets; try {/* www. jav a 2 s.c o m*/ targets = extractPositionsFromObject(illDefinedPosObject); } catch (Exception e) { return e.getMessage(); } for (int i = 0; i < groupMembers.size(); i++) { Object[] thisTarget = targets.get(i); if ((thisTarget != null) && (thisTarget.length > 0) && (thisTarget[0] != null)) { String reason = groupMembers.get(i).checkPositionValid(thisTarget); if (reason != null) { return reason; } } } return null; }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.DispatchServ.java
/** Called whenever a client attempts to make a trade */ public Response processTransactionRequest(Request req) { if (!isSessionValid(req)) return new Response(Response.INVALID_SESSION_RESPONSE); int sessionId = req.getIntInfo("sessionId"); AbstractOffer newOffer = (AbstractOffer) req.getInfo("offer"); long key = req.getLongInfo("key"); int periodNum = controlServ.getPeriodNum(sessionId); TradeEngine tradeServ = activeEngines.get(sessionId); UpdateBasket basket = tradeServ.processOffer(sessionId, newOffer, key); int periodTime = controlServ.getPeriodTime(sessionId); int[] marketTime = controlServ.getMarketTime(sessionId); int openingTime = controlServ.getOpeningTime(sessionId); Vector tradeUpdates = basket.getTradeUpdates(); for (int i = 0; i < tradeUpdates.size(); i++) { TradeUpdate tupdate = (TradeUpdate) tradeUpdates.get(i); tupdate.setPeriodTime(periodTime); tupdate.setMarketTime(marketTime); tupdate.setOpeningTime(openingTime); }/*from w ww . j a v a 2 s . c om*/ updateServ.sendTradeUpdates(periodNum, tradeUpdates); monitorServ.processTransactionUpdates(basket); return new Response(Response.GENERAL_ACK_RESPONSE); }
From source file:net.java.sen.tools.DictionaryMaker.java
private int getDicIdNoCache(String csv[]) { Vector result = new Vector(); getIdList(csv, result, 1);// w w w .j a v a 2 s . c om if (result.size() == 0) { log.error("can't find morpheme type"); log.error("input string is here:"); log.error("ruleList size=" + ruleList.size()); StringBuffer buf = new StringBuffer(); for (int i = 0; i < csv.length; i++) { buf.append(csv[i]); buf.append(","); } log.error(buf); return -1; } int priority[] = new int[result.size()]; int max = 0; for (int i = 0; i < result.size(); i++) { String v[] = (String[]) ruleList.get(((Integer) result.get(i)).intValue()); for (int j = 0; j < v.length; j++) { if (v[j].charAt(0) != '*') priority[i]++; } if (priority[max] < priority[i]) max = i; log.debug("detect=="); log.debug(getById(((Integer) result.get(max)).intValue())); } return ((Integer) result.get(max)).intValue(); }
From source file:com.urs.triptracks.TripUploader.java
private String getPostData(long tripId) throws JSONException { //JSONObject coords = getCoordsJSON(tripId); String coords = getCoordsJSON(tripId); Log.v("coordsoutput:", coords); //JSONObject user = getUserJSON(); String user = getUserJSON().toString(); Log.v("useroutput:", user); //JSONObject everystop=getEveryStopJSON(); //String deviceId = getDeviceId(); Vector<String> tripData = getTripData(tripId); //String notes = tripData.get(0); String purpose = tripData.get(0); String startTime = tripData.get(1); String stopTime = tripData.get(2); String travelBy = tripData.get(3); int members = Integer.parseInt(tripData.get(4)); int nonmembers = Integer.parseInt(tripData.get(5)); int delays = Integer.parseInt(tripData.get(6)); int toll = Integer.parseInt(tripData.get(7)); double tollAmt = Double.parseDouble(tripData.get(8)); int payForParking = Integer.parseInt(tripData.get(9)); double payForParkingAmt = Double.parseDouble(tripData.get(10)); double fare = Double.parseDouble(tripData.get(11)); /*List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("coords", coords.toString())); nameValuePairs.add(new BasicNameValuePair("user", user.toString())); //HS//from w w w . jav a2 s . c o m nameValuePairs.add(new BasicNameValuePair("travelBy", travelBy)); nameValuePairs.add(new BasicNameValuePair("members", members)); nameValuePairs.add(new BasicNameValuePair("nonmembers", nonmembers)); nameValuePairs.add(new BasicNameValuePair("delays", delays)); nameValuePairs.add(new BasicNameValuePair("toll", toll)); nameValuePairs.add(new BasicNameValuePair("tollAmt", tollAmt)); nameValuePairs.add(new BasicNameValuePair("payForParking", payForParking)); nameValuePairs.add(new BasicNameValuePair("payForParkingAmt", payForParkingAmt)); nameValuePairs.add(new BasicNameValuePair("fare", fare)); nameValuePairs.add(new BasicNameValuePair("device", deviceId)); nameValuePairs.add(new BasicNameValuePair("purpose", purpose)); nameValuePairs.add(new BasicNameValuePair("startTime", startTime)); nameValuePairs.add(new BasicNameValuePair("stopTime", stopTime)); nameValuePairs.add(new BasicNameValuePair("version", "2"));*/ //return nameValuePairs; String codedPostData = "{\"coords\":[" + coords + "],\"user\":" + user + ",\"travelBy\":\"" + travelBy + "\",\"members\":" + members + ",\"nonmembers\":" + nonmembers + ",\"delays\":" + delays + ",\"toll\":" + toll + ",\"tollAmt\":" + tollAmt + ",\"payForParking\":" + payForParking + ",\"payForParkingAmt\":" + payForParkingAmt + ",\"fare\":" + fare //+ ", device:" + deviceId + ",\"purpose\":\"" + purpose + "\",\"startTime\":\"" + startTime + "\",\"stopTime\":\"" + stopTime + "\",\"version\":" + 2 + "}"; //String codedPostData = "\"UserId:\"" + "\"hema5\""; //String codedPostData= new JSONObject().put("UserId", "hemax").toString();//worked //String codedPostData= new JSONObject().put("UserId", "hemax").toString(); // codedPostData= new JSONObject(codedPostData).toString(); //codedPostData. //JSONObject travelBy=new JSONObject(); /* JSONObject jason=new JSONObject(); jason.put("coords", coords); jason.put("user", user); jason.put("travelBy", travelBy); jason.put("members", members); jason.put("nonMembers", nonmembers); jason.put("delays", delays); jason.put("toll", toll); jason.put("tollAmt", tollAmt); jason.put("payForParking", payForParking); jason.put("payForParkingAmt", payForParkingAmt); jason.put("fare", fare); //jason.put("device", deviceId); jason.put("purpose", purpose); jason.put("startTime", startTime); jason.put("stopTime", stopTime); jason.put("version", 2);*/ //return jason.toString(); return codedPostData; }