Example usage for java.util Vector contains

List of usage examples for java.util Vector contains

Introduction

In this page you can find the example usage for java.util Vector contains.

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this vector contains the specified element.

Usage

From source file:gate.DocumentFormat.java

public synchronized void addStatusListener(StatusListener l) {
    @SuppressWarnings("unchecked")
    Vector<StatusListener> v = statusListeners == null ? new Vector<StatusListener>(2)
            : (Vector<StatusListener>) statusListeners.clone();
    if (!v.contains(l)) {
        v.addElement(l);/*from w w  w .  j  av a2s.  com*/
        statusListeners = v;
    }
}

From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.FortressSiege.java

public static boolean addPlayerOk(String teamName, L2PcInstance eventPlayer) {
    if (teamName == null || eventPlayer == null)
        return false;
    if (checkShufflePlayers(eventPlayer) || eventPlayer._inEventFOS) {
        eventPlayer.sendMessage("You already participated in this event!");
        return false;
    }/*from  w w  w  .  j av  a  2 s. c  o m*/
    if (eventPlayer._inEventTvT || eventPlayer._inEventCTF || eventPlayer._inEventDM) {
        eventPlayer.sendMessage("You already participated in another event!");
        return false;
    }
    for (L2PcInstance player : _players) {
        if (player.getObjectId() == eventPlayer.getObjectId()
                || player.getName().equals(eventPlayer.getName())) {
            eventPlayer.sendMessage("You already participated in this event!");
            return false;
        }
    }
    if (_players.contains(eventPlayer)) {
        eventPlayer.sendMessage("You already participated in this event!");
        return false;
    }
    if (TvT._savePlayers.contains(eventPlayer.getName()) || CTF._savePlayers.contains(eventPlayer.getName())) {
        eventPlayer.sendMessage("You already participated in another event!");
        return false;
    }
    if (Config.FortressSiege_EVEN_TEAMS.equals("NO"))
        return true;
    else if (Config.FortressSiege_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.FortressSiege_EVEN_TEAMS.equals("SHUFFLE"))
        return true;
    eventPlayer.sendMessage("Too many players in team \"" + teamName + "\"");
    return false;
}

From source file:org.kuali.rice.krad.service.impl.PersistenceStructureServiceOjbImpl.java

/**
 * @see org.kuali.rice.krad.service.PersistenceService#getRelationshipMetadata(java.lang.Class,
 *      java.lang.String)/*from w w w.  ja  v  a 2  s.c o m*/
 */

@Override
public Map<String, DataObjectRelationship> getRelationshipMetadata(Class persistableClass, String attributeName,
        String attributePrefix) {
    if (persistableClass == null) {
        throw new IllegalArgumentException("invalid (null) persistableClass");
    }
    if (StringUtils.isBlank(attributeName)) {
        throw new IllegalArgumentException("invalid (blank) attributeName");
    }

    Map<String, DataObjectRelationship> relationships = new HashMap<String, DataObjectRelationship>();
    ClassDescriptor classDescriptor = getClassDescriptor(persistableClass);
    Vector<ObjectReferenceDescriptor> references = classDescriptor.getObjectReferenceDescriptors();
    for (ObjectReferenceDescriptor objRef : references) {
        Vector fks = objRef.getForeignKeyFields();
        if (fks.contains(attributeName) || objRef.getAttributeName().equals(attributeName)) {
            Map<String, String> fkToPkRefs = getForeignKeysForReference(persistableClass,
                    objRef.getAttributeName());
            DataObjectRelationship rel = new DataObjectRelationship(persistableClass, objRef.getAttributeName(),
                    objRef.getItemClass());
            for (Map.Entry<String, String> ref : fkToPkRefs.entrySet()) {
                if (StringUtils.isBlank(attributePrefix)) {
                    rel.getParentToChildReferences().put(ref.getKey(), ref.getValue());
                } else {
                    rel.getParentToChildReferences().put(attributePrefix + "." + ref.getKey(), ref.getValue());
                }
            }
            relationships.put(objRef.getAttributeName(), rel);
        }
    }
    return relationships;
}

From source file:org.openmrs.module.conceptsearch.db.hibernate.HibernateConceptSearchDAO.java

/**
 * Returns a list of concept names, maximum 30 elements
 * //from w w w .  java  2 s. c  o  m
 * @see org.openmrs.module.conceptsearch.ConceptSearchDAO#getAutocompleteConcepts(java.lang.String)
 */
