Example usage for java.util Vector iterator

List of usage examples for java.util Vector iterator

Introduction

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

Prototype

public synchronized Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:org.curriki.xwiki.plugin.curriki.CurrikiPlugin.java

/**
 * Verificate if a user is in Group//from ww  w  .  ja va  2  s  .  co  m
 * @param groupName
 * @param context
 * @return
 * @throws XWikiException
 */
public Boolean isMember(String groupName, XWikiContext context) throws XWikiException {
    XWikiDocument doc = context.getWiki().getDocument(groupName, context);
    Vector<BaseObject> groups = doc.getObjects("XWiki.XWikiGroups");
    if (groups != null) {
        for (Iterator iterator = groups.iterator(); iterator.hasNext();) {
            BaseObject group = (BaseObject) iterator.next();
            if (group != null) {
                String groupMember = group.getStringValue("member");
                if (groupMember != null && context.getUser().equals(groupMember)) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:com.jada.order.document.InvoiceEngine.java

public Vector<?> getInvoiceTaxes() {
    Vector<InvoiceDetailTax> invoiceDetailTaxes = new Vector<InvoiceDetailTax>();
    Iterator<?> iterator = invoiceHeader.getInvoiceTaxes().iterator();
    while (iterator.hasNext()) {
        InvoiceDetailTax invoiceDetailTax = (InvoiceDetailTax) iterator.next();
        boolean found = false;
        Iterator<?> sumIterator = invoiceDetailTaxes.iterator();
        InvoiceDetailTax sumTax = null;// w  w  w.ja v a 2  s  .co  m
        while (sumIterator.hasNext()) {
            sumTax = (InvoiceDetailTax) sumIterator.next();
            if (sumTax.getTaxName().equals(invoiceDetailTax.getTaxName())) {
                found = true;
                break;
            }
        }
        if (!found) {
            sumTax = new InvoiceDetailTax();
            sumTax.setTaxName(invoiceDetailTax.getTaxName());
            sumTax.setTaxAmount((float) 0);
            sumTax.setTax(invoiceDetailTax.getTax());
            invoiceDetailTaxes.add(sumTax);
        }
        float taxAmount = sumTax.getTaxAmount();
        taxAmount += invoiceDetailTax.getTaxAmount();
        sumTax.setTaxAmount(taxAmount);
    }
    return invoiceDetailTaxes;
}

From source file:org.kepler.dataproxy.datasource.opendap.OpendapDataSourceODC.java

/**
 * Configure the output ports to expose all of the variables at the top
 * level of the (potentially constrained) DDS.
 * //  w w w . j ava2s  .c om
 * @param dds
 *            The DDS
 * @throws IllegalActionException
 *             When bad things happen.
 */
private void configureOutputPorts(DDS dds) throws IllegalActionException {

    Vector<Type> types = new Vector<Type>();
    Vector<String> names = new Vector<String>();

    Enumeration e = dds.getVariables();
    while (e.hasMoreElements()) {
        opendap.dap.BaseType bt = (opendap.dap.BaseType) e.nextElement();
        types.add(TypeMapper.mapDapObjectToType(bt, false));
        names.add(bt.getLongName());
    }

    removeOtherOutputPorts(names);

    Iterator ti = types.iterator();
    Iterator ni = names.iterator();

    while (ti.hasNext() && ni.hasNext()) {
        Type type = (Type) ti.next();
        String name = (String) ni.next();
        initializePort(name, type);
    }

}

From source file:org.apache.axis.attachments.AttachmentsImpl.java

/**
 * Retrieves all the <CODE>AttachmentPart</CODE> objects
 * that have header entries that match the specified headers.
 * Note that a returned attachment could have headers in
 * addition to those specified.//from w w w.ja v a  2s  .c om
 * @param   headers a <CODE>MimeHeaders</CODE>
 *     object containing the MIME headers for which to
 *     search
 * @return an iterator over all attachments that have a header
 *     that matches one of the given headers
 */
public java.util.Iterator getAttachments(javax.xml.soap.MimeHeaders headers) {
    if (_askedForStreams) {
        throw new IllegalStateException(Messages.getMessage("concurrentModificationOfStream"));
    }
    java.util.Vector vecParts = new java.util.Vector();
    java.util.Iterator iterator = GetAttachmentsIterator();
    while (iterator.hasNext()) {
        Part part = (Part) iterator.next();
        if (part instanceof AttachmentPart) {
            if (((AttachmentPart) part).matches(headers)) {
                vecParts.add(part);
            }
        }
    }
    return vecParts.iterator();
}

From source file:dao.ColMessageDaoDb.java

private int getNodeLevel(String rid, Vector msgs, ColMessage colMsg) {

    if (RegexStrUtil.isNull(rid) || (msgs == null) || (colMsg == null)) {
        throw new BaseDaoException("params are null");
    }//from  www .  j a va  2 s. com

    //logger.info("msgs.size() = " + msgs.size());

    int j = 0;
    Iterator iterator = msgs.iterator();
    if (rid != null) {
        while (iterator.hasNext()) {
            Vector replies = (Vector) iterator.next();
            if (replies == null) {
                //logger.info("replies is null ");
                continue;
            }
            for (int i = 0; i < replies.size(); i++) {
                if (rid.equalsIgnoreCase(((ColMessage) replies.elementAt(i)).getValue(DbConstants.RID))) {
                    String levelStr = ((ColMessage) replies.elementAt(i)).getValue(DbConstants.LEVEL);

                    //logger.info("level = " + levelStr + "msgs rid " + ((ColMessage)replies.elementAt(i)).getValue(DbConstants.MESSAGE_ID) );
                    if (levelStr != null) {
                        Integer level = new Integer(levelStr);
                        //logger.info("level Integer = " + level);
                        level++;
                        //logger.info("level Integer = " + level.toString() + " j = " + j);
                        colMsg.setValue("level", level.toString());
                    }
                    return (j + 1);
                }
            }
            j++;
        }
    }
    return -1;
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

private void sendLogs(CheckpointInfoCIC ci) {
    //send replies
    //System.out.println("[CIC] Sending logged messages...");
    Vector<ReplyLog> replies = ci.replyToResend;
    Iterator<ReplyLog> itReplies = replies.iterator();
    while (itReplies.hasNext()) {
        //System.out.println( this.owner.getID() + "      SEND REPLY");
        UniversalBody destination = null;
        Reply r = null;/* www  .jav  a  2 s  .c om*/
        ReplyLog rl = (itReplies.next());
        r = rl.getReply();
        destination = rl.getDestination();
        this.sendReply(r, destination);
    }

    //send requests
    Vector<RequestLog> requests = ci.requestToResend;
    Iterator<RequestLog> itRequests = requests.iterator();
    while (itRequests.hasNext()) {
        try {
            //System.out.println( this.owner.getID() + "      SEND REQUEST");
            UniversalBody destination = null;
            RequestLog lr = itRequests.next();
            Request loggedRequest = lr.getRequest();
            destination = lr.getDestination();
            // must create a new req : the sender must be this.owner
            Request r = new RequestImpl(loggedRequest.getMethodCall(), this.owner.getRemoteAdapter(),
                    loggedRequest.isOneWay(), loggedRequest.getSequenceNumber());
            this.sendRequest(r, destination);
        } catch (RenegotiateSessionException e) {
            e.printStackTrace();
        } catch (CommunicationForbiddenException e) {
            e.printStackTrace();
        }
    }
}

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

/**
 * @param sorted/*from w  w  w .jav a2s .  c  o m*/
 *            Return sorted list if true.
 */
public Iterator<NamedOntClass> getNamedSubClasses(boolean sorted) {
    Vector<NamedOntClass> result = new Vector<NamedOntClass>();
    for (OWLDescription desc : _ontClass.getSubClasses(_ontology)) {
        OWLClass subcls = desc.asOWLClass();
        boolean hasLabel = !subcls.getAnnotations(_ontology, OWLRDFVocabulary.RDFS_LABEL.getURI()).isEmpty();
        if (hasLabel || subcls.toString() != null) {
            // NOTE: Does subcls.toString == null happen?
            result.add(new NamedOntClass(subcls, _ontology));
        }
    }
    if (sorted) {
        Collections.sort(result);
    }
    return result.iterator();
}

From source file:com.limegroup.gnutella.metadata.MP3DataEditor.java

/**
 * Actually writes the ID3 tags out to the ID3V3 section of the mp3 file
 *///from   w  w w  .j av  a  2 s. c  o  m
private int writeID3V2DataToDisk(File file) throws IOException, ID3v2Exception {
    ID3v2 id3Handler = new ID3v2(file);
    Vector frames = null;
    try {
        frames = (Vector) id3Handler.getFrames().clone();
    } catch (NoID3v2TagException ex) {//there are no ID3v2 tags in the file
        //fall thro' we'll deal with it later -- frames will be null
    }

    List framesToUpdate = new ArrayList();
    addAllNeededFrames(framesToUpdate);
    if (framesToUpdate.size() == 0) //we have nothing to update
        return LimeXMLReplyCollection.NORMAL;
    if (frames != null) { //old frames present, update the differnt ones 
        for (Iterator iter = frames.iterator(); iter.hasNext();) {
            ID3v2Frame oldFrame = (ID3v2Frame) iter.next();
            //note: equality of ID3v2Frame based on value of id
            int index = framesToUpdate.indexOf(oldFrame);
            ID3v2Frame newFrame = null;
            if (index >= 0) {
                newFrame = (ID3v2Frame) framesToUpdate.remove(index);
                if (Arrays.equals(oldFrame.getContent(), newFrame.getContent()))
                    continue;//no need to update, skip this frame
            }
            //we are either going to replace it if it was changed, or remove
            //it since there is no equivalent frame in the ones we need to
            //update, this means the user probably removed it
            id3Handler.removeFrame(oldFrame);
            if (newFrame != null)
                id3Handler.addFrame(newFrame);
        }
    }
    //now we are left with the ones we need to add only, if there were no
    //old tags this will be all the frames that need to get updated
    for (Iterator iter = framesToUpdate.iterator(); iter.hasNext();) {
        ID3v2Frame frame = (ID3v2Frame) iter.next();
        id3Handler.addFrame(frame);
    }

    id3Handler.update();
    //No Exceptions? We are home
    return LimeXMLReplyCollection.NORMAL;
}

From source file:org.apache.rampart.PolicyBasedResultsValidator.java

protected ArrayList getSigEncrActions(Vector results) {
    ArrayList sigEncrActions = new ArrayList();
    for (Iterator iter = results.iterator(); iter.hasNext();) {
        Integer actInt = (Integer) ((WSSecurityEngineResult) iter.next())
                .get(WSSecurityEngineResult.TAG_ACTION);
        int action = actInt.intValue();
        if (WSConstants.SIGN == action || WSConstants.ENCR == action) {
            sigEncrActions.add(Integer.valueOf(action));
        }/*from  w  ww  . j a  va  2s  .c  o m*/

    }
    return sigEncrActions;
}

From source file:dao.PblogMessageDaoDb.java

private int getNodeLevel(String rid, Vector msgs, Blog pBlogMsg) {
    if (RegexStrUtil.isNull(rid) || (msgs == null) || (pBlogMsg == null)) {
        throw new BaseDaoException("params are null");
    }/*  w w  w.  j a  va  2 s .  c  o m*/

    int j = 0;
    Iterator iterator = msgs.iterator();
    if (rid != null) {
        while (iterator.hasNext()) {
            Vector replies = (Vector) iterator.next();
            if (replies == null) {
                //logger.info("replies is null ");
                continue;
            }
            for (int i = 0; i < replies.size(); i++) {
                if (rid.equalsIgnoreCase(((Blog) replies.elementAt(i)).getValue(DbConstants.REPLY_ID))) {
                    String levelStr = ((Blog) replies.elementAt(i)).getValue(DbConstants.LEVEL);

                    //logger.info("level = " + levelStr + "msgs rid " + ((Blog)replies.elementAt(i)).getValue(DbConstants.MESSAGE_ID) );
                    if (levelStr != null) {
                        Integer level = new Integer(levelStr);
                        //logger.info("level Integer = " + level);
                        level++;
                        //logger.info("level Integer = " + level.toString() + " j = " + j);
                        pBlogMsg.setValue("level", level.toString());
                    }
                    return (j + 1);
                }
            }
            j++;
        }
    }
    return -1;
}