java.util.Collection#iterator ( )源码实例Demo

下面列出了java.util.Collection#iterator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: coming   文件: Cardumen_0082_s.java
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
源代码2 项目: SimplifyReader   文件: CameraConfigurationUtils.java
private static String toString(Collection<int[]> arrays) {
    if (arrays == null || arrays.isEmpty()) {
        return "[]";
    }
    StringBuilder buffer = new StringBuilder();
    buffer.append('[');
    Iterator<int[]> it = arrays.iterator();
    while (it.hasNext()) {
        buffer.append(Arrays.toString(it.next()));
        if (it.hasNext()) {
            buffer.append(", ");
        }
    }
    buffer.append(']');
    return buffer.toString();
}
 
@Test
public void resolveDebugOff() throws Exception {
    defaultTemplateFilesResolver.setTemplatesLocation(new ClassPathResource("templates", getClass().getClassLoader()));
    defaultTemplateFilesResolver.setRecursive(false);
    final Collection<URL> urls = defaultTemplateFilesResolver.resolve();
    Assert.assertEquals("should resolve urls", 3, urls.size());
    final Iterator<URL> it = urls.iterator();
    final URL template1Url = it.next();
    final URL template2Url = it.next();
    final URL template3Url = it.next();
    Assert.assertTrue("template1Url file should end with template1.soy", template1Url.getFile().endsWith("template1.soy"));
    Assert.assertTrue("template2Url file should end with template2.soy", template2Url.getFile().endsWith("template2.soy"));
    Assert.assertTrue("template3Url file should end with template3.soy", template3Url.getFile().endsWith("template3.soy"));
}
 
源代码4 项目: datawave   文件: FileLatency.java
public static ArrayWritable makeWritable(Collection<?> writables, Class<? extends Writable> impl) {
    Writable[] array = new Writable[writables.size()];
    Iterator<?> writable = writables.iterator();
    for (int i = 0; i < array.length; ++i)
        array[i] = (Writable) writable.next();
    ArrayWritable arrayWritable = new ArrayWritable(impl);
    arrayWritable.set(array);
    return arrayWritable;
}
 
源代码5 项目: lams   文件: DefaultValueStyler.java
private String style(Collection<?> value) {
	StringBuilder result = new StringBuilder(value.size() * 8 + 16);
	result.append(getCollectionTypeString(value)).append('[');
	for (Iterator<?> i = value.iterator(); i.hasNext();) {
		result.append(style(i.next()));
		if (i.hasNext()) {
			result.append(',').append(' ');
		}
	}
	if (value.isEmpty()) {
		result.append(EMPTY);
	}
	result.append("]");
	return result.toString();
}
 
源代码6 项目: springreplugin   文件: ArraySet.java
/**
 * Determine if the array set contains all of the values in the given collection.
 *
 * @param collection The collection whose contents are to be checked against.
 * @return Returns true if this array set contains a value for every entry
 * in <var>collection</var>, else returns false.
 */
@Override
public boolean containsAll(Collection<?> collection) {
    Iterator<?> it = collection.iterator();
    while (it.hasNext()) {
        if (!contains(it.next())) {
            return false;
        }
    }
    return true;
}
 
源代码7 项目: ontopia   文件: ScopeUtils.java
/**
 * Checks to see if the ScopedIF's scope intersects with the user
 * context. Note that there is no intersection when either
 * collection is empty.<p>
 *
 * Note that the unconstrained scope is in this case considered an
 * empty set.<p>
 *
 * @param obj The ScopedIF object to compare with.
 * @param context The user context; a collection of TopicIFs.
 *
 * @return boolean; true if the scoped object's scope intersects
 * with the user context.
 */
public static boolean isIntersectionOfContext(ScopedIF obj,
                                              Collection<TopicIF> context) {
  // Get object scope
  Collection<TopicIF> objscope = obj.getScope();

  // Loop over context to see if there is an intersection with the object scope.
  Iterator<TopicIF> iter = context.iterator();
  while (iter.hasNext()) {
    // If object scope contains context theme then there is an intersection.
    if (objscope.contains(iter.next())) return true;
  }
  // There is no intersection with the object scope.
  return false;
}
 
源代码8 项目: crate   文件: Symbols.java
public static Streamer<?>[] streamerArray(Collection<? extends Symbol> symbols) {
    Streamer<?>[] streamers = new Streamer<?>[symbols.size()];
    Iterator<? extends Symbol> iter = symbols.iterator();
    for (int i = 0; i < symbols.size(); i++) {
        streamers[i] = iter.next().valueType().streamer();
    }
    return streamers;
}
 
