Example usage for java.util Vector remove

List of usage examples for java.util Vector remove

Introduction

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

Prototype

public synchronized E remove(int index) 

Source Link

Document

Removes the element at the specified position in this Vector.

Usage

From source file:org.alfresco.repo.transfer.AlienProcessorImpl.java

public void beforeDeleteAlien(NodeRef deletedNodeRef, ChildAssociationRef oldAssoc) {
    log.debug("before delete node - need to check for alien invaders");

    List<String> stuff = (List<String>) nodeService.getProperty(deletedNodeRef, TransferModel.PROP_INVADED_BY);
    if (stuff == null)
        return;//from ww w  .  j  a v a2 s.com
    Vector<String> exInvaders = new Vector<String>(stuff);

    /**
     * some fudge to get this to run after the node has been moved.
     */
    ChildAssociationRef currentAssoc;
    if (oldAssoc != null) {
        currentAssoc = oldAssoc;
    } else {
        currentAssoc = nodeService.getPrimaryParent(deletedNodeRef);
    }

    while (currentAssoc != null && exInvaders != null && exInvaders.size() > 0) {
        NodeRef parentNodeRef = currentAssoc.getParentRef();
        NodeRef currentNodeRef;

        if (currentAssoc == oldAssoc) {
            currentNodeRef = deletedNodeRef;
        } else {
            currentNodeRef = currentAssoc.getChildRef();
        }

        /**
         * Does the parent have alien invaders ?
         */
        if (nodeService.hasAspect(parentNodeRef, TransferModel.ASPECT_ALIEN)) {
            log.debug("parent node is invaded by aliens");

            /**
             * Remove the parent's origin from the list of exInvaders since the parent also invades.
             */
            String parentRepoId;
            if (nodeService.hasAspect(parentNodeRef, TransferModel.ASPECT_TRANSFERRED)) {
                parentRepoId = (String) nodeService.getProperty(parentNodeRef,
                        TransferModel.PROP_FROM_REPOSITORY_ID);
            } else {
                parentRepoId = descriptorService.getCurrentRepositoryDescriptor().getId();
            }

            exInvaders.remove(parentRepoId);

            /**
             * For each invader of the deletedNode
             */
            Iterator<String> i = exInvaders.listIterator();
            while (i.hasNext()) {
                String exInvader = i.next();
                log.debug("Checking exInvader:" + exInvader);

                /**
                  * Check the siblings of this node to see whether there are any other alien nodes for this invader.
                  */
                //List<ChildAssociationRef> refs = nodeService.getChildAssocs(parentNodeRef);
                List<ChildAssociationRef> refs = nodeService.getChildAssocsByPropertyValue(parentNodeRef,
                        TransferModel.PROP_INVADED_BY, exInvader);

                for (ChildAssociationRef ref : refs) {
                    NodeRef childRef = ref.getChildRef();
                    List<String> invadedBy = (List<String>) nodeService.getProperty(childRef,
                            TransferModel.PROP_INVADED_BY);

                    if (childRef.equals(currentNodeRef)) {
                        // do nothing - this is the node we are working with.
                    } else {
                        if (invadedBy != null && invadedBy.contains(exInvader)) {
                            // There is a sibling so remove this from the list of ex invaders.
                            log.debug("yes there is a sibling so it remains an invader");
                            i.remove();
                            break;
                        }
                    }
                } // for each child assoc

            } // for each invader

            log.debug("end of checking siblings");

            if (exInvaders.size() > 0) {
                log.debug("removing invaders from parent node:" + parentNodeRef);
                List<String> parentInvaders = (List<String>) nodeService.getProperty(parentNodeRef,
                        TransferModel.PROP_INVADED_BY);

                final List<String> newInvaders = new ArrayList<String>(10);
                for (String invader : parentInvaders) {
                    if (exInvaders.contains(invader)) {
                        log.debug("removing invader:" + invader);
                    } else {
                        newInvaders.add(invader);
                    }
                }

                final NodeRef oldAlien = parentNodeRef;

                /**
                 * Parent may be locked or not be editable by the current user 
                 * turn off auditing and lock service for this transaction and 
                 * run as admin.
                 */
                RunAsWork<Void> actionRunAs = new RunAsWork<Void>() {
                    public Void doWork() throws Exception {
                        behaviourFilter.disableBehaviour(oldAlien, ContentModel.ASPECT_AUDITABLE);
                        behaviourFilter.disableBehaviour(oldAlien, ContentModel.ASPECT_LOCKABLE);
                        if (newInvaders.size() > 0) {
                            nodeService.setProperty(oldAlien, TransferModel.PROP_INVADED_BY,
                                    (Serializable) newInvaders);
                        } else {
                            log.debug("parent node is no longer alien nodeRef" + oldAlien);
                            nodeService.removeAspect(oldAlien, TransferModel.ASPECT_ALIEN);
                        }
                        return null;
                    }
                };
                AuthenticationUtil.runAs(actionRunAs, AuthenticationUtil.getSystemUserName());
            }

            /**
             * Now step up to the parent's parent
             */
            currentAssoc = nodeService.getPrimaryParent(parentNodeRef);
        } else {
            log.debug("parent is not an alien node");
            currentAssoc = null;
        }
    } // end of while              
}

