List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:org.mahasen.util.PutUtil.java
/** * @return// w w w .j a va 2s. c o m */ private Vector<NodeHandle> getNodeHandlesToPut() { LeafSet leafSet = mahasenManager.getNode().getLeafSet(); Vector<NodeHandle> nodeHandles = new Vector<NodeHandle>(); for (int i = -leafSet.ccwSize(); i <= leafSet.cwSize(); i++) { if (!nodeHandles.contains(leafSet.get(i))) { nodeHandles.add(leafSet.get(i)); } } return nodeHandles; }
From source file:kenh.xscript.database.elements.Execute.java
/** * Use child elements <code>Param</code> to set parameter for <code>SQLBean</code>. * @param bean//from ww w.j a va 2s. c o m * @throws UnsupportedScriptException */ private Map<String, String> getParameters(SQLBean bean) throws UnsupportedScriptException { List<ParamBean> parameters = bean.getParameters(); Map<String, String> values = new LinkedHashMap(); Map<String, String> links = new LinkedHashMap(); for (ParamBean p : parameters) { String name = p.getName(); if (p.isLink()) { String linkName = p.getLinkName(); links.put(name, linkName); } else { String value = p.getValue(); values.put(name, value); } } this.invokeChildren(); Vector<Element> children = this.getChildren(); for (Element child : children) { if (child instanceof Param) { Param c = (Param) child; String name = c.getName(); if (!values.containsKey(name) && !links.containsKey(name)) throw new UnsupportedScriptException(this, "Unknown parameter. [" + name + "]"); values.remove(name); links.remove(name); if (c.isLink()) { String linkName = c.getLinkName(); links.put(name, linkName); } else { String value = c.getValue(); values.put(name, value); } } } Map<String, String> results = new LinkedHashMap(); for (ParamBean p : parameters) { String name = p.getName(); if (values.containsKey(name)) { String value = values.get(name); results.put(name, value); } else if (links.containsKey(name)) { String linkName = links.get(name); Vector<String> linkNames = new Vector(); linkNames.add(name); while (links.containsKey(linkName)) { if (linkNames.contains(linkName)) throw new UnsupportedScriptException(this, "Infinite Loop. [" + name + ", " + linkName + "]"); linkNames.add(linkName); linkName = links.get(linkName); } if (!values.containsKey(linkName)) throw new UnsupportedScriptException(this, "Could not find the parameter to link. [" + name + ", " + linkName + "]"); String value = values.get(linkName); results.put(name, value); } } return results; }
From source file:org.mahasen.util.SearchUtil.java
/** * @param vector1/*from w ww .ja va 2s .c om*/ * @param vector2 * @return * @throws MahasenException */ private Vector<Id> getCommonIds(Vector<Id> vector1, Vector<Id> vector2) throws MahasenException { Vector<Id> commonIds = new Vector<Id>(); for (Id id : vector1) { if (vector2 == null) { throw new MahasenException("No results found"); } if (vector2.contains(id)) { commonIds.add(id); } } return commonIds; }
From source file:es.pode.administracion.presentacion.adminusuarios.modificarGrupo.ModificarGruposControllerImpl.java
private RolVOCheck[] obtenerRolCheck(RolVO[] rolVO, GrupoVO grupoVO) { RolVOCheck[] resultado = null;//from ww w . j a v a2 s . co m resultado = new RolVOCheck[rolVO.length]; RolVO[] rolesGrupo = grupoVO.getRols(); Vector vRol = new Vector(); for (int j = 0; j < rolesGrupo.length; j++) { vRol.add(rolesGrupo[j].getId()); } for (int i = 0; i < rolVO.length; i++) { RolVOCheck rol = new RolVOCheck(); rol.setId(rolVO[i].getId()); rol.setDescripcion(rolVO[i].getDescripcion()); if (vRol.contains(rolVO[i].getId())) { rol.setChecked(Boolean.TRUE); } else { rol.setChecked(Boolean.FALSE); } resultado[i] = rol; } return resultado; }
From source file:org.lockss.devtools.TestRunKbartReport.java
/** * A class that reads the output file, summarises it and runs various tests. *//* w w w . j a va 2 s .co m*/ private void checkOutputFile(Reader r) { BufferedReader reader = new BufferedReader(r); int numberLines = 0; String outputHeader = null; try { outputHeader = reader.readLine(); numberLines = 1; String s; while ((s = reader.readLine()) != null) { // Get the header from the first line //if (numberLines==0) outputHeader = s; numberLines++; } } catch (IOException e) { e.printStackTrace(); } // Count empty and duplicate lines in the input int numEmptyLines = 0; int numDuplicateLines = 0; Vector<String> lineList = new Vector<String>(Arrays.asList(lines)); for (String line : lines) { if (StringUtils.isEmpty(line)) numEmptyLines++; else { // If not empty, check ifthe line is a duplicate lineList.remove(line); if (lineList.contains(line)) numDuplicateLines++; } } ; // Number of entries assertEquals(lines.length - numEmptyLines - numDuplicateLines, numberLines); // Setup the expected output header line Vector<String> labels = new Vector<String>(columnOrdering.getOrderedLabels()); if (hideEmptyColumns) { // The expected output header is the list of col names from input header, // plus any constant-valued cols specified in the Ordering. // Only keep the columns specified in the input, as the rest will be // empty. The list of input cols comes from splitting the original // header on commas and trimming each token. // Additionally, expect a missing column from the original inputs. labels.retainAll(new ArrayList<String>() { { // retain labels from the input header for (String s : Arrays.asList(StringUtils.split(header, ","))) { add(StringUtils.trim(s).toLowerCase()); } // retain non-field labels from the ordering for (String s : columnOrdering.getNonFieldColumnLabels()) { add(s); //add(s.indexOf(" ")>=0 ? String.format("\"%s\"", s) : s); } // Also add title_url as it is filled in automatically by the exporter add(KbartTitle.Field.TITLE_URL.getLabel()); } } //Arrays.asList(StringUtils.split(header.replace(" ", ""), ",")) ); labels.remove(emptyColumnLabel.toLowerCase()); } if (showTdbStatus) { // expect an extra column // TODO this is not implemented yet, we need to add the extra column label } String expectedHeader = StringUtils.join(labels, ","); // Header should be equivalent to the defined field ordering //assertEquals(expectedHeader.toLowerCase(), outputHeader.toLowerCase()); // NOTE the utf output includes a BOM, which screws up comparison // Also remove quotes added by CVS output rules (this is a quick kludge) outputHeader = outputHeader.replaceAll("\"", ""); System.out.format("Output %s\nExpected %s\n", outputHeader, expectedHeader); assertTrue(outputHeader.toLowerCase().endsWith(expectedHeader.toLowerCase())); // TODO record ordering should be alphabetical by title, or first column }
From source file:org.kepler.gui.SimpleLibrarySearcher.java
/** * Check to see if the supplied NamedObj matches any of the LIIDs in the * supplied list.// w w w . j a v a 2 s. c o m * * @param nobj * @param lsids */ private boolean checkLiid(ComponentEntity e, Vector<Integer> liids) { if (isDebugging) log.debug("checkLsid(" + e.getName() + " " + liids + ")"); int thisLiid = LibraryManager.getLiidFor(e); if (thisLiid != -1) { Integer iLiid = new Integer(thisLiid); if (isDebugging) log.debug(iLiid); if (liids.contains(iLiid)) { if (isDebugging) log.debug("MATCH"); addStackTopToResult(); return true; } } return false; }
From source file:picocash.Picocash.java
@Action public void manageCategories() { Vector<Category> categories = new Vector<Category>(Services.getSelectedPersistenceMan().getAllCategories()); ManageCategoriesDialog dialog = new ManageCategoriesDialog(this.getMainFrame(), categories, true); dialog.setVisible(true);/* ww w. jav a2 s. c o m*/ if (dialog.getStatus() == DialogReturnStatus.OK) { log.trace("ManageCategoriessDialog [OK]"); log.trace("getting categories from Dialog"); Vector<Category> oldCategories = new Vector<Category>( Services.getSelectedPersistenceMan().getAllCategories()); if (log.isTraceEnabled()) { log.trace("old categories [" + oldCategories + "]"); } Vector<Category> newCategories = dialog.getCategories(); //delete oldCategories for (Category category : oldCategories) { if (!newCategories.contains(category)) { List<Transaction> transactions = Services.getSelectedPersistenceMan() .getAllTransactionsForCategory(category); for (Transaction transaction : transactions) { transaction.setCategory(null); } Services.getSelectedPersistenceMan().delete(category); setChangesAvailable(true); if (log.isTraceEnabled()) { log.trace("old category [" + category.getName() + "] deleted"); } } } for (Category category : newCategories) { Services.getSelectedPersistenceMan().persist(category); setChangesAvailable(true); } if (log.isTraceEnabled()) { log.trace("new categories [" + newCategories + "]"); } } else if (dialog.getStatus() == DialogReturnStatus.CANCEL) { log.trace("ManageCategoriessDialog [CANCEL]"); } else { throw new IllegalStateException("ManageCategoriessDialog not closed with ReturnStatus"); } }
From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java
/** * Initialize graphical components with values. *///from w w w .j ava 2s . c o m private void init() { String objectType = this.objetSchema.getType(); SchemaSyntax syntax = objetSchema.getSyntax(); String[] params_name = syntax.getParameters(objectType); if (params_name == null || params_name.length == 0) { return; } this.labels = new Hashtable<String, JComponent>(); this.values = new Hashtable<String, JComponent>(); this.valuesPresent = new Hashtable<String, JCheckBox>(); Vector<String> parametresEffectues = new Vector<String>(); for (int i = 0; i < params_name.length; i++) { if (parametresEffectues.contains(params_name[i])) { continue; } JComponent label = null; JComponent composant = null; JCheckBox checkbox = new JCheckBox(); String[] param_values; String[] param_others = syntax.getOthersParametersFor(objectType, params_name[i]); // If SUP parameters, add corresponding object names. if (params_name[i].compareTo("SUP") == 0) { SchemaObject[] objects = this.schema.getObjectsInOrder(objectType); param_values = new String[objects.length]; for (int j = 0; j < objects.length; j++) { param_values[j] = objects[j].getNameFirstValue(); } } // Else, read the syntax to find needed values. else { param_values = syntax.getParameterDefaultValues(objectType, params_name[i]); } // Plusieurs clefs. // C'est une liste de clefs possibles. if (param_others != null && param_others.length > 1) { label = new JComboBox(param_others); composant = new JLabel(); boolean ok = false; for (int j = 0; j < param_others.length && !ok; j++) { if (objetSchema.isKeyExists(param_others[j])) { ok = true; ((JComboBox) label).setSelectedItem(param_others[j]); checkbox.setSelected(true); } } for (int j = 0; j < param_others.length; j++) { parametresEffectues.add(param_others[j]); } } // Aucune valeur possible // La prsence du paramtre suffit => JCheckBox. else if (param_values.length == 0) { label = new JLabel(params_name[i]); composant = new JLabel(""); parametresEffectues.add(params_name[i]); checkbox.setSelected(objetSchema.isKeyExists(params_name[i])); } // Une valeur, on regarde si c'est une valeur prcise. // - Si c'est une chane qui peut tre quelconque => JTextField. // - Si la valeur est en fait un objet => JTextField + Objet. else if (param_values.length == 1 && param_values[0] != null) { String tmp = objetSchema.isKeyExists(params_name[i]) ? objetSchema.getValue(params_name[i]).toString() : param_values[0]; label = new JLabel(params_name[i]); composant = new JTextField(tmp, 30); parametresEffectues.add(params_name[i]); checkbox.setSelected(objetSchema.isKeyExists(params_name[i])); } // Plusieurs valeurs. // C'est une liste de choix possibles => JComboBox. else if (param_values.length > 1) { String tmp = objetSchema.isKeyExists(params_name[i]) ? objetSchema.getValue(params_name[i]).toString() : param_values[0]; if (!ArrayUtils.contains(param_values, tmp)) { Vector<String> list = new Vector<String>(); for (String param_value : param_values) { list.add(param_value); } list.add(0, tmp); param_values = list.toArray(new String[0]); } label = new JLabel(params_name[i]); composant = new JComboBox(param_values); ((JComboBox) composant).setEditable(true); ((JComboBox) composant).setSelectedItem(tmp); parametresEffectues.add(params_name[i]); checkbox.setSelected(objetSchema.isKeyExists(params_name[i])); } // Set elements into the frame. if (composant != null && label != null) { this.labels.put(params_name[i], label); this.values.put(params_name[i], composant); this.valuesPresent.put(params_name[i], checkbox); SchemaValue v = syntax.createSchemaValue(objectType, params_name[i], null); if (v.isValues() && !(composant instanceof JComboBox)) { composant.setEnabled(false); } } } // end for }
From source file:com.alfaariss.oa.engine.user.provisioning.translator.standard.StandardProfile.java
private Vector<String> getAllFields() throws UserException { Vector<String> vReturn = new Vector<String>(); try {//from w w w.ja v a2 s . co m String sField = _itemEnabled.getField(); if (sField != null) vReturn.add(sField); Enumeration enumAuthSPs = _htProfile.elements(); while (enumAuthSPs.hasMoreElements()) { ProfileItem itemRegistered = (ProfileItem) enumAuthSPs.nextElement(); String sRegisteredField = itemRegistered.getField(); if (sRegisteredField != null && !vReturn.contains(sRegisteredField)) vReturn.add(sRegisteredField); } } catch (Exception e) { _logger.fatal("Could not retrieve all configured fields", e); throw new UserException(SystemErrors.ERROR_INTERNAL); } return vReturn; }
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; }/*from w w w . j a v a2s. c om*/ 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)); }