List of usage examples for java.util Vector size
public synchronized int size()
From source file:gov.nih.nci.evs.browser.utils.ViewInHierarchyUtils.java
public String getFocusCode(String ontology_node_id) { if (ontology_node_id == null) return null; if (ontology_node_id.indexOf("_dot_") == -1) { return ontology_node_id; }/* ww w.j a va 2 s.c o m*/ Vector v = parseData(ontology_node_id, "_"); for (int i = 0; i < v.size(); i++) { String t = (String) v.elementAt(i); } if (v.contains("root")) { return restoreNodeID((String) v.elementAt(1)); } return restoreNodeID((String) v.elementAt(0)); }
From source file:net.aepik.alasca.plugin.schemaconverter.core.SchemaConverter.java
/** * Retourne l'ensemble des syntaxes de conversion possibles pour la * syntaxe du schma et un dictionnaire donn (tir du traducteur). * @param dictionnaire Le nom du dictionnaire prendre en compte. **///from www . j ava2 s . com public String[] getAvailableSyntaxes(String dictionnary) { String[] result = null; if (traduc.setSelectedDictionnary(dictionnary)) { String[] src = traduc.getSourceSyntaxes(); String[] dst = traduc.getDestinationSyntaxes(); boolean srcOk = false; // On regarde si la syntaxe du schma est dans l'ensemble des // syntaxes sources. String currentSyntax = schema.getSyntax().toString(); for (int i = 0; i < src.length && !srcOk; i++) { if (src[i].equals(currentSyntax)) srcOk = true; } // On regarde si les syntaxes de destinations sont prsentes // dans le logiciel, dans ce cas on les ajoutes dans le rsultat. Vector<String> resultTmp = new Vector<String>(); String[] syntaxes = Schema.getSyntaxes(); // Syntaxes logiciels for (int i = 0; i < dst.length && srcOk; i++) { for (int j = 0; j < syntaxes.length; j++) { if (syntaxes[j].equals(dst[i])) resultTmp.add(dst[i]); } } result = new String[resultTmp.size()]; Iterator<String> it = resultTmp.iterator(); int compteur = 0; while (it.hasNext()) { result[compteur] = it.next(); compteur++; } } if (result != null & result.length == 0) result = null; return result; }
From source file:net.rim.ejde.internal.builders.PreprocessingBuilder.java
/** * Preprocess the specified java resource. * * @param resource//from www . j a va2s . c o m * @param symbols * @param monitor * @throws CoreException */ private void preprocessResource(final IResource resource, IProgressMonitor monitor) throws CoreException { // remove the old markers and preprocessed file removePreprocessingMarkers(resource, IResource.DEPTH_ONE); deletePreprocessedFile((IFile) resource, monitor); // BlackBerryProperties properties = ContextManager.PLUGIN.getBBProperties(getProject().getName(), false); if (properties == null) { _log.error("Could not find the correspond BlackBerry properties."); return; } // get defined directives Vector<String> defines = getDefines(new BlackBerryProject(JavaCore.create(getProject()), properties), true); // if there is no directive defined, we do not do preprocessing if (defines == null || defines.size() == 0) return; // check preprocess hook if (!SourceMapperAccess.isHookCodeInstalled() && PreprocessorPreferences.getPopForPreprocessHookMissing()) { _log.error("Preprocessing hook was not installed."); //$NON-NLS-1$ ProjectUtils.setPreprocessorHook(); return; } else { _log.trace("Preprocessing file : " + resource.getLocation()); //$NON-NLS-1$ } // remove the fake preprocess derive defines.remove(Workspace.getDefineOptNull()); // get java file File javaFile = resource.getLocation().toFile(); Vector<File> javaFiles = new Vector<File>(); javaFiles.add(javaFile); IPreprocessingListenerDelegate listener = new PreprocessingListener(resource); IOutputFileCallbackDelegate callback = new OutputFileCallback(); _javaPP.setPreprocessingListener(listener); _javaPP.setOutputFileCallback(callback); try { _javaPP.preProcess(javaFiles, defines, _preprocessedFolder.getLocation().toFile()); resource.touch(monitor); } catch (IOException e) { // Is handled by PreprocessingListener } catch (Exception e) { try { ResourceBuilderUtils.createProblemMarker(resource, IRIMMarker.PREPROCESSING_PROBLEM_MARKER, e.getMessage(), -1, IMarker.SEVERITY_ERROR); } catch (CoreException e1) { _log.error(e1); } // if we got any exception, delete the proprocessed file. _log.debug(e.getMessage(), e); deletePreprocessedFile((IFile) resource, monitor); } setShouldBuiltByJavaBuilder(resource, javaFiles.size() != 0); }
From source file:edu.umn.cs.spatialHadoop.util.Parallel.java
public static <T> List<T> forEach(int start, int end, RunnableRange<T> r, int parallelism) throws InterruptedException { Vector<T> results = new Vector<T>(); if (end <= start) return results; final Vector<Throwable> exceptions = new Vector<Throwable>(); Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread th, Throwable ex) { exceptions.add(ex);//w w w . j a v a2 s. c o m } }; // Put an upper bound on parallelism to avoid empty ranges if (parallelism > (end - start)) parallelism = end - start; if (parallelism == 1) { // Avoid creating threads results.add(r.run(start, end)); } else { LOG.info("Creating " + parallelism + " threads"); final int[] partitions = new int[parallelism + 1]; for (int i_thread = 0; i_thread <= parallelism; i_thread++) partitions[i_thread] = i_thread * (end - start) / parallelism + start; final Vector<RunnableRangeThread<T>> threads = new Vector<RunnableRangeThread<T>>(); for (int i_thread = 0; i_thread < parallelism; i_thread++) { RunnableRangeThread<T> thread = new RunnableRangeThread<T>(r, partitions[i_thread], partitions[i_thread + 1]); thread.setUncaughtExceptionHandler(h); threads.add(thread); threads.lastElement().start(); } for (int i_thread = 0; i_thread < parallelism; i_thread++) { threads.get(i_thread).join(); results.add(threads.get(i_thread).getResult()); } if (!exceptions.isEmpty()) throw new RuntimeException(exceptions.size() + " unhandled exceptions", exceptions.firstElement()); } return results; }
From source file:com.sshtools.common.ui.SessionProviderFactory.java
SessionProviderFactory() { ExtensionClassLoader classloader = ConfigurationLoader.getExtensionClassLoader(); try {//from w ww. ja va2 s. co m Enumeration enumr = classloader.getResources("session.provider"); URL url = null; Properties properties; InputStream in; SessionProvider provider; String name; String id; while (enumr.hasMoreElements()) { try { url = (URL) enumr.nextElement(); in = url.openStream(); properties = new Properties(); properties.load(in); IOUtil.closeStream(in); if (properties.containsKey("provider.class") && properties.containsKey("provider.name")) { Class cls = classloader.loadClass(properties.getProperty("provider.class")); String optionsClassName = properties.getProperty("provider.options"); Class optionsClass = optionsClassName == null || optionsClassName.equals("") ? null : classloader.loadClass(optionsClassName); String pageclass; int num = 1; Vector pages = new Vector(); do { pageclass = properties.getProperty("property.page." + String.valueOf(num), null); if (pageclass != null) { pages.add(classloader.loadClass(pageclass)); num++; } } while (pageclass != null); Class[] propertypages = new Class[pages.size()]; pages.toArray(propertypages); name = properties.getProperty("provider.name"); int weight = Integer.parseInt(properties.getProperty("provider.weight")); id = properties.getProperty("provider.id", name); provider = new SessionProvider(id, name, cls, properties.getProperty("provider.shortdesc"), properties.getProperty("provider.mnemonic"), properties.getProperty("provider.smallicon"), properties.getProperty("provider.largeicon"), optionsClass, propertypages, weight); providers.put(id, provider); log.info("Installed " + provider.getName() + " session provider"); } } catch (ClassNotFoundException ex) { log.warn("Session provider class not found", ex); } catch (IOException ex) { log.warn("Failed to read " + url.toExternalForm(), ex); } } } catch (IOException ex) { } }
From source file:cm.aptoide.pt.Aptoide.java
private void proceed() { if (sPref.getInt("version", 0) < pkginfo.versionCode) { db.UpdateTables();// w w w .j a v a 2 s . c o m prefEdit.putBoolean("mode", true); prefEdit.putInt("version", pkginfo.versionCode); prefEdit.commit(); } if (sPref.getString("myId", null) == null) { String rand_id = UUID.randomUUID().toString(); prefEdit.putString("myId", rand_id); prefEdit.commit(); } if (sPref.getInt("scW", 0) == 0 || sPref.getInt("scH", 0) == 0) { DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); prefEdit.putInt("scW", dm.widthPixels); prefEdit.putInt("scH", dm.heightPixels); prefEdit.commit(); } if (sPref.getString("icdown", null) == null) { prefEdit.putString("icdown", "g3w"); prefEdit.commit(); } setContentView(R.layout.start); mProgress = (ProgressBar) findViewById(R.id.pbar); new Thread(new Runnable() { public void run() { Vector<ApkNode> apk_lst = db.getAll("abc"); mProgress.setMax(apk_lst.size()); PackageManager mPm; PackageInfo pkginfo; mPm = getPackageManager(); keepScreenOn.acquire(); for (ApkNode node : apk_lst) { if (node.status == 0) { try { pkginfo = mPm.getPackageInfo(node.apkid, 0); String vers = pkginfo.versionName; int verscode = pkginfo.versionCode; db.insertInstalled(node.apkid, vers, verscode); } catch (Exception e) { //Not installed anywhere... does nothing } } else { try { pkginfo = mPm.getPackageInfo(node.apkid, 0); String vers = pkginfo.versionName; int verscode = pkginfo.versionCode; db.UpdateInstalled(node.apkid, vers, verscode); } catch (Exception e) { db.removeInstalled(node.apkid); } } mProgressStatus++; // Update the progress bar mHandler.post(new Runnable() { public void run() { mProgress.setProgress(mProgressStatus); } }); } keepScreenOn.release(); Message msg = new Message(); msg.what = LOAD_TABS; startHandler.sendMessage(msg); } }).start(); }
From source file:net.nosleep.superanalyzer.analysis.views.GrowthView.java
private void refreshDataset() { TimeSeries series1 = new TimeSeries(Misc.getString("SONGS_IN_LIBRARY")); Hashtable addedHash = null;// w w w. j av a2 s . c o m if (_comboBox == null) { addedHash = _analysis.getDatesAdded(Analysis.KIND_TRACK, null); } else { ComboItem item = (ComboItem) _comboBox.getSelectedItem(); addedHash = _analysis.getDatesAdded(item.getKind(), item.getValue()); } Vector items = new Vector(); Enumeration e = addedHash.keys(); while (e.hasMoreElements()) { Day day = (Day) e.nextElement(); Integer count = (Integer) addedHash.get(day); if (count.intValue() > 0) { items.addElement(new GrowthItem(day, count)); } } Collections.sort(items, new GrowthComparator()); double value = 0.0; for (int i = 0; i < items.size(); i++) { GrowthItem item = (GrowthItem) items.elementAt(i); value += item.Count; series1.add(item.Day, value); } _dataset.removeAllSeries(); _dataset.addSeries(series1); }
From source file:com.concursive.connect.web.modules.admin.actions.AdminSync.java
public String executeCommandStartSync(ActionContext context) { if (!getUser(context).getAccessAdmin()) { return "PermissionError"; }/* ww w. j ava 2 s.co m*/ if (!hasMatchingFormToken(context)) { return "TokenError"; } boolean isValid = false; String serverURL = null; String apiClientId = null; String apiCode = null; String startSync = null; String saveConnectionDetails = null; Connection db = null; try { Scheduler scheduler = (Scheduler) context.getServletContext().getAttribute(Constants.SCHEDULER); Vector syncStatus = (Vector) scheduler.getContext().get("CRMSyncStatus"); String syncListings = context.getRequest().getParameter("syncListings"); startSync = context.getRequest().getParameter("startSync"); if ("true".equals(startSync)) { isValid = true; if (syncStatus != null && syncStatus.size() == 0) { // Trigger the sync job triggerJob(context, "syncSystem", syncListings); } else { // Do nothing as a sync is already in progress. } } saveConnectionDetails = context.getRequest().getParameter("saveConnectionDetails"); if ("true".equals(saveConnectionDetails)) { ApplicationPrefs prefs = this.getApplicationPrefs(context); serverURL = context.getRequest().getParameter("serverURL"); apiClientId = context.getRequest().getParameter("apiClientId"); apiCode = context.getRequest().getParameter("apiCode"); String domainAndPort = ""; if (serverURL.indexOf("http://") != -1) { domainAndPort = serverURL.substring(7).split("/")[0]; } else if (serverURL.indexOf("https://") != -1) { domainAndPort = serverURL.substring(8).split("/")[0]; } String domain = domainAndPort; if (domainAndPort.indexOf(":") != -1) { domain = domainAndPort.split(":")[0]; } if (StringUtils.hasText(serverURL) && StringUtils.hasText(domain) && StringUtils.hasText(apiClientId) && StringUtils.hasText(apiCode)) { if (testConnection(serverURL, domain, apiCode, apiClientId)) { isValid = true; prefs.add("CONCURSIVE_CRM.SERVER", serverURL); prefs.add("CONCURSIVE_CRM.ID", domain); prefs.add("CONCURSIVE_CRM.CODE", apiCode); prefs.add("CONCURSIVE_CRM.CLIENT", apiClientId); prefs.save(); triggerJob(context, "syncSystem", syncListings); //Set the connect user performing the first sync to have crm admin role db = this.getConnection(context); User user = getUser(context); user.setConnectCRMAdmin(true); user.update(db); //Add a sync client and send that information over to the Mgmt CRM Server Key key = (Key) context.getServletContext().getAttribute(ApplicationPrefs.TEAM_KEY); SyncClient syncClient = new SyncClient(); syncClient.setType(prefs.get(ApplicationPrefs.PURPOSE)); syncClient.setCode(new String(Hex.encodeHex(key.getEncoded()))); syncClient.setEnabled(true); syncClient.setEnteredBy(user.getId()); syncClient.setModifiedBy(user.getId()); boolean recorded = syncClient.insert(db); if (recorded) { CRMConnection connection = new CRMConnection(); connection.setUrl(serverURL); connection.setId(domain); connection.setCode(apiCode); connection.setClientId(apiClientId); DataRecord record = new DataRecord(); record.setName(MAP); record.setAction(SAVE_CONNECT_SYNC_INFO_SERVICE); record.addField("connectURL", getServerUrl(context)); if (StringUtils.hasText(prefs.get(ApplicationPrefs.WEB_DOMAIN_NAME))) { record.addField("connectDomain", prefs.get(ApplicationPrefs.WEB_DOMAIN_NAME)); } else { record.addField("connectDomain", context.getRequest().getServerName()); } record.addField("connectSyncClientId", syncClient.getId()); record.addField("connectSyncClientCode", syncClient.getCode()); connection.save(record); if (!connection.hasError()) { LOG.debug( "Connect Sync connection information has been successfully transmitted..."); } else { LOG.debug("Connect Sync connection information transmission failed..."); } } } } } } catch (Exception e) { context.getRequest().setAttribute("Error", e); return ("SystemError"); } finally { this.freeConnection(context, db); } if (!isValid && "true".equals(saveConnectionDetails)) { context.getRequest().setAttribute("serverURL", context.getRequest().getParameter("serverURL")); context.getRequest().setAttribute("apiClientId", context.getRequest().getParameter("apiClientId")); context.getRequest().setAttribute("apiCode", context.getRequest().getParameter("apiCode")); context.getRequest().setAttribute("actionError", "Could not connect to the CRM"); return executeCommandDefault(context); } return "StartSyncOK"; }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDomino.java
public boolean filter() { boolean ret = true; // // LOGGER.info("Start filter "); DAVRepositoryDomino rep = (DAVRepositoryDomino) this.getRepository(); String filter = rep.getFilter(); if (filter.equals("")) { // LOGGER.info("Filter null"); return true; }// w w w.j av a2s .co m // LOGGER.info("Filter is "+filter); Document doc = getDocument(); if (doc == null) { // LOGGER.info("Get Document is null"); return ret; } try { DAVRepositoryMETA drm = WebDavManager.getManager(null).getRepositoryMeta(); if (drm == null) { return true; } Base repDoc = (Base) DominoProxy.resolve(drm.getRepositoryConfigLocation()); if (repDoc != null) { // LOGGER.info("Rep internal address not null; has class="+repDoc.getClass().toString()); Database db = null; if (repDoc instanceof Document) { // LOGGER.info("rep doc is a Document"); db = ((Document) repDoc).getParentDatabase(); } if (repDoc instanceof View) { // LOGGER.info("repdoc is a view"); View vw = ((View) repDoc); db = (Database) vw.getParent(); } if (db != null) { // LOGGER.info("Parent database not null"); Document docP = db.createDocument(); // LOGGER.info("Create document parameters..."); docP.replaceItemValue("Form", "webDavParameters"); docP.computeWithForm(true, false); // LOGGER.info("Compute with form OK!"); @SuppressWarnings("rawtypes") Vector items = docP.getItems(); for (int i = 0; i < items.size(); i++) { Item itm = (Item) items.get(i); // LOGGER.info("Item "+itm.getName()+"="+itm.getValueString()); filter = filter.replaceAll("\\x5B\\x5B" + itm.getName() + "\\x5D\\x5D", "\"" + itm.getValueString() + "\""); } if (!filter.equals("")) { // LOGGER.info("Filter="+filter); Session ses = DominoProxy.getUserSession(); @SuppressWarnings("rawtypes") Vector eval = ses.evaluate(filter, doc); if (eval == null) { return true; } String retS = eval.firstElement().toString().toLowerCase(); // LOGGER.info("Evaluate result="+retS); if (retS.equals("1.0")) { // LOGGER.info("Filter pass OK!"); return true; } else { // LOGGER.info("Filter didn't pass"); return false; } } } } } catch (NotesException ne) { LOGGER.error("Error on filter;" + ne.getMessage()); return ret; } return ret; }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java
@SuppressWarnings("unchecked") public void queryChanged(String newQuery) { lastExecution++;//from w w w .j a va 2 s.c o m int thisExecution = lastExecution; // Execute a thread to perform the query change... String error_msg = ""; lastExecution++; int in = lastExecution; if (getReportQueryDialog() == null) return; getReportQueryDialog().getJLabelStatusSQL().setText(I18n.getString("BeanInspectorPanel.Label.StatusSQL")); ///////////////////////////// try { Thread.currentThread().setContextClassLoader(IReportManager.getInstance().getReportClassLoader()); } catch (Exception ex) { ex.printStackTrace(); } if (in < lastExecution) return; //Abort, new execution requested HQLFieldsReader hqlFR = new HQLFieldsReader(newQuery, getReportQueryDialog().getDataset().getParametersList()); if (in < lastExecution) return; //Abort, new execution requested try { Vector fields = hqlFR.readFields(); List columns = new ArrayList(); for (int i = 0; i < fields.size(); ++i) { JRDesignField field = (JRDesignField) fields.elementAt(i); columns.add(new Object[] { field, field.getValueClassName(), field.getDescription() }); } Vector v = hqlFR.getNotScalars(); if (v.size() == 0) v = null; if (in < lastExecution) return; //Abort, new execution requested setBeanExplorerFromWorker(v, true, true); if (in < lastExecution) return; //Abort, new execution requested setColumnsFromWorker(columns); } catch (Exception ex) { ex.printStackTrace(); setBeanExplorerFromWorker(null, true, true); setColumnErrorFromWork(I18n.getString("BeanInspectorPanel.Message.Error3") + ex.getMessage()); } getReportQueryDialog().getJLabelStatusSQL() .setText(I18n.getString("BeanInspectorPanel.Message.StatusSQL2")); }