From source file:edu.umn.cs.spatialHadoop.mapreduce.SpatialInputFormat3.java

@Override
public List<InputSplit> getSplits(JobContext job) throws IOException {
    List<InputSplit> splits = super.getSplits(job);
    Configuration jobConf = job.getConfiguration();
    if (jobConf.getInt(CombineSplits, 1) > 1) {
        long t1 = System.currentTimeMillis();
        int combine = jobConf.getInt(CombineSplits, 1);
        /*//from   www . j  a  v a 2  s  . com
         * Combine splits to reduce number of map tasks. Currently, this is done
         * using a greedy algorithm that combines splits based on how many hosts
         * they share.
         * TODO: Use a graph clustering algorithm where each vertex represents a
         * split, and each edge is weighted with number of shared hosts between
         * the two splits
         */
        Vector<Vector<FileSplit>> openSplits = new Vector<Vector<FileSplit>>();
        int maxNumberOfSplits = (int) Math.ceil((float) splits.size() / combine);
        List<InputSplit> combinedSplits = new Vector<InputSplit>();
        for (InputSplit split : splits) {
            FileSplit fsplit = (FileSplit) split;
            int maxSimilarity = -1; // Best similarity found so far
            int bestFit = -1; // Index of a random open split with max similarity
            int numMatches = 0; // Number of splits with max similarity
            for (int i = 0; i < openSplits.size(); i++) {
                Vector<FileSplit> splitList = openSplits.elementAt(i);
                int similarity = 0;
                for (FileSplit otherSplit : splitList) {
                    for (String host1 : fsplit.getLocations())
                        for (String host2 : otherSplit.getLocations())
                            if (host1.equals(host2))
                                similarity++;
                }
                if (similarity > maxSimilarity) {
                    maxSimilarity = similarity;
                    bestFit = i;
                    numMatches = 1;
                } else if (similarity == maxSimilarity) {
                    numMatches++;
                    // Replace with a probability () for a reservoir sample
                    double random = Math.random();
                    if (random < (double) 1 / numMatches) {
                        // Replace the element in the reservoir
                        bestFit = i;
                    }
                }
            }
            if (maxSimilarity > 0 || (openSplits.size() + combinedSplits.size()) >= maxNumberOfSplits) {
                // Good fit || cannot create more open splits,
                // add it to an existing open split.
                Vector<FileSplit> bestList = openSplits.elementAt(bestFit);
                bestList.add(fsplit);
                if (bestList.size() > combine) {
                    // Reached threshold for this list. Add it to combined splits
                    combinedSplits.add(FileSplitUtil.combineFileSplits(bestList, 0, bestList.size()));
                    // Remove it from open splits
                    openSplits.remove(bestFit);
                }
            } else {
                // Bad fit && can add a new split
                // Create a new open split just for this one
                Vector<FileSplit> newOpenSplit = new Vector<FileSplit>();
                newOpenSplit.add(fsplit);
                openSplits.addElement(newOpenSplit);
            }
        }

        // Add all remaining open splits to the list of combined splits
        for (Vector<FileSplit> openSplit : openSplits) {
            combinedSplits.add(FileSplitUtil.combineFileSplits(openSplit, 0, openSplit.size()));
        }

        String msg = String.format("Combined %d splits into %d combined splits", splits.size(),
                combinedSplits.size());
        splits.clear();
        splits.addAll(combinedSplits);
        long t2 = System.currentTimeMillis();
        LOG.info(msg + " in " + ((t2 - t1) / 1000.0) + " seconds");
    }
    return splits;
}