@SuppressWarnings("unchecked")
@Override
public List<String> getAutocompleteConcepts(String searchWord) throws DAOException {
    Criteria crit = sessionFactory.getCurrentSession().createCriteria(Concept.class);
    Vector<String> prev = new Vector<String>();

    crit.createAlias("names", "names");
    //crit.add(Restrictions.like("names.name", "%" + searchWord + "%"));

    crit.add(Restrictions.ilike("names.name", searchWord, MatchMode.ANYWHERE));
    crit.add(Restrictions.eq("retired", false));
    crit.setMaxResults(30);

    for (Concept c : (List<Concept>) crit.list()) {
        Collection<ConceptName> conceptNames = c.getNames();
        for (ConceptName cn : conceptNames) {
            if (isSearchTermBeginningOfWord(cn.getName(), searchWord) && !prev.contains(cn.getName())) {
                prev.add(cn.getName());
            }
        }
    }

    return prev;
}

From source file:at.gv.egiz.pdfas.lib.settings.Settings.java

public Vector<String> getFirstLevelKeys(String prefix) {
    String mPrefix = prefix.endsWith(".") ? prefix : prefix + ".";
    Iterator<Object> keyIterator = properties.keySet().iterator();
    Vector<String> valueMap = new Vector<String>();
    while (keyIterator.hasNext()) {
        String key = keyIterator.next().toString();

        if (key.startsWith(prefix)) {
            int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key.indexOf('.', mPrefix.length())
                    : key.length();//from   w ww . j a  va2 s  .  c  om
            String firstLevels = key.substring(0, keyIdx);
            if (!valueMap.contains(firstLevels)) {
                valueMap.add(firstLevels);
            }
        }
    }

    if (valueMap.isEmpty()) {
        return null;
    }

    return valueMap;
}

From source file:com.verisign.epp.codec.gen.EPPUtil.java

/**
 * Determines if one <code>Vector</code> is a subset of another
 * <code>Vector</code>. If every element in <code>aV1</code> is in
 * <code>aV2</code> return <code>true</code>; otherwise return
 * <code>false</code>.//w  ww.  j  a v  a2  s  .c o m
 * 
 * @param aV1
 *            Subset <code>Vector</code> to compare against <code>aV2</code>
 * @param aV2
 *            Superset <code>Vector</code> to compare against
 *            <code>aV1</code>
 * @return <code>true</code> if <code>aV1</code> is a subset of
 *         <code>aV2</code>; <code>false</code> otherwise.
 */
public static boolean vectorSubset(Vector aV1, Vector aV2) {
    Enumeration v1Enum = aV1.elements();

    while (v1Enum.hasMoreElements()) {
        if (!aV2.contains(v1Enum.nextElement())) {
            return false;
        }
    }

    return true;
}

From source file:org.lockss.util.Logger.java

private void writeMsg(int level, String msg) {
    Iterator iter = targets.iterator();
    while (iter.hasNext()) {
        LogTarget target = (LogTarget) iter.next();
        Vector ts = (Vector) targetStack.get();
        if (!ts.contains(target)) {
            try {
                ts.add(target);//from   ww  w.j av a  2 s  .  c  o  m
                target.handleMessage(this, level, msg);
            } catch (Exception e) {
                // should log this?
            } finally {
                ts.remove(target);
            }
        }
    }
}

From source file:org.kepler.sms.NamedOntModel.java

/**
 * @return The root classes, i.e., without a named superclass, for this
 *         ontology./*from  w  ww. jav  a 2s  .c o  m*/
 */
public Iterator<NamedOntClass> getRootClasses(boolean sorted) {
    // get all the classesg
    Vector<OWLClass> classes = new Vector(_ontology.getReferencedClasses());
    Vector<NamedOntClass> results = new Vector();
    boolean foundResult = true;
    // check each class to see if a root
    for (OWLClass c : _ontology.getReferencedClasses()) { // TODO: Is this an appropriate replacement for listNamedClasses()?
        for (OWLDescription superClassAxiom : c.getSuperClasses(_ontology)) {

            if (!superClassAxiom.isAnonymous()) {
                OWLClass s = superClassAxiom.asOWLClass();
                if (classes.contains(s)) {
                    foundResult = false;
                    break;
                }
            }
        }

        if (foundResult) {
            results.add(new NamedOntClass(c, _ontology));
        }
        foundResult = true;
    }
    if (sorted)
        Collections.sort(results);
    return results.iterator();
}

From source file:org.spiderplan.tools.visulization.GraphFrame.java

