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:com.naryx.tagfusion.cfm.xml.ws.javaplatform.DynamicWebServiceStubGenerator.java

private StubInfo.Operation[] findOperations(Parser wsdlParser, Port port) {
    SymbolTable symbolTable = wsdlParser.getSymbolTable();
    BindingEntry bEntry = symbolTable.getBindingEntry(port.getBinding().getQName());
    Set opSet = bEntry.getParameters().keySet();
    Iterator itr = opSet.iterator();

    StubInfo.Operation[] siOps = new StubInfo.Operation[opSet.size()];
    for (int i = 0; itr.hasNext(); i++) {
        // Get the operation and add the parameters
        Operation op = (Operation) itr.next();
        Vector parms = bEntry.getParameters(op).list;

        // Populate the parms
        StubInfo.Parameter[] siParms = new StubInfo.Parameter[parms.size()];
        StubInfo.Operation siOp = new StubInfo.Operation(op.getName(), siParms);
        siOps[i] = siOp;//  w  w w .  j  a  va 2s.  c  om
        Iterator tmpItr = parms.iterator();
        for (int j = 0; tmpItr.hasNext(); j++) {
            Parameter p = (Parameter) tmpItr.next();
            siParms[j] = new StubInfo.Parameter(p.getName(), p.isNillable(), p.isOmittable());
        }

        // If there is only 1 parameter and it's a complex object,
        // gather parameter information for its properties.
        if (parms.size() == 1) {
            Vector elems = ((Parameter) parms.get(0)).getType().getContainedElements();
            if (elems != null && !elems.isEmpty()) {
                StubInfo.Parameter[] siSubParms = new StubInfo.Parameter[elems.size()];
                tmpItr = elems.iterator();
                for (int j = 0; tmpItr.hasNext(); j++) {
                    ElementDecl e = (ElementDecl) tmpItr.next();
                    siSubParms[j] = new StubInfo.Parameter(e.getName(), e.getNillable(), e.getMinOccursIs0());
                }
                siOp.setSubParameters(siSubParms);
            }
        }
    }

    // Return the operations
    return siOps;
}

From source file:vitro.vspEngine.service.communication.DummyDCACommUtils.java

/**
 * Should parse a QueryDefinition and get the results from the corresponding gateway. Also apply any global functions if requested!
 *///ww w  .java2 s .c  o  m