From source file:edu.ku.brc.specify.config.init.secwiz.UserPanel.java

/**
 * @param isInitial//from   w w w.  j  a  va2 s  . c o m
 */
private void loadData(final boolean isInitial) {
    label.setText("");

    String hostName = properties.getProperty("hostName");
    String dbUserName = properties.getProperty("dbUserName");
    String dbPassword = properties.getProperty("dbPassword");

    int index = 0;
    List<String> dbNamesList = masterPanel.getDbNamesForMaster();
    List<String> otherNamesList = masterPanel.getDbNameList();

    if (dbNamesList == null || dbNamesList.size() == 0) {
        return;
    }

    //dbNamesList.clear();
    //otherNamesList.clear();
    //dbNamesList.add("testfish");

    Vector<String> items = new Vector<String>(dbNamesList);
    Collections.sort(items);

    if (!isInitial) {
        index = dbList.getSelectedIndex();
        if (index == -1) {
            return;
        }
    }

    databaseName = isInitial ? items.get(0) : (String) dbList.getSelectedValue();

    DBMSUserMgr mgr = DBMSUserMgr.getInstance();
    do {
        if (mgr.connect(dbUserName, dbPassword, hostName, databaseName)) {
            if (isInitial) {
                HashSet<String> dbNameHashSet = new HashSet<String>();
                DefaultListModel model = new DefaultListModel();
                for (String nm : items) {
                    model.addElement(nm);
                    dbNameHashSet.add(nm);
                }
                dbList.setModel(model);

                model = new DefaultListModel();
                for (String nm : otherNamesList) {
                    if (!dbNameHashSet.contains(nm)) {
                        model.addElement(nm);
                    }
                }
                otherDBList.setModel(model);
            }

            label.setText(getFormattedResStr("MSTR_USR_DB", databaseName));

            if (!mgr.doesDBHaveTable(databaseName, "specifyuser")) {
                items.remove(0);
                databaseName = isInitial ? items.get(0) : (String) dbList.getSelectedValue();
                continue;
            }

            Vector<UserData> userDataList = new Vector<UserData>();
            String sql = "SELECT SpecifyUserId, Name, Password, EMail FROM specifyuser";
            Vector<Object[]> data = BasicSQLUtils.query(mgr.getConnection(), sql);

            for (Object[] c : data) {
                UserData ud = new UserData((Integer) c[0], (String) c[1], (String) c[2], "(On user's machine)",
                        (String) c[3]);
                userDataList.add(ud);

                sql = String.format(
                        "SELECT LastName, FirstName, EMail FROM agent WHERE SpecifyUserID = %d ORDER BY TimestampModified, TimestampCreated LIMIT 0,1",
                        ud.getId());
                Vector<Object[]> uData = BasicSQLUtils.query(mgr.getConnection(), sql);
                if (uData.size() > 0) {
                    Object[] d = uData.get(0);
                    ud.setLastName((String) d[0]);
                    ud.setFirstName((String) d[1]);

                    String email = (String) d[2];
                    if (StringUtils.isNotEmpty(email) && StringUtils.isEmpty(ud.getEmail())) {
                        ud.setEmail(email);
                    }
                } else {
                    // error
                }
            }
            mgr.close();
            userModel.setUserData(userDataList);
            UIHelper.calcColumnWidths(userTable);

            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    Window window = getTopWindow();
                    Insets screenInsets = Toolkit.getDefaultToolkit()
                            .getScreenInsets(window.getGraphicsConfiguration());
                    Rectangle screenRect = window.getGraphicsConfiguration().getBounds();

                    screenRect.height -= screenInsets.top + screenInsets.bottom;
                    screenRect.width -= screenInsets.left + screenInsets.right;

                    Rectangle rect = window.getBounds();
                    Dimension size = window.getPreferredSize();

                    // Make sure the window isn't larger than the screen
                    size.width = Math.min(size.width, screenRect.width);
                    size.height = Math.min(size.height, screenRect.height);

                    if (size.height > rect.height || size.width > rect.width) {
                        window.setBounds(rect.x, rect.y, size.width, size.height);
                        UIHelper.centerWindow(getTopWindow());

                    }
                }
            });

            if (isInitial && items.size() > 0) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        dbList.setSelectedIndex(0);
                    }
                });
            }

            break;
        } else if (items.size() > 1) {
            items.remove(0);
            databaseName = isInitial ? items.get(0) : (String) dbList.getSelectedValue();
        } else {
            break;
        }

    } while (true);

}