@Override
public void actionPerformed(ActionEvent ae) {
    Component source = (Component) ae.getSource();

    if (source.getName().equals("SwitchMode")) {
        if (this.mode == Mode.Transformation) {
            switchMode.setText("Transformation");
            this.mode = Mode.Picking;
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
        } else {//from  w w  w . j  a v  a2 s . com
            switchMode.setText("Picking");
            this.mode = Mode.Transformation;
            graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
        }
    } else if (source.getName().equals("Dump")) {
        this.writeJPEGImage("screenshot.png", "png");
    } else if (source.getName().equals("Subgraph")) {

        PickedState<V> selection = vv.getPickedVertexState();

        if (selection.getPicked().size() > 0) {
            int depth = Integer.valueOf(subGraphDepth.getText()).intValue();

            GraphTools<V, E> cG = new GraphTools<V, E>();

            Vector<V> connected = new Vector<V>();
            connected.addAll(selection.getPicked());
            Vector<V> checked = new Vector<V>();

            for (int i = 0; i < depth; i++) {
                Vector<V> addList = new Vector<V>();
                for (V v1 : connected) {
                    if (!checked.contains(v1)) {
                        checked.add(v1);
                        for (V v2 : g.getNeighbors(v1)) {
                            if (!connected.contains(v2)) {
                                addList.add(v2);
                            }
                        }
                    }
                }
                for (V v : addList) {
                    connected.add(v);
                }
            }

            AbstractTypedGraph<V, E> subGraph;
            if (this.defaultEdgeType == EdgeType.UNDIRECTED) {
                subGraph = cG.copyUndirSparseMultiGraph(g);
            } else {
                subGraph = cG.copyDirSparseMultiGraph(g);
            }

            Vector<V> removeList = new Vector<V>();
            for (V v : subGraph.getVertices()) {
                if (!connected.contains(v)) {
                    removeList.add(v);
                }
            }
            for (V v : removeList) {
                subGraph.removeVertex(v);
            }
            new GraphFrame<V, E>(subGraph, null, "Sub Graph " + subGraphCounter, this.layoutClass,
                    this.edgeLabels);

            subGraphCounter++;
        }
    } else if (source.getName().equals("SelectLayout")) {
        @SuppressWarnings("rawtypes")
        JComboBox box = (JComboBox) source;

        String selection = box.getSelectedItem().toString();

        if (selection.equals("FR")) {
            this.setLayout(LayoutClass.FR);
        } else if (selection.equals("FR2")) {
            this.setLayout(LayoutClass.FR2);
        } else if (selection.equals("Static")) {
            this.setLayout(LayoutClass.Static);
        } else if (selection.equals("Circle")) {
            this.setLayout(LayoutClass.Circle);
        } else if (selection.equals("DAG")) {
            this.setLayout(LayoutClass.DAG);
        } else if (selection.equals("Spring")) {
            this.setLayout(LayoutClass.Spring);
        } else if (selection.equals("Spring2")) {
            this.setLayout(LayoutClass.Spring2);
        } else if (selection.equals("ISOM")) {
            this.setLayout(LayoutClass.ISOM);
        } else if (selection.equals("PolarPoint")) {
            this.setLayout(LayoutClass.PolarPoint);
        } else if (selection.equals("KK")) {
            this.setLayout(LayoutClass.KK);
        }

        Dimension d = vv.getSize();//new Dimension(600,600);
        layout.setSize(d);

        try {
            Relaxer relaxer = new VisRunner((IterativeContext) layout);
            relaxer.stop();
            relaxer.prerelax();
        } catch (java.lang.ClassCastException e) {
        }

        StaticLayout<V, E> staticLayout = new StaticLayout<V, E>(g, layout);
        LayoutTransition<V, E> lt = new LayoutTransition<V, E>(vv, vv.getGraphLayout(), staticLayout);
        Animator animator = new Animator(lt);
        animator.start();
        vv.repaint();
    }
}

From source file:org.openmrs.module.openhmis.inventory.web.controller.InventoryMessageRenderController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView render(HttpServletRequest request) {
    // object to store keys from inventory and backboneforms
    Vector<String> keys = new Vector<String>();

    Locale locale = RequestContextUtils.getLocale(request);
    ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale);

    // store inventory message keys in the vector object
    keys.addAll(resourceBundle.keySet());

    // retrieve backboneforms messages
    BackboneMessageRenderController backboneController = new BackboneMessageRenderController();
    ModelAndView modelAndView = backboneController.render(request);

    // store backboneforms message keys in the vector object
    for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) {
        Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue();
        while (messageKey.hasMoreElements()) {
            String key = messageKey.nextElement();
            if (!keys.contains(key))
                keys.add(key);/*  w ww  .  j a  va 2s . c  o m*/
        }
    }

    return new ModelAndView(ModuleWebConstants.MESSAGE_PAGE, "keys", keys.elements());
}