List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.TvT.java
public static boolean addPlayerOk(String teamName, L2PcInstance eventPlayer) { if (checkShufflePlayers(eventPlayer) || eventPlayer._inEventTvT) { eventPlayer.sendMessage("You already participated in the event!"); return false; }//from w w w . jav a 2 s . com if (eventPlayer._inEventFOS || eventPlayer._inEventCTF || eventPlayer._inEventDM) { eventPlayer.sendMessage("You already participated in another event!"); return false; } for (L2PcInstance player : _players) { if (player.getObjectId() == eventPlayer.getObjectId()) { eventPlayer.sendMessage("You already participated in the event!"); return false; } else if (player.getName() == eventPlayer.getName()) { eventPlayer.sendMessage("You already participated in the event!"); return false; } } if (_players.contains(eventPlayer)) { eventPlayer.sendMessage("You already participated in the event!"); return false; } if (CTF._savePlayers.contains(eventPlayer.getName())) { eventPlayer.sendMessage("You already participated in another event!"); return false; } if (Config.TVT_EVEN_TEAMS.equals("NO")) return true; else if (Config.TVT_EVEN_TEAMS.equals("BALANCE")) { boolean allTeamsEqual = true; int countBefore = -1; for (int playersCount : _teamPlayersCount) { if (countBefore == -1) countBefore = playersCount; if (countBefore != playersCount) { allTeamsEqual = false; break; } countBefore = playersCount; } if (allTeamsEqual) return true; countBefore = Integer.MAX_VALUE; for (int teamPlayerCount : _teamPlayersCount) { if (teamPlayerCount < countBefore) countBefore = teamPlayerCount; } Vector<String> joinableTeams = new Vector<String>(); for (String team : _teams) { if (teamPlayersCount(team) == countBefore) joinableTeams.add(team); } if (joinableTeams.contains(teamName)) return true; } else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE")) return true; eventPlayer.sendMessage("Too many players in team \"" + teamName + "\""); return false; }
From source file:org.parosproxy.paros.core.scanner.Kb.java
/** * Generic method for adding into a map// w w w . j a v a 2 s .c o m * @param map * @param key * @param value */ // ZAP: Added the type arguments. private void add(TreeMap<String, Object> map, String key, Object value) { // ZAP: Added the type argument. Vector<Object> v = getList(map, key); if (v == null) { // ZAP: Added the type argument. v = new Vector<>(); synchronized (map) { map.put(key, v); } } if (!v.contains(value)) { v.add(value); } }
From source file:charts.Chart.java
public static int FindPathwayPosition(Vector pathways, String pathway) { if (!pathways.contains(pathway)) { return (-1);//nao contem }// w w w .j a va 2 s.co m for (int p = 0; p < pathways.size(); p++) { if (((String) pathways.get(p)).equalsIgnoreCase(pathway)) { return (p); } } return (-1); }
From source file:org.kepler.gui.state.StateChangeMonitor.java
/** * This method is called by objects to register a listener for changes in * the application state. Any change in the state will trigger notification. * //from w w w . j a v a 2 s . c om * @param stateChange * the name of the state change for which notifications should be * sent * @param listener * a reference to the object to be notified of changes */ public void addStateChangeListener(String stateChange, StateChangeListener listener) { Vector currentStateListeners = null; if (!listeners.containsKey(stateChange)) { log.debug("Adding state vector: " + stateChange); currentStateListeners = new Vector(); listeners.put(stateChange, currentStateListeners); } else { currentStateListeners = (Vector) listeners.get(stateChange); } if (!currentStateListeners.contains(listener)) { log.debug("Adding listener: " + listener.toString()); currentStateListeners.addElement(listener); } }
From source file:org.apache.tomcat.util.IntrospectionUtils.java
/** * Add elements from the classpath <i>cp </i> to a Vector <i>jars </i> as * file URLs (We use Vector for JDK 1.1 compat). * <p>//from ww w.j av a 2s. c o m * * @param jars The jar list * @param cp a String classpath of directory or jar file elements * separated by path.separator delimiters. * @throws IOException If an I/O error occurs * @throws MalformedURLException Doh ;) */ public static void addJarsFromClassPath(Vector jars, String cp) throws IOException, MalformedURLException { String sep = System.getProperty("path.separator"); String token; StringTokenizer st; if (cp != null) { st = new StringTokenizer(cp, sep); while (st.hasMoreTokens()) { File f = new File(st.nextToken()); String path = f.getCanonicalPath(); if (f.isDirectory()) { path += "/"; } URL url = new URL("file", "", path); if (!jars.contains(url)) { jars.addElement(url); } } } }
From source file:org.sakaiproject.content.tool.AttachmentAction.java
/** * Update the attachments list based on which ids were selected at this browse level. *///from www . j a v a2s. c om static private void updateAttachments(SessionState state, Vector ids) { String id = (String) state.getAttribute(STATE_BROWSE_COLLECTION_ID); List attachments = (List) state.getAttribute(STATE_ATTACHMENTS); List members = null; try { // get the set of member ids ContentCollection collection = ContentHostingService.getCollection(id); members = collection.getMembers(); // for each member for (int i = 0; i < members.size(); i++) { String memberId = (String) members.get(i); String ref = ContentHostingService.getReference(memberId); // if the member id is in the list of ids selected if (ids.contains(memberId)) { // make sure it is in the attachments if (!attachments.contains(ref)) { attachments.add(EntityManager.newReference(ref)); } } else { // make sure its NOT in the attachments attachments.remove(ref); } } } catch (IdUnusedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (PermissionException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.escidoc.core.test.om.container.ContainerReferenceTest.java
/** * Check the references of an Container for the REST representation. * * @param containerXml The XML of the Container. * @throws Exception Thrown if retrieve or ID extracting failed. *//*w w w. j a v a2 s . c o m*/ private void checkRestReferences(final String containerXml) throws Exception { Document containerDoc = EscidocRestSoapTestBase.getDocument(containerXml); NodeList hrefs = selectNodeList(containerDoc, "//@href"); List<String> refList = nodeList2List(hrefs); // retrieve each single ref from framework // prevent duplicate href checking Vector<String> checkedRefs = new Vector<String>(); Iterator<String> refIt = refList.iterator(); while (refIt.hasNext()) { String ref = refIt.next(); if (!checkedRefs.contains(ref) && !skipRefCheck(ref)) { call(ref); checkedRefs.add(ref); } } }
From source file:de.escidoc.core.test.om.container.ContainerReferenceTest.java
/** * Check the references of an Container for the SOAP representation. * * @param containerXml The XML of the Container. * @throws Exception Thrown if retrieve or ID extracting failed. *//*from w ww . j av a 2 s .c om*/ private void checkSoapReferences(final String containerXml) throws Exception { Document containerDoc = EscidocRestSoapTestBase.getDocument(containerXml); NodeList objids = selectNodeList(containerDoc, "//*[@objid]"); List<String> refList = nodeListSOAP2List(objids); // retrieve each single ref from framework // prevent duplicate href checking Vector<String> checkedRefs = new Vector<String>(); Iterator<String> refIt = refList.iterator(); while (refIt.hasNext()) { String ref = refIt.next(); if (!checkedRefs.contains(ref) && !skipRefCheck(ref)) { call(ref); checkedRefs.add(ref); } } }
From source file:oscar.oscarMessenger.config.data.MsgMessengerGroupData.java
@SuppressWarnings("unchecked") public void printAllProvidersWithMembers(Locale locale, String grpNo, JspWriter out) { java.util.Vector<String> vector = membersInGroups(grpNo); ProviderDao dao = SpringUtils.getBean(ProviderDao.class); List<Provider> ps = dao.getProviders(); Collections.sort(ps, new BeanComparator("lastName")); try {//from www. java 2 s.c om for (Provider p : ps) { out.print(" <tr>"); out.print(" <td>"); if (vector.contains(p.getProviderNo())) { out.print("<input type=\"checkbox\" name=providers value=" + p.getProviderNo() + " checked >"); } else { out.print("<input type=\"checkbox\" name=providers value=" + p.getProviderNo() + ">"); } out.print(" </td>"); out.print(" <td>"); out.print(p.getLastName()); out.print(" </td>"); out.print(" <td>"); out.print(p.getFirstName()); out.print(" </td>"); out.print(" <td>"); String strProviderType = p.getProviderType(); out.print(strProviderType); out.print(" </td>"); out.print(" </tr>"); } } catch (Exception e) { MiscUtils.getLogger().error("Error", e); } }
From source file:org.kepler.sms.SemanticTypeManager.java
/** * Check if the given manager is equivalent to this manager. Two managers * are equal if they contain the same objects, and the objects have the same * types.// ww w . j a va2 s .com * * @param obj the object to test for equivalence * @return true if the given object is equivalent to this manager */ public boolean equals(Object obj) { if (!(obj instanceof SemanticTypeManager)) return false; SemanticTypeManager manager = (SemanticTypeManager) obj; Vector<Object> managerObjects = manager.getObjects(); if (getObjects().size() != managerObjects.size()) return false; Iterator<Object> objs = getObjects().iterator(); while (objs.hasNext()) { Object o = objs.next(); if (!managerObjects.contains(o)) return false; Vector<Object> managerTypes = manager.getTypes(o); if (getTypes(o).size() != managerTypes.size()) return false; Iterator<Object> types = getTypes(o).iterator(); while (types.hasNext()) if (!managerTypes.contains(types.next())) return false; } return true; }