From source file:org.apache.axis.wsdl.toJava.JavaGeneratorFactory.java

/**
 * If a binding's type is not TYPE_SOAP, then we don't use that binding
 * or that binding's portType./*from  w  w  w.ja va2s .  c  o  m*/
 *
 * @param symbolTable
 */
protected void ignoreNonSOAPBindings(SymbolTable symbolTable) {

    // Look at all uses of the portTypes.  If none of the portType's bindings are of type
    // TYPE_SOAP, then turn off that portType's isReferenced flag.
    Vector unusedPortTypes = new Vector();
    Vector usedPortTypes = new Vector();
    Iterator it = symbolTable.getHashMap().values().iterator();

    while (it.hasNext()) {
        Vector v = (Vector) it.next();

        for (int i = 0; i < v.size(); ++i) {
            SymTabEntry entry = (SymTabEntry) v.elementAt(i);

            if (entry instanceof BindingEntry) {
                BindingEntry bEntry = (BindingEntry) entry;
                Binding binding = bEntry.getBinding();
                PortType portType = binding.getPortType();
                PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName());

                if (bEntry.getBindingType() == BindingEntry.TYPE_SOAP) {

                    // If a binding is of type TYPE_SOAP, then mark its portType used
                    // (ie., add it to the usedPortTypes list.  If the portType was
                    // previously marked as unused, unmark it (in other words, remove it
                    // from the unusedPortTypes list).
                    usedPortTypes.add(ptEntry);

                    if (unusedPortTypes.contains(ptEntry)) {
                        unusedPortTypes.remove(ptEntry);
                    }
                } else {
                    bEntry.setIsReferenced(false);

                    // If a binding is not of type TYPE_SOAP, then mark its portType as
                    // unused ONLY if it hasn't already been marked as used.
                    if (!usedPortTypes.contains(ptEntry)) {
                        unusedPortTypes.add(ptEntry);
                    }
                }
            }
        }
    }

    // Go through all the portTypes that are marked as unused and set their isReferenced flags
    // to false.
    for (int i = 0; i < unusedPortTypes.size(); ++i) {
        PortTypeEntry ptEntry = (PortTypeEntry) unusedPortTypes.get(i);

        ptEntry.setIsReferenced(false);
    }
}

From source file:eu.planets_project.tb.gui.backing.exp.NewExpWizardController.java

/**
 * /*from w w  w.  jav  a 2 s  . c  o m*/
 * @param valueChangedEvent
 */
public void handleObsSelectChangeListener(ValueChangeEvent valueChangedEvent) {
    log.info("Handling event in handleObsSelectChangeListener.");

    MeasurementImpl targetBean = (MeasurementImpl) this.getObsTable().getRowData();

    ExperimentBean expBean = (ExperimentBean) JSFUtil.getManagedObject("ExperimentBean");
    Vector<String> props = expBean.getExperiment().getExperimentExecutable().getProperties();
    if (props.contains(targetBean.getIdentifier().toString())) {
        props.remove(targetBean.getIdentifier().toString());
        log.info("Removed: " + targetBean.getIdentifier());
    } else {
        props.add(targetBean.getIdentifier().toString());
        log.info("Added: " + targetBean.getIdentifier());
    }

}

From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java

/**
 * @see de.juwimm.cms.remote.ContentServiceSpring#getNotReferencedUnits(de.juwimm.cms.vo.ViewDocumentValue)
 *//*from www . ja va2  s.  co m*/
