List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:skoa.helpers.Graficos.java
/********************************************************************************************************* * FUNCIONES PARA CREAR LOS GRFICOS DE LA CONSULTA C! MANIPULANDO LOS DATOS OBTENIDOS DE LAS CONSULTAS.* *********************************************************************************************************/ private void maxMinMed() { //En este tipo de consultas, sacamos la DG del fichero original de datos, para ponerla en la graf. String dg = nombresFicheros.get(0); //dg=dg.substring(dg.indexOf("-")+7,dg.indexOf(".txt")); //Saca la DG del nombre del fich. if (dg.indexOf("D") > 0 && dg.indexOf(" ") < 0) { //Si es el resultado final de una consulta D. dg = dg.substring(dg.indexOf(".txt") - 13, dg.indexOf(".txt")); //Saca la DG del nombre del fich. } else { //Si son resultados de una consulta D. //As, buscando a partir de .txt da igual el tipo de consulta que sea, que se saca igual. dg = dg.substring(dg.indexOf(" ") - 6, dg.indexOf(".txt")); //Saca la DG del nombre del fich. }/*from www . j a va2 s . c o m*/ //--------------------------------------------- crearEstadisticas(); //Crea el fichero estadisticas.txt donde se encuentra el FECHA MAX MIN y MED en este orden Vector<String> vectorOrdenUnidades = new Vector<String>(); vectorOrdenUnidades.add(unidad); nombresDGs.add("Max"); //Reusamos esta variable. Nos referimos al nombre de cada una de las barras que se ven. nombresDGs.add("Min"); nombresDGs.add("Med"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset = obtenerSerieBarras2(vectorOrdenUnidades); String unidad = ""; for (int i = 0; i < vectorOrdenUnidades.size(); i++) unidad = unidad + vectorOrdenUnidades.elementAt(i) + ", "; unidad = unidad.substring(0, unidad.length() - 2); //Quita el ultimo espacio y la ultima coma. if (unidad.indexOf("C") >= 0) unidad = "C"; dg = dg.replaceAll("-", "/"); JFreeChart grafica = ChartFactory.createBarChart("Valores medidos de las direcciones de grupo", "Fechas", //titulo eje x "Mediciones (" + unidad + ") de " + dg, dataset, PlotOrientation.VERTICAL, true, //leyenda true, false); if (fechaInicial.equals("") & fechaFinal.equals("")) { //Si estn vacas es porque no hay resultados para ese intervalo. fechaInicial = " ? "; fechaFinal = " ? "; } TextTitle t = new TextTitle("desde " + fechaInicial + " hasta " + fechaFinal, new Font("SanSerif", Font.ITALIC, 12)); grafica.addSubtitle(t); CategoryPlot plot = grafica.getCategoryPlot(); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); domainAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 9)); //Letra de las fechas ms pequea //Esconder las sombras de las barras del barchart. CategoryPlot categoryPlot = (CategoryPlot) grafica.getPlot(); BarRenderer renderer = new BarRenderer(); renderer.setShadowVisible(false); categoryPlot.setRenderer(renderer); //------------------------------------------------- try { ChartUtilities.saveChartAsJPEG(new File(ruta + "MaxMinMedSmall.jpg"), grafica, 400, 300); ChartUtilities.saveChartAsJPEG(new File(ruta + "MaxMinMedBig.jpg"), grafica, 900, 600); } catch (IOException e) { System.err.println("Problem occurred creating chart." + e); } }
From source file:gov.nih.nci.evs.browser.utils.MetaTreeUtils.java
public BySourceTabResults findHighestRankedAtom(Vector<BySourceTabResults> v, String source) { if (v == null) return null; if (v.size() == 0) return null; if (v.size() == 1) { return (BySourceTabResults) v.elementAt(0); }/*from w w w.j ava2 s. c o m*/ if (_termGroupRankHashMap == null) { return (BySourceTabResults) v.elementAt(0); } BySourceTabResults target = null; for (int i = 0; i < v.size(); i++) { BySourceTabResults r = (BySourceTabResults) v.elementAt(i); if (source != null) { if (r.getSource().compareTo(source) == 0) { if (target == null) { target = r; } else { // select the higher ranked one as target String idx_target = getRank(target.getType(), target.getSource()); String idx_atom = getRank(r.getType(), r.getSource()); if (idx_atom != null && idx_atom.compareTo(idx_target) > 0) { target = r; } } } } else { return r; } } return target; }
From source file:com.netscape.cms.logging.LogFile.java
/** * Retrieve last "maxLine" number of system log with log lever >"level" * and from source "source". If the parameter is omitted. All entries * are sent back.//from w w w. j av a 2 s. co m */ public synchronized NameValuePairs retrieveLogContent(Hashtable<String, String> req) throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); String tmp, fName = null; int maxLine = -1, level = -1; LogSource source = null; Vector<LogEntry> entries = null; if ((tmp = req.get(Constants.PR_LOG_ENTRY)) != null) { maxLine = Integer.parseInt(tmp); } if ((tmp = req.get(Constants.PR_LOG_LEVEL)) != null) { level = Integer.parseInt(tmp); } if ((tmp = req.get(Constants.PR_LOG_SOURCE)) != null) { source = LogSource.valueOf(Integer.parseInt(tmp)); } tmp = req.get(Constants.PR_LOG_NAME); if (!(tmp.equals(Constants.PR_CURRENT_LOG))) { fName = tmp; } else { flush(); } try { entries = readEntry(maxLine, level, source, fName); for (int i = 0; i < entries.size(); i++) { params.put(Integer.toString(i) + entries.elementAt(i).getEntry(), ""); } } catch (Exception e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, ILogger.LL_WARN, "System log parse error"); } return params; }
From source file:gov.nih.nci.evs.browser.utils.MappingSearchUtils.java
public ResolvedConceptReferencesIteratorWrapper searchByRelationships(Vector schemes, Vector versions, String matchText, String matchAlgorithm, int maxToReturn) { if (matchText == null || matchText.trim().length() == 0) return null; matchText = matchText.trim();/*from w w w. j av a 2 s. c o m*/ _logger.debug("searchByName ... " + matchText); if (matchAlgorithm.compareToIgnoreCase("contains") == 0) { matchAlgorithm = new SearchUtils().findBestContainsAlgorithm(matchText); } SearchDesignationOption option = SearchDesignationOption.ALL; String language = null; //CodedNodeSet.PropertyType[] propertyTypes = null; LocalNameList propertyNames = null; LocalNameList sourceList = null; //propertyTypes = getAllNonPresentationPropertyTypes(); LocalNameList contextList = null; NameAndValueList qualifierList = null; LexBIGService lbSvc = RemoteServerUtil.createLexBIGService(); MappingExtension mappingExtension = null; try { mappingExtension = (MappingExtension) lbSvc.getGenericExtension("MappingExtension"); } catch (Exception ex) { ex.printStackTrace(); return null; } ResolvedConceptReferencesIterator itr = null; int lcv = 0; String scheme = null; String version = null; int numberRemaining = -1; while (itr == null && numberRemaining == -1 && lcv < schemes.size()) { scheme = (String) schemes.elementAt(lcv); version = (String) versions.elementAt(lcv); String containerName = getMappingRelationsContainerName(scheme, version); if (containerName != null) { LocalNameList relationshipList = getSupportedAssociationNames(lbSvc, scheme, version, containerName); try { CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag(); if (version != null) { versionOrTag.setVersion(version); } Mapping mapping = mappingExtension.getMapping(scheme, versionOrTag, containerName); if (mapping != null) { mapping = mapping.restrictToRelationship(matchText, option, matchAlgorithm, language, relationshipList); //Finally, resolve the Mapping. itr = mapping.resolveMapping(); try { numberRemaining = itr.numberRemaining(); //System.out.println("Number of matches: " + numberRemaining); } catch (Exception ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); //return null; } } lcv++; } if (itr != null) { ResolvedConceptReferencesIteratorWrapper wrapper = new ResolvedConceptReferencesIteratorWrapper(itr); wrapper.setCodingSchemeName(scheme); wrapper.setCodingSchemeVersion(version); return wrapper; } return null; }
From source file:org.adl.samplerte.server.CourseService.java
/** * Edits the objectives based on the parameters being passed in * @param iParams - List of parameters//from w w w .j a v a2 s. c om * @return String representation of the success of this operation (true or false) */ public String editObjs(Vector iParams) { String result = "true"; Vector requestNames = iParams; try { Connection conn; conn = LMSDBHandler.getConnection(); PreparedStatement stmtUpdateObjective; PreparedStatement stmtDeleteObjective; String sqlUpdateObjective = "UPDATE Objectives SET satisfied = 'unknown', measure = 'unknown' " + ", rawscore = 'unknown', minscore = 'unknown', maxscore = 'unknown', progressmeasure = 'unknown'" + ",completion = 'unknown' WHERE objID = ? AND learnerID = ?"; String sqlDeleteObjective = "DELETE FROM Objectives WHERE objID = ? AND learnerID = ?"; stmtUpdateObjective = conn.prepareStatement(sqlUpdateObjective); stmtDeleteObjective = conn.prepareStatement(sqlDeleteObjective); // loop through all of the parameters. for (int i = 0; i < requestNames.size(); i++) { String param = (String) requestNames.elementAt(i); // We must remove the number~ prefix added in the html to protect case param = param.substring(param.indexOf("~") + 1, param.length()); String paramName; String paramValue; int splitIndex; splitIndex = param.lastIndexOf(":"); paramName = param.substring(0, splitIndex); paramValue = param.substring(splitIndex + 1, param.length()); String objID; String learnerID; // If the parameter is not the submit button if (!(paramName.equals("submit"))) { splitIndex = paramName.lastIndexOf(";"); objID = decodeHandler.encodeObjectiveID(paramName.substring(0, splitIndex)); learnerID = paramName.substring(splitIndex + 1, paramName.length()); if (paramValue.equals("reset")) { synchronized (stmtUpdateObjective) { stmtUpdateObjective.setString(1, objID); stmtUpdateObjective.setString(2, learnerID); stmtUpdateObjective.executeUpdate(); } } else if (paramValue.equals("delete")) { synchronized (stmtDeleteObjective) { stmtDeleteObjective.setString(1, objID); stmtDeleteObjective.setString(2, learnerID); stmtDeleteObjective.executeUpdate(); } } } } stmtUpdateObjective.close(); stmtDeleteObjective.close(); LMSDBHandler.closeConnection(); } catch (Exception e) { result = "false"; System.out.println(e); } return result; }
From source file:gov.nih.nci.evs.browser.utils.MetaTreeUtils.java
public HashMap getRemainingSubconcepts(String scheme, String version, String code, String sab, String subconcept_code) { CodingSchemeVersionOrTag csvt = new CodingSchemeVersionOrTag(); if (version != null) csvt.setVersion(version);/* ww w .j av a 2 s .co m*/ String name = null; try { name = getCodeDescription(scheme, csvt, code); } catch (Exception ex) { } TreeItem ti = new TreeItem(code, name); ti._expandable = false; //HashSet hset = new HashSet(); HashMap hmap = new HashMap(); Vector w = new Vector(); //long ms = System.currentTimeMillis(); //Set<String> codesToExclude = Collections.EMPTY_SET; List<String> par_chd_assoc_list = new ArrayList(); par_chd_assoc_list.add("CHD"); Map<String, List<BySourceTabResults>> map = null; MetaBrowserService mbs = null; try { mbs = (MetaBrowserService) lbSvc.getGenericExtension("metabrowser-extension"); map = mbs.getBySourceTabDisplay(ti._code, sab, par_chd_assoc_list, Direction.SOURCEOF); } catch (Exception ex) { ex.printStackTrace(); hmap.put(code, ti); return hmap; } HashMap cui2SynonymsMap = createCUI2SynonymsHahMap(map); ti._expandable = false; Iterator iterator = cui2SynonymsMap.entrySet().iterator(); while (iterator.hasNext()) { Entry thisEntry = (Entry) iterator.next(); String child_cui = (String) thisEntry.getKey(); TreeItem sub = null; //Vector v = (Vector) cui2SynonymsMap.get(child_cui); Vector v = (Vector) thisEntry.getValue(); BySourceTabResults result = findHighestRankedAtom(v, sab); if (result == null) { result = (BySourceTabResults) v.elementAt(0); } sub = new TreeItem(child_cui, result.getTerm()); sub._expandable = hasSubconcepts(lbSvc, mbs, child_cui, "NCI", "CHD", true); w.add(sub); } /* * // testing par_chd_assoc_list = new ArrayList(); * par_chd_assoc_list.add("CHD"); try { mbs = * (MetaBrowserService)lbSvc.getGenericExtension * ("metabrowser-extension"); map = mbs.getBySourceTabDisplay(ti.code, * sab, par_chd_assoc_list, Direction.TARGETOF); * * } catch (Exception ex) { ex.printStackTrace(); hmap.put(code, ti); * return hmap; } * * cui2SynonymsMap = createCUI2SynonymsHahMap(map); //ti.expandable = * false; keyset = cui2SynonymsMap.keySet(); iterator = * keyset.iterator(); while (iterator.hasNext()) { String child_cui = * (String) iterator.next(); TreeItem sub = null; Vector v = (Vector) * cui2SynonymsMap.get(child_cui); BySourceTabResults result = * findHighestRankedAtom(v, sab); if (result == null) { result * = (BySourceTabResults) v.elementAt(0); } sub = new * TreeItem(child_cui, result.getTerm()); sub.expandable = * hasSubconcepts(lbSvc, mbs, child_cui, "NCI", "CHD", true); * w.add(sub); } */ w = SortUtils.quickSort(w); boolean include = false; int istart = 0; if (subconcept_code != null) { for (int i = 0; i < w.size(); i++) { TreeItem sub = (TreeItem) w.elementAt(i); if (sub._code.compareTo(subconcept_code) == 0) { istart = i; break; } } } for (int i = 0; i < w.size(); i++) { TreeItem sub = (TreeItem) w.elementAt(i); if (subconcept_code == null) { include = true; } else { if (i >= istart) include = true; } ti._expandable = true; if (include) { ti.addChild("CHD", sub); } } hmap.put(code, ti); return hmap; }
From source file:corelyzer.ui.CorelyzerApp.java
public void createPluginMenuItems(final Vector pluginNames) { JMenuItem pluginMenuItem;/* w w w.j a va 2 s . co m*/ for (int k = 0; k < pluginNames.size(); k++) { pluginMenuItem = new JMenuItem((String) pluginNames.elementAt(k)); pluginMenuItem.addActionListener(controller); pluginMenu.add(pluginMenuItem); pluginMenuItemVec.add(pluginMenuItem); if (k == getPluginUIIndex()) { pluginMenuItem.setEnabled(false); } } }
From source file:gov.nih.nci.evs.browser.utils.MappingSearchUtils.java
public ResolvedConceptReferencesIteratorWrapper searchByProperties(Vector schemes, Vector versions, String matchText, String matchAlgorithm, int maxToReturn) { if (matchText == null || matchText.trim().length() == 0) return null; matchText = matchText.trim();/*from w ww . j a v a 2 s .c o m*/ _logger.debug("searchByName ... " + matchText); if (matchAlgorithm.compareToIgnoreCase("contains") == 0) { matchAlgorithm = new SearchUtils().findBestContainsAlgorithm(matchText); } CodedNodeSet.PropertyType[] propertyTypes = null; LocalNameList propertyNames = null; LocalNameList sourceList = null; propertyTypes = getAllNonPresentationPropertyTypes(); LocalNameList contextList = null; NameAndValueList qualifierList = null; String language = null; // to be modified //SearchContext searchContext = SearchContext.SOURCE_OR_TARGET_CODES ; LexBIGService lbSvc = RemoteServerUtil.createLexBIGService(); MappingExtension mappingExtension = null; try { mappingExtension = (MappingExtension) lbSvc.getGenericExtension("MappingExtension"); } catch (Exception ex) { ex.printStackTrace(); return null; } ResolvedConceptReferencesIterator itr = null; int lcv = 0; String scheme = null; String version = null; int numberRemaining = -1; while (itr == null && numberRemaining == -1 && lcv < schemes.size()) { scheme = (String) schemes.elementAt(lcv); version = (String) versions.elementAt(lcv); String containerName = getMappingRelationsContainerName(scheme, version); if (containerName != null) { try { CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag(); if (version != null) { versionOrTag.setVersion(version); } Mapping mapping = mappingExtension.getMapping(scheme, versionOrTag, containerName); if (mapping != null) { mapping = mapping.restrictToMatchingProperties(propertyNames, propertyTypes, sourceList, contextList, qualifierList, matchText, matchAlgorithm, null, SearchContext.SOURCE_OR_TARGET_CODES); //Finally, resolve the Mapping. itr = mapping.resolveMapping(); try { numberRemaining = itr.numberRemaining(); //System.out.println("Number of matches: " + numberRemaining); } catch (Exception ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); //return null; } } lcv++; } if (itr != null) { ResolvedConceptReferencesIteratorWrapper wrapper = new ResolvedConceptReferencesIteratorWrapper(itr); wrapper.setCodingSchemeName(scheme); wrapper.setCodingSchemeVersion(version); return wrapper; } return null; }
From source file:gov.nih.nci.cagrid.gts.service.ProxyPathValidator.java
public void validate(X509Certificate[] certPath, X509Certificate[] trustedCerts, CertificateRevocationLists crls) throws ProxyPathValidatorException { if (certPath == null) { throw new IllegalArgumentException("certs == null"); }/*from ww w. ja va 2s . c om*/ TrustedCertificates trustedCertificates = null; if (trustedCerts != null) { trustedCertificates = new TrustedCertificates(trustedCerts); } Vector validatedChain = null; CertVerifyPolicyInt policy = PureTLSUtil.getDefaultCertVerifyPolicy(); try { Vector userCerts = PureTLSUtil.certificateChainToVector(certPath); CertContext context = new CertContext(); if (trustedCerts != null) { for (int i = 0; i < trustedCerts.length; i++) { context.addRoot(trustedCerts[i].getEncoded()); } } validatedChain = X509Cert.verifyCertChain(context, userCerts, policy); } catch (COM.claymoresystems.cert.CertificateException e) { throw new ProxyPathValidatorException(ProxyPathValidatorException.FAILURE, e); } catch (GeneralSecurityException e) { throw new ProxyPathValidatorException(ProxyPathValidatorException.FAILURE, e); } if (validatedChain == null || validatedChain.size() < certPath.length) { throw new ProxyPathValidatorException(ProxyPathValidatorException.UNKNOWN_CA, null, "Unknown CA"); } /** * The chain returned by PureTSL code contains the CA certificates we * need to insert those certificates into the new certPath if the sizes * are different */ int size = validatedChain.size(); if (size != certPath.length) { X509Certificate[] newCertPath = new X509Certificate[size]; System.arraycopy(certPath, 0, newCertPath, 0, certPath.length); X509Cert cert; ByteArrayInputStream in; try { for (int i = 0; i < size - certPath.length; i++) { cert = (X509Cert) validatedChain.elementAt(i); in = new ByteArrayInputStream(cert.getDER()); newCertPath[i + certPath.length] = CertUtil.loadCertificate(in); } } catch (GeneralSecurityException e) { throw new ProxyPathValidatorException(ProxyPathValidatorException.FAILURE, e); } certPath = newCertPath; } validate(certPath, trustedCertificates, crls); }
From source file:SWTFileViewerDemo.java
/** * Notifies the application components that a new current directory has been * selected/*from www.j a v a2 s .com*/ * * @param dir * the directory that was selected, null is ignored */ void notifySelectedDirectory(File dir) { if (dir == null) return; if (currentDirectory != null && dir.equals(currentDirectory)) return; currentDirectory = dir; notifySelectedFiles(null); /* * Shell: Sets the title to indicate the selected directory */ shell.setText(getResourceString("Title", new Object[] { currentDirectory.getPath() })); /* * Table view: Displays the contents of the selected directory. */ workerUpdate(dir, false); /* * Combo view: Sets the combo box to point to the selected directory. */ final File[] comboRoots = (File[]) combo.getData(COMBODATA_ROOTS); int comboEntry = -1; if (comboRoots != null) { for (int i = 0; i < comboRoots.length; ++i) { if (dir.equals(comboRoots[i])) { comboEntry = i; break; } } } if (comboEntry == -1) combo.setText(dir.getPath()); else combo.select(comboEntry); /* * Tree view: If not already expanded, recursively expands the parents * of the specified directory until it is visible. */ Vector /* of File */ path = new Vector(); // Build a stack of paths from the root of the tree while (dir != null) { path.add(dir); dir = dir.getParentFile(); } // Recursively expand the tree to get to the specified directory TreeItem[] items = tree.getItems(); TreeItem lastItem = null; for (int i = path.size() - 1; i >= 0; --i) { final File pathElement = (File) path.elementAt(i); // Search for a particular File in the array of tree items // No guarantee that the items are sorted in any recognizable // fashion, so we'll // just sequential scan. There shouldn't be more than a few thousand // entries. TreeItem item = null; for (int k = 0; k < items.length; ++k) { item = items[k]; if (item.isDisposed()) continue; final File itemFile = (File) item.getData(TREEITEMDATA_FILE); if (itemFile != null && itemFile.equals(pathElement)) break; } if (item == null) break; lastItem = item; if (i != 0 && !item.getExpanded()) { treeExpandItem(item); item.setExpanded(true); } items = item.getItems(); } tree.setSelection((lastItem != null) ? new TreeItem[] { lastItem } : new TreeItem[0]); }