Gets a source that joins the given iterator of sources end to end.
<p>
When closed, the returned source will ensure the wrapped sources are
all closed.

@param iterator the sources to join.
@param <T> the type.
@return the joined source.
543740
public static <T> Source<T> join(final Iterator<Source<T>> iterator) {
        return new AbstractSource<T>() {
            private Source<T> current = popSource();

            @Override
            public T computeNext() throws IOException {
                while (current != null) {
                    if (current.hasNext()) {
                        return current.next();
                    } else {
                        current.close();
                        current = popSource();
                    }
                }
                return endOfData();
            }

            @Override
            public void close() {
                while (current != null) {
                    current.close();
                    current = popSource();
                }
            }

            private Source<T> popSource() {
                if (iterator.hasNext()) {
                    return iterator.next();
                } else {
                    return null;
                }
            }
        };
    }
897178
public static String join(Iterable<?> iterable, String separator) {
		return Joiner.on(separator).join(iterable);
	}
741706
void addIterator(final DataStreamingEventIterator<E> iterator) {
        checkLocked();
        if (iterator == null) {
            throw new NullPointerException("Iterator must not be null");
        }
        iteratorChain.add(iterator);
    }
850094
public static <E> Iterator<E> get() {
		@SuppressWarnings("unchecked")
		Iterator<E> iter = (Iterator<E>) INSTANCE;
		return iter;
	}
76873
public static <T> Source<T> join(Collection<Source<T>> collection) {
        return join(collection.iterator());
    }
1192357
public static IntIteratorEx of(final Supplier<? extends IntIterator> iteratorSupplier) {
        N.checkArgNotNull(iteratorSupplier, "iteratorSupplier");

        return new IntIteratorEx() {
            private IntIterator iter = null;
            private IntIteratorEx iterEx = null;
            private boolean isInitialized = false;

            @Override
            public boolean hasNext() {
                if (isInitialized == false) {
                    init();
                }

                return iter.hasNext();
            }

            @Override
            public int nextInt() {
                if (isInitialized == false) {
                    init();
                }

                return iter.nextInt();
            }

            @Override
            public void skip(long n) {
                N.checkArgNotNegative(n, "n");

                if (isInitialized == false) {
                    init();
                }

                if (iterEx != null) {
                    iterEx.skip(n);
                } else {
                    super.skip(n);
                }
            }

            @Override
            public long count() {
                if (isInitialized == false) {
                    init();
                }

                if (iterEx != null) {
                    return iterEx.count();
                } else {
                    return super.count();
                }
            }

            @Override
            public void close() {
                if (isInitialized == false) {
                    init();
                }

                if (iterEx != null) {
                    iterEx.close();
                }
            }

            private void init() {
                if (isInitialized == false) {
                    isInitialized = true;
                    iter = iteratorSupplier.get();
                    iterEx = iter instanceof IntIteratorEx ? (IntIteratorEx) iter : null;
                }
            }
        };
    }
576338
public static Class<?> getElementType(Iterator<?> iterator) {
		final Iterator<?> iter2 = new CopiedIter<>(iterator);
		if (null != iter2) {
			Object t;
			while (iter2.hasNext()) {
				t = iter2.next();
				if (null != t) {
					return t.getClass();
				}
			}
		}
		return null;
	}
913789
public static LongIterator of(final Supplier<? extends LongIterator> iteratorSupplier) {
        N.checkArgNotNull(iteratorSupplier, "iteratorSupplier");

        return new LongIterator() {
            private LongIterator iter = null;
            private boolean isInitialized = false;

            @Override
            public boolean hasNext() {
                if (isInitialized == false) {
                    init();
                }

                return iter.hasNext();
            }

            @Override
            public long nextLong() {
                if (isInitialized == false) {
                    init();
                }

                return iter.nextLong();
            }

            private void init() {
                if (isInitialized == false) {
                    isInitialized = true;
                    iter = iteratorSupplier.get();
                }
            }
        };
    }
276587
public static <T> Stream<T> iteratorToStream(final Iterator<T> iterator) {
        return iteratorToStream(iterator, enableParallel);
    }
491337
public static <E> Collector<E, List<E>, String> join(Joiner joiner) {
    requireNonNull(joiner, "Joiner can't be null");

    return Collector.of(
      ArrayList::new,
      List::add,
      mergeNotSupportedMerger(),
      joiner::join);
  }
201935
@ReplacedBy("com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()")
    public static <T> Iterator<T> getMetaIterator (Iterable<Iterator<T>> metaIterable)
    {
        return new MetaIterator<T>(metaIterable);
    }
315862
public static <T> String join(final Iterable<T> iterable, final String separator) {
        final StringBuilder sb = new StringBuilder();
        int index = 0;
        for (final T item : iterable) {
            if (index > 0) {
                sb.append(separator);
            }
            sb.append(item.toString());
            index += 1;
        }
        return sb.toString();
    }
97632
public Iterator iterator()
   {
      if (tc.isEntryEnabled()) SibTr.entry(tc, "iterator");
      if (tc.isEntryEnabled()) SibTr.exit(tc, "iterator");

      return map.values().iterator();
   }
240831
public static <E> Iterable<E> asIterable(final Iterator<E> iter) {
		return IterUtil.asIterable(iter);
	}
886981
public java.util.Iterator iterator() {
        // TODO Bug in remove from a concurrentSet/Map iterator, it does not actually do the remove!
        java.util.Set combinedSet = new java.util.HashSet();
        if (subSets != null) {
            for (int i = 0; i < subSets.length; i++) {
                synchronized (subSets[i]) {
                    combinedSet.addAll(subSets[i]);
                } // synchronized (subSet).
            }
        }
        return combinedSet.iterator();
    }
303329
public Iterator<Record> getSource()
    {
        String strURL = this.getProperty("source");
        if (strURL == null)
            return null;
        
        Reader reader = null;
        try {
            URL url = new URL(strURL);
            InputStream inputStream = url.openStream();
            InputStreamReader inStream = new InputStreamReader(inputStream);
            reader = inStream;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        Record record = this.getMergeRecord();
        SaxHtmlHandler handler = this.getSaxHandler(record);
        return new HtmlSource(reader, record, handler);
    }
626951
public SIMPIterator getTopicNameIterator()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getTopicNameIterator");
    //if the stream is flushed then we have not subscribed
    //to any topics, so we return an empty list
    List topicList = null;
    if(_anycastInputHandler.getAIStream()!=null)
    {
      String[] topics =
            _anycastInputHandler.getRCD().getConsumerDispatcherState().getTopics();
       topicList = Arrays.asList(topics);
    }
    else
    {
      //we are flushed, so we are not currently subscribing for any
      //topics
      topicList = new LinkedList(); //create an empty collection
    }
    
    BasicSIMPIterator iterator = new BasicSIMPIterator(topicList.iterator());
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getTopicNameIterator", iterator);
    return iterator;                                   
  }