源代码9 项目: kfs   文件: CustomerOpenItemReportServiceImpl.java
/**
 * This method populates CustomerOpenItemReportDetails for PaymentApplicationDocuments (Customer History Report).
 *
 * @param paymentApplicationIds <=> documentNumbers of PaymentApplicationDocuments
 * @param results <=> CustomerOpenItemReportDetails to display in the report
 * @param details <=> <key = documentNumber, value = customerOpenItemReportDetail>
 */
protected void populateReportDetailsForPaymentApplications(List paymentApplicationIds, List results, Hashtable details) throws WorkflowException {
    Collection paymentApplications = getDocuments(PaymentApplicationDocument.class, paymentApplicationIds);

    for (Iterator itr = paymentApplications.iterator(); itr.hasNext();) {
        PaymentApplicationDocument paymentApplication = (PaymentApplicationDocument) itr.next();
        String documentNumber = paymentApplication.getDocumentNumber();

        CustomerOpenItemReportDetail detail = (CustomerOpenItemReportDetail) details.get(documentNumber);

        // populate Document Description
        String documentDescription = paymentApplication.getDocumentHeader().getDocumentDescription();
        if (ObjectUtils.isNotNull(documentDescription)) {
            detail.setDocumentDescription(documentDescription);
        }
        else {
            detail.setDocumentDescription("");
        }

        // populate Document Payment Amount
        detail.setDocumentPaymentAmount(paymentApplication.getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount().negated());

        // populate Unpaid/Unapplied Amount if the customer number is the same
        if (ObjectUtils.isNotNull(paymentApplication.getNonAppliedHolding())) {
            if (paymentApplication.getNonAppliedHolding().getCustomerNumber().equals(paymentApplication.getAccountsReceivableDocumentHeader().getCustomerNumber())) {
                detail.setUnpaidUnappliedAmount(paymentApplication.getNonAppliedHolding().getAvailableUnappliedAmount().negated());
            } else {
                detail.setUnpaidUnappliedAmount(KualiDecimal.ZERO);
            }
        } else {
            detail.setUnpaidUnappliedAmount(KualiDecimal.ZERO);
        }

        results.add(detail);
    }
}
 
源代码10 项目: gate-core   文件: FieldInfos.java
/**
 * Assumes the field is not storing term vectors
 * @param names The names of the fields
 * @param isIndexed Whether the fields are indexed or not
 *
 * @see #add(String, boolean)
 */
public void add(Collection names, boolean isIndexed) {
  Iterator i = names.iterator();
  int j = 0;
  while (i.hasNext()) {
    add((String)i.next(), isIndexed);
  }
}
 
@Test
public void shouldPlaceBusinessRuleTask() {

  ProcessBuilder builder = Bpmn.createExecutableProcess();

  instance = builder
      .startEvent(START_EVENT_ID)
      .sequenceFlowId(SEQUENCE_FLOW_ID)
      .businessRuleTask(TASK_ID)
      .done();

  Bounds businessRuleTaskBounds = findBpmnShape(TASK_ID).getBounds();
  assertShapeCoordinates(businessRuleTaskBounds, 186, 78);

  Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
  Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();

  Waypoint waypoint = iterator.next();
  assertWaypointCoordinates(waypoint, 136, 118);

  while(iterator.hasNext()){
    waypoint = iterator.next();
  }

  assertWaypointCoordinates(waypoint, 186, 118);

}
 
源代码12 项目: ontopia   文件: SuperclassesTag.java
@Override
public Collection process(Collection topics) throws JspTagException {
  // find all superclasses of all topics in collection
  if (topics == null || topics.isEmpty())
    return Collections.EMPTY_SET;
  else {
    HashSet superclasses = new HashSet();
    Iterator iter = topics.iterator();
    TopicIF topic = null;
    Object obj = null;

    while (iter.hasNext()) {
      obj = iter.next();
      try {
        topic = (TopicIF)obj;
      } catch (ClassCastException e) {
        String msg = "SubclassesTag expected to get a input collection of " +
          "topic instances, " +
          "but got instance of class " + obj.getClass().getName();
        throw new NavigatorRuntimeException(msg);
      }

      // ok, the topic cast succeeded, now continue
      if (levelNumber == null)
        // if no level is specified get all of them.
        superclasses.addAll(hierUtils.getSuperclasses(topic));
      else 
        superclasses.addAll(hierUtils.getSuperclasses(topic, levelNumber.intValue()));

    } // while
    return superclasses;
  }
}
 