@Override
protected UnitValue[] handleGetNotReferencedUnits(ViewDocumentValue viewDocument) throws Exception {
    if (log.isInfoEnabled())
        log.info("starting getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                + viewDocument.getLanguage());
    try {
        Collection coll = super.getViewComponentHbmDao().findAllWithUnit(viewDocument.getViewDocumentId());
        Collection u = super.getUnitHbmDao().findAll(viewDocument.getSiteId());
        Vector<Integer> units = new Vector<Integer>();

        Iterator itUnits = u.iterator();
        while (itUnits.hasNext()) {
            UnitHbm unit = (UnitHbm) itUnits.next();
            units.add(unit.getUnitId());
        }

        Iterator it = coll.iterator();
        while (it.hasNext()) {
            ViewComponentHbm vcl = (ViewComponentHbm) it.next();
            try {
                units.remove(vcl.getAssignedUnit().getUnitId());
            } catch (Exception e) {
                if (log.isDebugEnabled()) {
                    log.debug("Could not remove assigned unit: " + e.getMessage());
                }
            }
        }

        UnitValue[] unitdaos = new UnitValue[units.size()];
        it = units.iterator();
        int i = 0;
        while (it.hasNext()) {
            Integer unitId = (Integer) it.next();
            UnitHbm ul = super.getUnitHbmDao().load(unitId);
            unitdaos[i++] = getUnitHbmDao().getDao(ul);
        }
        if (log.isDebugEnabled())
            log.debug("end getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                    + viewDocument.getLanguage());
        return unitdaos;
    } catch (Exception e) {
        log.warn("Error getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                + viewDocument.getLanguage() + ": " + e.getMessage(), e);
        throw new UserException(e.getMessage());
    }
}

From source file:it.classhidra.core.controller.bsController.java

public static Vector getActionStreams(String id_action) {
    Vector _streams = null;
    info_action iActionMapped = (info_action) getAction_config().get_actions().get(id_action);
    if (iActionMapped == null)
        return new Vector();
    else if (iActionMapped.getVm_streams() != null)
        _streams = iActionMapped.getVm_streams();
    else {/*from  ww w . j  a  v  a2 s.  c  om*/
        _streams = new Vector();
        Vector _streams_orig = (Vector) getAction_config().get_streams_apply_to_actions().get("*");

        if (_streams_orig != null)
            _streams.addAll(_streams_orig);
        Vector _streams4action = (Vector) getAction_config().get_streams_apply_to_actions().get(id_action);
        if (_streams4action != null) {
            Vector _4add = new Vector();
            HashMap _4remove = new HashMap();
            for (int i = 0; i < _streams4action.size(); i++) {
                info_stream currentis = (info_stream) _streams4action.get(i);
                if (currentis.get_apply_to_action() != null) {
                    info_apply_to_action currentiata = (info_apply_to_action) currentis.get_apply_to_action()
                            .get(id_action);
                    if (currentiata.getExcluded() != null && currentiata.getExcluded().equalsIgnoreCase("true"))
                        _4remove.put(currentis.getName(), currentis.getName());
                    else
                        _4add.add(currentis);
                }
            }
            _streams.addAll(_4add);
            if (_4remove.size() > 0) {
                int i = 0;
                while (i < _streams.size()) {
                    info_stream currentis = (info_stream) _streams.get(i);
                    if (_4remove.get(currentis.getName()) != null)
                        _streams.remove(i);
                    else
                        i++;
                }
            }
            _streams = new util_sort().sort(_streams, "int_order", "A");
        }
        iActionMapped.setVm_streams(_streams);
    }
    return _streams;

}

From source file:br.com.blackhubos.eventozero.factory.Event.java

/**
 * Atualiza todas placas//from   w  ww  .j av  a  2 s .  com
 */
public void updateSigns() {
    if (this.getData().containsKey("options.signs.locations")
            && (this.getData().getData("options.signs.locations") != null)) {
        final Vector<Location> signs = (Vector<Location>) getSignsLocation();
        for (final Location location : signs) {
            final Block block = location.getWorld().getBlockAt(location);
            if ((block.getType() == Material.SIGN_POST) || (block.getType() == Material.WALL_SIGN)) {
                final String string = String
                        .valueOf(this.getData().getData("options.message." + this.getState().getPath()));
                final Sign sign = (Sign) block.getState();
                sign.setLine(0, String.valueOf(this.getData().getData("options.signs.line.1"))
                        .replace("{state]", string)
                        .replace("{playersize}", String.valueOf(this.getPlayers().size()))
                        .replace("{playermax}", String.valueOf(this.getData().getData("options.player_max")))
                        .replace("{name}", this.getName()).replaceAll("&", ""));
                sign.setLine(1, String.valueOf(this.getData().getData("options.signs.line.2"))
                        .replace("{state]", string)
                        .replace("{playersize}", String.valueOf(this.getPlayers().size()))
                        .replace("{playermax}", String.valueOf(this.getData().getData("options.player_max")))
                        .replace("{name}", this.getName()).replaceAll("&", ""));
                sign.setLine(2, String.valueOf(this.getData().getData("options.signs.line.3"))
                        .replace("{state]", string)
                        .replace("{playersize}", String.valueOf(this.getPlayers().size()))
                        .replace("{playermax}", String.valueOf(this.getData().getData("options.player_max")))
                        .replace("{name}", this.getName()).replaceAll("&", ""));
                sign.setLine(3, String.valueOf(this.getData().getData("options.signs.line.4"))
                        .replace("{state]", string)
                        .replace("{playersize}", String.valueOf(this.getPlayers().size()))
                        .replace("{playermax}", String.valueOf(this.getData().getData("options.player_max")))
                        .replace("{name}", this.getName()).replaceAll("&", ""));
                sign.update();
            } else
                // remove a locaiton da sign
                signs.remove(location);
        }
    }
}

From source file:com.yaniv.online.MainActivity.java

@Override
public void onRealTimeMessageReceived(RealTimeMessage rtm) {

    byte[] buf = rtm.getMessageData();
    String sender = rtm.getSenderParticipantId();
    Log.d(TAG, "[onRealTimeMessageReceived] - Got message from Participant " + sender + ",msg: "
            + Arrays.toString(buf));

    // Another player finished his turn
    if (buf[0] == 20) {

        turn = buf[1];//from ww w .j av a2  s  . c om
        Card newCard;
        TextView lastPlayerPick = (TextView) (findViewById(R.id.lastPlayerPick));
        if (buf[2] == 5) {
            // if the last player took from the deck, remove the first card
            lastPlayerPick.setText("Last player picked from the deck");
            newCard = cardDeck.jp.remove(0);
        } else {
            lastPlayerPick.setText("Last player picked: " + primaryDeck.peek().get(buf[2]).toString());
            ArrayList<Card> lastDrop = primaryDeck.peek();
            newCard = lastDrop.get(buf[2]);
        }

        lastDropType = buf[3];

        ArrayList<Card> droppedCards = fromGson(buf, 5, buf.length, DATA_TYPE_CARDS);
        Log.d(TAG, "Player dropped cards: " + droppedCards.toString());
        primaryDeck.push(droppedCards);
        Log.d(TAG, "Player cards before: " + mParticipantCards.get(sender));

        Vector<Card> playerCards = mParticipantCards.get(sender);
        for (Card c : droppedCards) {
            Log.d(TAG, "Deleting card: " + c.toString());
            boolean contains = playerCards.contains(c);
            boolean b = playerCards.remove(c);
            Log.d(TAG, "Delete worked: " + b + " card exist? " + contains);
        }
        playerCards.add(newCard);
        Log.d(TAG, "Player cards changed: " + playerCards);
        mParticipantCards.put(sender, playerCards);
        Log.d(TAG, "Player cards after: " + mParticipantCards.get(sender));

        updateParticipantUI(sender);
        updatePrimaryDeckUI();

    }
    //Game is started, owner send the cardsDeck, any participant needs to reload the cards into cardDeck or shuffle cards.
    else if ((int) buf[0] == 0) {
        // Checking shuffle
        if ((int) buf[1] == 1) {
            displayToastForLimitTime("Shuffling Card Deck...", 3000);
        }
        cardDeck = fromGson(buf, 5, buf.length, DATA_TYPE_CARD_DECK);
        Log.d(TAG, "[onRealTimeMessageReceived] - cardDeck " + cardDeck.jp);
        if (cardDeck != null) {
        }
    }
    // Owner create the cards for all participant. needs to save it on Mycards.
    else if ((int) buf[0] == 1) {
        // starting highscores array if null
        if (highscores == null) {
            highscores = new int[mParticipants.size()];
        }
        mParticipantCards = fromGson(buf, 5, buf.length, DATA_TYPE_M_PARTICIPANT_CARDS);
        myCards = mParticipantCards.containsKey(mMyId) ? mParticipantCards.get(mMyId) : null;
        calculateSum();
        setPlayerPositonUI();
        Log.d(TAG, "[onRealTimeMessageReceived] -mycards after" + myCards);
        updateTurnUi();
        updateParticipantsNamesAndUI();
    }
    // When participant played a turn
    else if ((int) buf[0] == 2) {

        mParticipantCards.put(sender, (Vector<Card>) fromGson(buf, 5, buf.length, DATA_TYPE_MY_CARDS));
        Log.d(TAG, "[onRealTimeMessageReceived] -participant " + sender + " finished his turn, his new cards: "
                + mParticipantCards.get(sender));
        updateParticipantUI(sender);

    }
    // take from 0-primary 1-deck           take from the primary or deck (and update in each screen)
    // Cards he take (only if 0)
    else if ((int) buf[0] == 5) {
        primaryDeck = fromGson(buf, 5, buf.length, DATA_TYPE_PRIMARY_DECK);
        Log.d(TAG, "[onRealTimeMessageReceived] - primaryDeck " + primaryDeck);
        if (primaryDeck != null) {
            updatePrimaryDeckUI();
        }
    }
    //when player declare yaniv
    else if ((int) buf[0] == 7) {
        yanivCalled(buf);
    }

    else if ((int) buf[0] == 8) {
        readyToPlayPlayers.put(sender, true);
        checkReadyList();
    }

    else if ((int) buf[0] == 10) {

    }

    // Regular messages to change the turn.
    else {

        turn = buf[3];
        updateTurnUi();
        Log.d(TAG, "[onRealTimeMessageReceived] - regular message ");

        if (buf[1] == 'F' || buf[1] == 'U') {
            turn = buf[3];
            lastDropType = (int) buf[4];
        }
    }
}

From source file:org.apache.ws.security.handler.WSHandler.java

protected void checkSignatureConfirmation(RequestData reqData, Vector wsResult) throws WSSecurityException {
    if (doDebug) {
        log.debug("Check Signature confirmation");
    }//from w  w w.java 2  s.  c  o m

    /*
     * First get all Signature values stored during sending the request
     */
    Vector sigv = (Vector) getProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV);
    /*
     * Now get all results that hold a SignatureConfirmation element from
     * the current run of receiver (we can have more than one run: if we
     * have several security header blocks with different actors/roles)
     */
    Vector sigConf = new Vector();
    WSSecurityUtil.fetchAllActionResults(wsResult, WSConstants.SC, sigConf);
    /*
     * now loop over all SignatureConfirmation results and check:
     * - if there is a signature value and no Signature value generated in request: error
     * - if there is a signature value and no matching Signature value found: error
     * 
     *  If a matching value found: remove from vector of stored signature values
     */
    for (int i = 0; i < sigConf.size(); i++) {
        WSSecurityEngineResult result = (WSSecurityEngineResult) sigConf.get(i);
        SignatureConfirmation sc = (SignatureConfirmation) result
                .get(WSSecurityEngineResult.TAG_SIGNATURE_CONFIRMATION);

        byte[] sigVal = sc.getSignatureValue();
        if (sigVal != null) {
            if (sigv == null || sigv.size() == 0) {
                // If there are no stored signature values
                if (sigVal.length != 0) {
                    // If there's no value in the case where there are no
                    // stored SV it is valid. Therefore if there IS a value 
                    // in the sig confirmation element
                    throw new WSSecurityException(
                            "WSHandler: Check Signature confirmation: got a SC element, " + "but no stored SV");
                }
            } else {
                //If we have stored signature values
                boolean found = false;
                for (int ii = 0; ii < sigv.size(); ii++) {
                    byte[] storedValue = (byte[]) sigv.get(ii);
                    if (Arrays.equals(sigVal, storedValue)) {
                        found = true;
                        sigv.remove(ii);
                        break;
                    }
                }
                if (!found) {
                    throw new WSSecurityException(
                            "WSHandler: Check Signature confirmation: got SC element, " + "but no matching SV");
                }
            }
        }
    }

    /*
     * This indicates this is the last handler: the vector holding the
     * stored Signature values must be empty, otherwise we have an error
     */
    if (!reqData.isNoSerialization()) {
        log.debug("Check Signature confirmation - last handler");
        if (sigv != null && !sigv.isEmpty()) {
            throw new WSSecurityException(
                    "WSHandler: Check Signature confirmation: stored SV vector not empty");
        }
    }
}