public void executeAggrQuery(String uQDefID, String gateID,
        Vector<QueriedMoteAndSensors> motesAndTheirSensorAndFuncVec, boolean isHistory,
        Vector<ReqFunctionOverData> functionVec, int thisQueryOrderNum) {
    String tmpXMLtoSend;
    String tmpXMLreceived;
    try {
        // TODO: ++++ CHECK RESPONSES. CHECK INVALID RESPONSES AND ERRORS TOO?
        Iterator<QueriedMoteAndSensors> itVec = motesAndTheirSensorAndFuncVec.iterator();
        while (itVec.hasNext()) {
            QueriedMoteAndSensors tmp = itVec.next();
            String dcaDevId = /*gateID+ "." +*/ tmp.getMoteId(); // we already have the gateID prefix in DCA comm mode.
            tmpXMLtoSend = SensorData.getLastMeasurement(Config.getConfig().getServiceIDVITRO(), dcaDevId);
            tmpXMLreceived = IDASHttpRequest.getIDASHttpRequest().sendPOSTToIdasXML(tmpXMLtoSend);
            //LOG.debug("RECEIVED LAST MEASUREMENT FROM "+ dcaDevId + ": "+tmpXMLreceived + "\n--------------------------\n--------------------------\n\n");
            String[] possibleFaultCode;

            XPathString xpathStr = new XPathString(tmpXMLreceived);
            try {
                possibleFaultCode = xpathStr.parseXpathValues("//Envelope/Body/Fault/faultcode/text()");
                if (possibleFaultCode != null && possibleFaultCode.length > 0 && possibleFaultCode[0] != null
                        && !possibleFaultCode[0].trim().isEmpty()) {
                    String[] possibleFaultText;
                    String[] possibleFaultDetailCode;
                    possibleFaultText = xpathStr.parseXpathValues("//Envelope/Body/Fault/faultstring/text()");
                    possibleFaultDetailCode = xpathStr
                            .parseXpathValues("//Envelope/Body/Fault/detail/errorCode/text()");
                    if (possibleFaultText != null && possibleFaultText.length > 0
                            && possibleFaultDetailCode != null && possibleFaultDetailCode.length > 0
                            && possibleFaultText[0] != null && possibleFaultDetailCode[0] != null)
                        LOG.error("Error while requesting measurements from " + dcaDevId + ". Error Code: "
                                + possibleFaultCode[0] + " (" + possibleFaultDetailCode[0] + "). Error desc: "
                                + possibleFaultText[0]);
                    else
                        LOG.error("Error while requesting measurements from " + dcaDevId + ". Error Code: "
                                + possibleFaultCode[0] + ".");
                } else {
                    String[] capabilityArrStr;
                    String[] measurementArrStr;
                    String[] dateTSArrStr;
                    capabilityArrStr = xpathStr.parseXpathValues(
                            "//Envelope/Body/getDeviceDataResponse/measure/data/attribute/name/text()");
                    measurementArrStr = xpathStr.parseXpathValues(
                            "//Envelope/Body/getDeviceDataResponse/measure/data/attribute/value/text()");
                    dateTSArrStr = xpathStr
                            .parseXpathValues("//Envelope/Body/getDeviceDataResponse/measure/date/text()");
                    //DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ");

                    if (capabilityArrStr != null && measurementArrStr != null && dateTSArrStr != null
                            && capabilityArrStr.length > 0 && measurementArrStr.length > 0
                            && dateTSArrStr.length > 0 && capabilityArrStr[0] != null
                            && measurementArrStr[0] != null && dateTSArrStr[0] != null) {
                        //Date timestampDate = df.parse(dateTSArrStr[0]);
                        Date timestampDate = new Date();
                        Calendar calendar = javax.xml.bind.DatatypeConverter.parseDateTime(dateTSArrStr[0]);
                        timestampDate = calendar.getTime();
                        LOG.info("RECEIVED LAST MEASUREMENT FROM " + dcaDevId + ": " + capabilityArrStr[0]
                                + ":: " + measurementArrStr[0] + " :: at:: " + timestampDate.toString()
                                + "  \n--------------------------\n--------------------------\n\n");
                    } else {
                        LOG.error("Unexpected error while reading measurement received from " + dcaDevId + ".");
                    }
                }
                //dirtySensorMLForDevice=xpathStr.parseXpathValues("//Envelope/Body/Fault/faultcode/text()");
                //parse the right values (xpath), omit wrong/error answers, and produce an aggrResponseMessage+file for response!
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    } catch (Exception e) {
        LOG.info(e.getMessage());
        e.printStackTrace();
        System.out.println(e.getMessage());
    }
}

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

/**
 * @see org.kuali.rice.krad.service.PersistenceService#getForeignKeysForReference(java.lang.Class,
 *      java.lang.String) The Map structure is: Key(String fkFieldName) =>
 *      Value(String pkFieldName) NOTE that this implementation depends on
 *      the ordering of foreign-key elements in the ojb-repository matching
 *      the ordering of primary-key declarations of the class on the other
 *      side of the relationship. This is done because: 1. The current
 *      version of OJB requires you to declare all of these things in the
 *      correct (and matching) order in the ojb-repository file for it to
 *      work at all. 2. There is no other way to match a given foreign-key
 *      reference to its corresponding primary-key on the opposing side of
 *      the relationship. Yes, this is a crummy way to do it, but OJB doesnt
 *      provide explicit matches of foreign-keys to primary keys, and always
 *      assumes that foreign-keys map to primary keys on the other object,
 *      and never to a set of candidate keys, or any other column.
 *//* w ww.  j av a  2  s. c  o m*/

@Override
public Map getForeignKeysForReference(Class clazz, String attributeName) {
    // yelp if nulls were passed in
    if (clazz == null) {
        throw new IllegalArgumentException("The Class passed in for the clazz argument was null.");
    }
    if (attributeName == null) {
        throw new IllegalArgumentException("The String passed in for the attributeName argument was null.");
    }

    // get the class of the attribute name
    Class attributeClass = getBusinessObjectAttributeClass(clazz, attributeName);
    if (attributeClass == null) {
        throw new ReferenceAttributeDoesntExistException("Requested attribute: '" + attributeName
                + "' does not exist " + "on class: '" + clazz.getName() + "'.");
    }

    // make sure the class of the attribute descends from BusinessObject,
    // otherwise throw an exception
    if (!PersistableBusinessObject.class.isAssignableFrom(attributeClass)) {
        throw new ObjectNotABusinessObjectRuntimeException("Attribute requested (" + attributeName
                + ") is of class: " + "'" + attributeClass.getName() + "' and is not a "
                + "descendent of BusinessObject.  Only descendents of BusinessObject " + "can be used.");
    }

    Map fkMap = new HashMap();

    // make sure the attribute designated is listed as a
    // reference-descriptor on the clazz specified, otherwise
    // throw an exception (OJB);
    ClassDescriptor classDescriptor = getClassDescriptor(clazz);
    ObjectReferenceDescriptor referenceDescriptor = classDescriptor
            .getObjectReferenceDescriptorByName(attributeName);
    if (referenceDescriptor == null) {
        throw new ReferenceAttributeNotAnOjbReferenceException("Attribute requested (" + attributeName
                + ") is not listed " + "in OJB as a reference-descriptor for class: '" + clazz.getName() + "'");
    }

    // special case when the attributeClass passed in doesnt match the
    // class of the reference-descriptor as defined in ojb-repository.
    // Currently
    // the only case of this happening is ObjectCode vs.
    // ObjectCodeCurrent.
    if (!attributeClass.equals(referenceDescriptor.getItemClass())) {

        if (referenceConversionMap.containsKey(attributeClass)) {
            attributeClass = referenceConversionMap.get(attributeClass);
        } else {
            throw new RuntimeException("The Class of the Java member [" + attributeClass.getName() + "] '"
                    + attributeName + "' does not match the class of the " + "reference-descriptor ["
                    + referenceDescriptor.getItemClass().getName() + "]. "
                    + "This is an unhandled special case for which special code needs to be written "
                    + "in this class.");
        }
    }

    // get the list of the foreign-keys for this reference-descriptor
    // (OJB)
    Vector fkFields = referenceDescriptor.getForeignKeyFields();
    Iterator fkIterator = fkFields.iterator();

    // get the list of the corresponding pk fields on the other side of
    // the relationship
    List pkFields = getPrimaryKeys(attributeClass);
    Iterator pkIterator = pkFields.iterator();

    // make sure the size of the pkIterator is the same as the
    // size of the fkIterator, otherwise this whole thing is borked
    if (pkFields.size() != fkFields.size()) {
        throw new RuntimeException("KualiPersistenceStructureService Error: The number of "
                + "foreign keys doesnt match the number of primary keys.  This may be a "
                + "result of misconfigured OJB-repository files.");
    }

    // walk through the list of the foreign keys, get their types
    while (fkIterator.hasNext()) {
        // if there is a next FK but not a next PK, then we've got a big
        // problem,
        // and cannot continue
        if (!pkIterator.hasNext()) {
            throw new RuntimeException("The number of foriegn keys dont match the number of primary "
                    + "keys for the reference '" + attributeName + "', on BO of type '" + clazz.getName()
                    + "'.  "
                    + "This should never happen under normal circumstances, as it means that the OJB repository "
                    + "files are misconfigured.");
        }

        // get the field name of the fk & pk field
        String fkFieldName = (String) fkIterator.next();
        String pkFieldName = (String) pkIterator.next();

        // add the fieldName and fieldType to the map
        fkMap.put(fkFieldName, pkFieldName);
    }

    return fkMap;
}

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

/**
 * @see org.kuali.rice.krad.service.PersistenceService#getForeignKeyFieldsPopulationState(org.kuali.rice.krad.bo.BusinessObject,
 *      java.lang.String)//from w  w w. j  av a 2 s.  c  om
 */
@Override
public ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(PersistableBusinessObject bo,
        String referenceName) {
    boolean allFieldsPopulated = true;
    boolean anyFieldsPopulated = false;
    List<String> unpopulatedFields = new ArrayList<String>();

    // yelp if nulls were passed in
    if (bo == null) {
        throw new IllegalArgumentException("The Class passed in for the BusinessObject argument was null.");
    }
    if (StringUtils.isBlank(referenceName)) {
        throw new IllegalArgumentException(
                "The String passed in for the referenceName argument was null or empty.");
    }

    PropertyDescriptor propertyDescriptor = null;

    // make sure the attribute exists at all, throw exception if not
    try {
        propertyDescriptor = PropertyUtils.getPropertyDescriptor(bo, referenceName);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    if (propertyDescriptor == null) {
        throw new ReferenceAttributeDoesntExistException("Requested attribute: '" + referenceName
                + "' does not exist " + "on class: '" + bo.getClass().getName() + "'.");
    }

    // get the class of the attribute name
    Class referenceClass = propertyDescriptor.getPropertyType();

    // make sure the class of the attribute descends from BusinessObject,
    // otherwise throw an exception
    if (!PersistableBusinessObject.class.isAssignableFrom(referenceClass)) {
        throw new ObjectNotABusinessObjectRuntimeException("Attribute requested (" + referenceName
                + ") is of class: " + "'" + referenceClass.getName() + "' and is not a "
                + "descendent of BusinessObject.  Only descendents of BusinessObject " + "can be used.");
    }

    // make sure the attribute designated is listed as a
    // reference-descriptor
    // on the clazz specified, otherwise throw an exception (OJB);

    ClassDescriptor classDescriptor = getClassDescriptor(bo.getClass());

    // This block is a combination of legacy and jpa
    ObjectReferenceDescriptor referenceDescriptor = classDescriptor
            .getObjectReferenceDescriptorByName(referenceName);
    if (referenceDescriptor == null) {
        throw new ReferenceAttributeNotAnOjbReferenceException(
                "Attribute requested (" + referenceName + ") is not listed "
                        + "in OJB as a reference-descriptor for class: '" + bo.getClass().getName() + "'");
    }

    // get the list of the foreign-keys for this reference-descriptor
    Vector fkFieldsLegacy = referenceDescriptor.getForeignKeyFields();
    Iterator fkIteratorLegacy = fkFieldsLegacy.iterator();

    // walk through the list of the foreign keys, get their types
    while (fkIteratorLegacy.hasNext()) {

        // get the field name of the fk & pk field
        String fkFieldName = (String) fkIteratorLegacy.next();

        // get the value for the fk field
        Object fkFieldValue = null;
        try {
            fkFieldValue = PropertyUtils.getSimpleProperty(bo, fkFieldName);
        }

        // abort if the value is not retrievable
        catch (Exception e) {
            throw new RuntimeException(e);
        }

        // test the value
        if (fkFieldValue == null) {
            allFieldsPopulated = false;
            unpopulatedFields.add(fkFieldName);
        } else if (fkFieldValue instanceof String) {
            if (StringUtils.isBlank((String) fkFieldValue)) {
                allFieldsPopulated = false;
                unpopulatedFields.add(fkFieldName);
            } else {
                anyFieldsPopulated = true;
            }
        } else {
            anyFieldsPopulated = true;
        }
    }

    // sanity check. if the flag for all fields populated is set, then
    // there should be nothing in the unpopulatedFields list
    if (allFieldsPopulated) {
        if (!unpopulatedFields.isEmpty()) {
            throw new RuntimeException("The flag is set that indicates all fields are populated, but there "
                    + "are fields present in the unpopulatedFields list.  This should never happen, and indicates "
                    + "that the logic in this method is broken.");
        }
    }

    return new ForeignKeyFieldsPopulationState(allFieldsPopulated, anyFieldsPopulated, unpopulatedFields);
}

From source file:org.mwc.debrief.track_shift.views.StackedDotHelper.java

/**
 * sort out data of interest//  w  ww.  j a  va  2  s.c  o  m
 * 
 */
public static TreeSet<Doublet> getDoublets(final TrackWrapper sensorHost, final ISecondaryTrack targetTrack,
        final boolean onlyVis, final boolean needBearing, final boolean needFrequency) {
    final TreeSet<Doublet> res = new TreeSet<Doublet>();

    // friendly fix-wrapper to save us repeatedly creating it
    final FixWrapper index = new FixWrapper(new Fix(null, new WorldLocation(0, 0, 0), 0.0, 0.0));

    // loop through our sensor data
    final Enumeration<Editable> sensors = sensorHost.getSensors().elements();
    if (sensors != null) {
        while (sensors.hasMoreElements()) {
            final SensorWrapper wrapper = (SensorWrapper) sensors.nextElement();
            if (!onlyVis || (onlyVis && wrapper.getVisible())) {
                final Enumeration<Editable> cuts = wrapper.elements();
                while (cuts.hasMoreElements()) {
                    final SensorContactWrapper scw = (SensorContactWrapper) cuts.nextElement();
                    if (!onlyVis || (onlyVis && scw.getVisible())) {
                        // is this cut suitable for what we're looking for?
                        if (needBearing) {
                            if (!scw.getHasBearing())
                                continue;
                        }

                        // aaah, but does it meet the frequency requirement?
                        if (needFrequency) {
                            if (!scw.getHasFrequency())
                                continue;
                        }

                        FixWrapper targetFix = null;
                        TrackSegment targetParent = null;

                        if (targetTrack != null) {
                            // right, get the track segment and fix nearest to
                            // this
                            // DTG
                            final Enumeration<Editable> trkData = targetTrack.segments();
                            final Vector<TrackSegment> _theSegments = new Vector<TrackSegment>();

                            while (trkData.hasMoreElements()) {

                                final Editable thisI = trkData.nextElement();
                                if (thisI instanceof SegmentList) {
                                    final SegmentList thisList = (SegmentList) thisI;
                                    final Enumeration<Editable> theElements = thisList.elements();
                                    while (theElements.hasMoreElements()) {
                                        final TrackSegment ts = (TrackSegment) theElements.nextElement();
                                        _theSegments.add(ts);
                                    }

                                }
                                if (thisI instanceof TrackSegment) {
                                    final TrackSegment ts = (TrackSegment) thisI;
                                    _theSegments.add(ts);
                                }
                            }

                            if (_theSegments.size() > 0) {
                                final Iterator<TrackSegment> iter = _theSegments.iterator();
                                while (iter.hasNext()) {
                                    final TrackSegment ts = iter.next();

                                    final TimePeriod validPeriod = new TimePeriod.BaseTimePeriod(ts.startDTG(),
                                            ts.endDTG());
                                    if (validPeriod.contains(scw.getDTG())) {
                                        // sorted. here we go
                                        targetParent = ts;

                                        // create an object with the right time
                                        index.getFix().setTime(scw.getDTG());

                                        // and find any matching items
                                        final SortedSet<Editable> items = ts.tailSet(index);
                                        if (items.size() > 0) {
                                            targetFix = (FixWrapper) items.first();
                                        }
                                    }

                                }
                            }
                        }

                        final Watchable[] matches = sensorHost.getNearestTo(scw.getDTG());
                        if ((matches != null) && (matches.length > 0) && (targetFix != null)) {
                            final FixWrapper hostFix = (FixWrapper) matches[0];

                            final Doublet thisDub = new Doublet(scw, targetFix, targetParent, hostFix);

                            // if we've no target track add all the points
                            if (targetTrack == null) {
                                // store our data
                                res.add(thisDub);
                            } else {
                                // if we've got a target track we only add points
                                // for which we
                                // have
                                // a target location
                                if (targetFix != null) {
                                    // store our data
                                    res.add(thisDub);
                                }
                            } // if we know the track
                        } // if there are any matching items
                          // if we find a match
                    } // if cut is visible
                } // loop through cuts
            } // if sensor is visible
        } // loop through sensors
    } // if there are sensors

    return res;
}

From source file:org.apache.james.James.java

public Iterator getAttributeNames() {
    Vector names = new Vector();
    for (Enumeration e = attributes.keys(); e.hasMoreElements();) {
        names.add(e.nextElement());//from   www  . ja v a2 s.  c  om
    }
    return names.iterator();
}

From source file:org.mwc.debrief.track_shift.views.BaseStackedDotsView.java

protected void fillLocalToolBar(final IToolBarManager toolBarManager) {
    // fit to window
    toolBarManager.add(_autoResize);/*from w  w  w  . j a va2 s  . c  o m*/
    toolBarManager.add(_onlyVisible);
    toolBarManager.add(_showLinePlot);
    toolBarManager.add(_showDotPlot);
    // toolBarManager.add(_magicBtn);

    // and a separator
    toolBarManager.add(new Separator());

    final Vector<Action> actions = DragSegment.getDragModes();
    for (final Iterator<Action> iterator = actions.iterator(); iterator.hasNext();) {
        final Action action = iterator.next();
        toolBarManager.add(action);
    }
}

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

/**
 * The set of ontology names in the catalog
 * /*  ww  w  .j av a 2  s. co m*/
 *@return The set of names for ontologies
 */
public Iterator<String> getOntologyNames() {
    Vector<String> results = new Vector<String>();
    for (Iterator<NamedOntModel> iter = getNamedOntModels(); iter.hasNext();) {
        NamedOntModel m = iter.next();
        results.add(m.getName());
    }
    return results.iterator();
}

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

/**
 * The set of ontology names for use in the catalog
 * //from  ww w  .  j  a  v  a2s. c om
 *@return The libraryOntologyNames value
 */
public Iterator<String> getLibraryOntologyNames() {
    Vector<String> results = new Vector<String>();
    for (Iterator<NamedOntModel> iter = getLibraryNamedOntModels(); iter.hasNext();) {
        NamedOntModel m = iter.next();
        results.add(m.getName());
    }
    return results.iterator();
}

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

public Vector<?> getCreditTaxes() {
    Vector<CreditDetailTax> creditDetailTaxes = new Vector<CreditDetailTax>();
    Iterator<?> iterator = creditHeader.getCreditTaxes().iterator();
    while (iterator.hasNext()) {
        CreditDetailTax creditDetailTax = (CreditDetailTax) iterator.next();
        boolean found = false;
        Iterator<?> sumIterator = creditDetailTaxes.iterator();
        CreditDetailTax sumTax = null;//from  w ww .  j  a v a2s.  c o  m
        while (sumIterator.hasNext()) {
            sumTax = (CreditDetailTax) sumIterator.next();
            if (sumTax.getTaxName().equals(creditDetailTax.getTaxName())) {
                found = true;
                break;
            }
        }
        if (!found) {
            sumTax = new CreditDetailTax();
            sumTax.setTaxName(creditDetailTax.getTaxName());
            sumTax.setTaxAmount((float) 0);
            sumTax.setTax(creditDetailTax.getTax());
            creditDetailTaxes.add(sumTax);
        }
        float taxAmount = sumTax.getTaxAmount();
        taxAmount += creditDetailTax.getTaxAmount();
        sumTax.setTaxAmount(taxAmount);
    }
    return creditDetailTaxes;
}