源代码13 项目: vjtools   文件: SortedArrayList.java
/**
 * Add all of the elements in the given collection to this list.
 */
@Override
public boolean addAll(Collection<? extends E> c) {
	Iterator<? extends E> i = c.iterator();
	boolean changed = false;
	while (i.hasNext()) {
		boolean ret = add(i.next());
		if (!changed) {
			changed = ret;
		}
	}
	return changed;
}
 
源代码14 项目: lapse-plus   文件: SourceView.java
public static boolean isSafeName(String identifier) {
Collection safes = XMLConfig.readSafes("safes.xml");
for(Iterator iter = safes.iterator(); iter.hasNext(); ){
	XMLConfig.SafeDescription safeDesc = (XMLConfig.SafeDescription) iter.next();
	if(safeDesc.getMethodName().equals(identifier)){
		return true;
	}
}
	
// none matched
return false;
  }
 
源代码15 项目: rya   文件: EventQueryNode.java
/**
 * Verify the Subject for all of the patterns is the same.
 *
 * @param patterns - The patterns to check.
 * @throws IllegalStateException If all of the Subjects are not the same.
 */
private static void verifySameSubjects(final Collection<StatementPattern> patterns) throws IllegalStateException {
    requireNonNull(patterns);

    final Iterator<StatementPattern> it = patterns.iterator();
    final Var subject = it.next().getSubjectVar();

    while(it.hasNext()) {
        final StatementPattern pattern = it.next();
        if(!pattern.getSubjectVar().equals(subject)) {
            throw new IllegalStateException("At least one of the patterns has a different subject from the others. " +
                    "All subjects must be the same.");
        }
    }
}
 
/**
 * Returns code/description pairs of all Purchase Order Vendor Choices.
 * 
 * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
 */
public List getKeyValues() {
    KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
    Collection codes = boService.findAll(PurchaseOrderVendorChoice.class);
    List labels = new ArrayList();
    labels.add(new ConcreteKeyValue(KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING));
    for (Iterator iter = codes.iterator(); iter.hasNext();) {
        PurchaseOrderVendorChoice povc = (PurchaseOrderVendorChoice) iter.next();
        labels.add(new ConcreteKeyValue(povc.getPurchaseOrderVendorChoiceCode(), povc.getPurchaseOrderVendorChoiceDescription()));
    }
    return labels;
}
 
源代码17 项目: Spark   文件: UserInvitationPane.java
/**
 * Removes oneself as an owner of the room.
 *
 * @param muc the <code>MultiUserChat</code> of the chat room.
 */
private void removeOwner(MultiUserChat muc) {
    if (muc.isJoined()) {
        // Try and remove myself as an owner if I am one.
        Collection<Affiliate> owners = null;
        try {
            owners = muc.getOwners();
        }
        catch (XMPPException | SmackException | InterruptedException e1) {
            return;
        }

        if (owners == null) {
            return;
        }

        Iterator<Affiliate> iter = owners.iterator();

        List<Jid> list = new ArrayList<>();
        while (iter.hasNext()) {
            Affiliate affilitate = iter.next();
            Jid jid = affilitate.getJid();
            if (!jid.equals(SparkManager.getSessionManager().getBareUserAddress())) {
                list.add(jid);
            }
        }
        if (list.size() > 0) {
            try {
                Form form = muc.getConfigurationForm().createAnswerForm();
                List<String> jidStrings = JidUtil.toStringList(list);
                form.setAnswer("muc#roomconfig_roomowners", jidStrings);

                // new DataFormDialog(groupChat, form);
                muc.sendConfigurationForm(form);
            }
            catch (XMPPException | SmackException | InterruptedException e) {
                Log.error(e);
            }
        }
    }
}
 
