Example usage for org.apache.commons.collections4.iterators EnumerationIterator EnumerationIterator

List of usage examples for org.apache.commons.collections4.iterators EnumerationIterator EnumerationIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections4.iterators EnumerationIterator EnumerationIterator.

Prototype

public EnumerationIterator(final Enumeration<? extends E> enumeration) 

Source Link

Document

Constructs a new EnumerationIterator that provides an iterator view of the given enumeration.

Usage

From source file:de.micromata.genome.gwiki.web.tags.GWikiHtmlOptionsCollectionTag.java

@SuppressWarnings({ "unchecked", "rawtypes" })
protected Iterator<?> getIterator(Object collection) throws JspException {
    Class<?> clcls = collection.getClass();
    if (clcls.isArray()) {
        collection = Arrays.asList((Object[]) collection);
    }//  w ww  .j a va  2s.  co m

    if (collection instanceof Collection) {
        return (((Collection<?>) collection).iterator());

    } else if (collection instanceof Iterator) {
        return ((Iterator<?>) collection);

    } else if (collection instanceof Map) {
        return (((Map<?, ?>) collection).entrySet().iterator());

    } else if (collection instanceof Enumeration) {
        return new EnumerationIterator((Enumeration<?>) collection);

    } else {
        throw new JspException("form." + property + " does not return a valid collection");
    }
}

From source file:com.feilong.core.util.EnumerationUtil.java

/**
 * <code>enumeration</code>?,?<code>value</code>.
 *
 * @param <O>//  w  w  w . ja v  a2 s.c  om
 *            the generic type
 * @param enumeration
 *            the enumeration
 * @param value
 *            
 * @return  <code>enumeration</code> nullempty, false<br>
 *         ? contains true,<br>
 *         false
 * @see "org.springframework.util.CollectionUtils#contains(Enumeration, Object)"
 * @see org.apache.commons.collections4.iterators.EnumerationIterator
 * @see org.apache.commons.collections4.IteratorUtils#contains(java.util.Iterator, Object)
 */
public static <O> boolean contains(Enumeration<O> enumeration, O value) {
    return isNullOrEmpty(enumeration) ? false
            : IteratorUtils.contains(new EnumerationIterator<O>(enumeration), value);
}

From source file:com.garethahealy.elasticpostman.scraper.entities.EmailContent.java

public void parse() throws Exception {
    Session session = Session.getDefaultInstance(new Properties());
    MimeMessage message = MimeMessageUtils.createMimeMessage(session, raw);
    MimeMessageParser mimeMessageParser = new MimeMessageParser(message);
    MimeMessageParser parsed = mimeMessageParser.parse();

    this.from = parsed.getFrom();
    this.subject = parsed.getSubject();
    this.content = parsed.getPlainContent();
    this.contentIds = parsed.getContentIds();
    this.sentDate = new DateTime(parsed.getMimeMessage().getSentDate());
    this.headers = new HashMap<String, String>();

    @SuppressWarnings("unchecked")
    EnumerationIterator it = new EnumerationIterator(parsed.getMimeMessage().getAllHeaders());
    while (it.hasNext()) {
        Object current = it.next();
        if (current instanceof Header) {
            Header header = (Header) current;
            if (includeHeader(header.getName())) {
                headers.put(header.getName(), sanatizeValue(header.getName(), header.getValue()));
            }//from w  ww  . j av a 2 s  . c  om
        }
    }

}

From source file:org.apache.bcel.BCELBenchmark.java

private Iterable<JarEntry> getClasses(JarFile jar) {
    return new IteratorIterable<>(
            new FilterIterator<>(new EnumerationIterator<>(jar.entries()), new Predicate<JarEntry>() {
                @Override/*from  w  w  w.j  a v  a 2s . c  o m*/
                public boolean evaluate(JarEntry entry) {
                    return entry.getName().endsWith(".class");
                }
            }));
}