Пример #1
0
 /**
  * Chunks a list of items into sublists where each sublist contains at most the specified maximum
  * number of items.
  *
  * @param ts The list of elements to chunk
  * @param chunkSize The maximum number of elements per sublist
  * @return A list of sublists, where each sublist has chunkSize or fewer elements and all elements
  *     from ts are present, in order, in some sublist
  */
 private static <T> List<List<T>> chunkList(List<? extends T> ts, int chunkSize) {
   Iterator<? extends T> iterator = ts.iterator();
   List<List<T>> returnList = new LinkedList<List<T>>();
   while (iterator.hasNext()) {
     List<T> sublist = new LinkedList<T>();
     for (int i = 0; i < chunkSize && iterator.hasNext(); i++) {
       sublist.add(iterator.next());
     }
     returnList.add(sublist);
   }
   return returnList;
 }
Пример #2
0
 public String next() {
   ListEntry listEntry = entries.next();
   StringBuffer line = new StringBuffer();
   for (String tag : listEntry.getCustomElements().getTags()) {
     line.append("\"").append(listEntry.getCustomElements().getValue(tag)).append("\"");
     line.append(",");
   }
   if (line.length() > 0) {
     line.deleteCharAt(line.length() - 1);
   }
   return line.toString();
 }
Пример #3
0
 public boolean hasNext() {
   return entries.hasNext();
 }