源代码18 项目: unitime   文件: CsvClassAssignmentExport.java
public static CSVFile exportCsv(UserContext user, Collection classes, ClassAssignmentProxy proxy) {
	CSVFile file = new CSVFile();
	String instructorFormat = user.getProperty(UserProperty.NameFormat);
	file.setSeparator(",");
	file.setQuotationMark("\"");
	file.setHeader(new CSVField[] {
			new CSVField("COURSE"),
			new CSVField("ITYPE"),
			new CSVField("SECTION"),
			new CSVField("SUFFIX"),
			new CSVField("EXTERNAL_ID"),
			new CSVField("ENROLLMENT"),
			new CSVField("LIMIT"),
			new CSVField("DATE_PATTERN"),
			new CSVField("DAY"),
			new CSVField("START_TIME"),
			new CSVField("END_TIME"),
			new CSVField("ROOM"),
			new CSVField("INSTRUCTOR"),
			new CSVField("SCHEDULE_NOTE")
		});
	
	for (Iterator i=classes.iterator();i.hasNext();) {
		Object[] o = (Object[])i.next(); Class_ clazz = (Class_)o[0]; CourseOffering co = (CourseOffering)o[1];
		StringBuffer leadsSb = new StringBuffer();
		if (clazz.isDisplayInstructor()) 
		for (ClassInstructor ci: clazz.getClassInstructors()) {
			if (!leadsSb.toString().isEmpty())
				leadsSb.append("\n");
			DepartmentalInstructor instructor = ci.getInstructor();
			leadsSb.append(instructor.getName(instructorFormat));
		}
           String divSec = clazz.getClassSuffix(co);
		Assignment assignment = null;
		try {
			assignment = proxy.getAssignment(clazz);
		} catch (Exception e) {
			Debug.error(e);
		}
		if (assignment!=null) {
			Placement placement = assignment.getPlacement();
			file.addLine(new CSVField[] {
					new CSVField(co.getCourseName()),
					new CSVField(clazz.getItypeDesc()),
					new CSVField(clazz.getSectionNumber()),
					new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()),
					new CSVField(divSec),
					new CSVField(clazz.getEnrollment()),
					new CSVField(clazz.getClassLimit(proxy)),
					new CSVField(assignment.getDatePattern().getName()),
					new CSVField(placement.getTimeLocation().getDayHeader()),
					new CSVField(placement.getTimeLocation().getStartTimeHeader(CONSTANTS.useAmPm())),
					new CSVField(placement.getTimeLocation().getEndTimeHeader(CONSTANTS.useAmPm())),
					new CSVField(placement.getRoomName(",")),
					new CSVField(leadsSb),
					new CSVField(clazz.getSchedulePrintNote()==null?"":clazz.getSchedulePrintNote())
			});
		} else {
			DurationModel dm = clazz.getSchedulingSubpart().getInstrOfferingConfig().getDurationModel();
               Integer arrHrs = dm.getArrangedHours(clazz.getSchedulingSubpart().getMinutesPerWk(), clazz.effectiveDatePattern());
			file.addLine(new CSVField[] {
					new CSVField(co.getCourseName()),
					new CSVField(clazz.getItypeDesc()),
					new CSVField(clazz.getSectionNumber()),
					new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()),
					new CSVField(divSec),
					new CSVField(clazz.getEnrollment()),
					new CSVField(clazz.getClassLimit(proxy)),
					new CSVField(clazz.effectiveDatePattern().getName()),
					new CSVField("Arr "+(arrHrs==null?"":arrHrs+" ")+"Hrs"),
					new CSVField(""),
					new CSVField(""),
					new CSVField(""),
					new CSVField(leadsSb),
					new CSVField(clazz.getSchedulePrintNote()==null?"":clazz.getSchedulePrintNote())
			});
		}
	}
	return file;
}
 
GenomePositionSelectorIteratorImpl(@NotNull Collection<P> positions) {
    this.positions = positions.iterator();
    next = this.positions.hasNext() ? this.positions.next() : null;
}
 
源代码20 项目: astor   文件: Validate.java
/**
 * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
 * if the argument collection  is <code>null</code> or has elements that
 * are not of type <code>clazz</code> or a subclass.</p>
 *
 * <pre>
 * Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
 * </pre>
 *
 * @param collection  the collection to check, not null
 * @param clazz  the <code>Class</code> which the collection's elements are expected to be, not null
 * @param message  the exception message if the <code>Collection</code> has elements not of type <code>clazz</code>
 * @since 2.1
 */
public static void allElementsOfType(Collection collection, Class clazz, String message) {
    Validate.notNull(collection);
    Validate.notNull(clazz);
    for (Iterator it = collection.iterator(); it.hasNext(); ) {
        if (clazz.isInstance(it.next()) == false) {
            throw new IllegalArgumentException(message);
        }
    }
}