Example usage for org.apache.commons.collections IteratorUtils filteredIterator

List of usage examples for org.apache.commons.collections IteratorUtils filteredIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections IteratorUtils filteredIterator.

Prototype

public static Iterator filteredIterator(Iterator iterator, Predicate predicate) 

Source Link

Document

Gets an iterator that filters another iterator.

Usage

From source file:nl.strohalm.cyclos.controls.reports.members.transactions.ExportMembersTransactionsReportToCsvAction.java

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<?> executeQuery(final ActionContext context) {
    final MembersReportHandler reportHandler = getReportHandler();
    final Pair<MembersTransactionsReportDTO, Iterator<MemberTransactionSummaryReportData>> pair = reportHandler
            .handleTransactionsSummary(context);
    final MembersTransactionsReportDTO dto = pair.getFirst();
    final Iterator<MemberTransactionSummaryReportData> reportIterator = pair.getSecond();
    final Iterator iterator = IteratorUtils.filteredIterator(reportIterator, new Predicate() {
        @Override//from   www . j  a  v a2  s. c o m
        public boolean evaluate(final Object element) {
            final MemberTransactionSummaryReportData data = (MemberTransactionSummaryReportData) element;
            if (dto.isIncludeNoTraders()) {
                return true;
            }
            return data.isHasData();
        }
    });
    return new IteratorListImpl(iterator);
}

From source file:org.apache.cayenne.ashwood.graph.FilterIteration.java

public Iterator<E> vertexIterator() {
    return IteratorUtils.filteredIterator(digraph.vertexIterator(), acceptVertex);
}

From source file:org.apache.stanbol.enhancer.nlp.model.impl.SectionImpl.java

@Override
@SuppressWarnings("unchecked")
public Iterator<Span> getEnclosed(final Set<SpanTypeEnum> types) {
    return IteratorUtils.filteredIterator(getIterator(), new Predicate() {
        @Override//  w w w .  j av  a  2s .com
        public boolean evaluate(Object span) {
            return types.contains(((Span) span).getType());
        }
    });
}

From source file:org.apache.stanbol.enhancer.nlp.model.impl.SectionImpl.java

@Override
@SuppressWarnings("unchecked")
public Iterator<Span> getEnclosed(final Set<SpanTypeEnum> types, int startOffset, int endOffset) {
    if (startOffset >= (span[1] - span[0])) { //start is outside the span
        return Collections.<Span>emptySet().iterator();
    }// ww  w. j a v  a2 s  . co m
    int startIdx = startOffset < 0 ? span[0] : (span[0] + startOffset);
    int endIdx = span[0] + endOffset;
    if (endIdx <= startIdx) {
        return Collections.<Span>emptySet().iterator();
    } else if (endIdx > span[1]) {
        endIdx = span[1];
    }
    return IteratorUtils.filteredIterator(getIterator(new SubSetHelperSpan(startIdx, endIdx)), new Predicate() {
        @Override
        public boolean evaluate(Object span) {
            return types.contains(((Span) span).getType());
        }
    });
}

From source file:org.apache.stanbol.enhancer.nlp.model.impl.SectionImpl.java

/**
 * Internal helper to generate correctly generic typed {@link Iterator}s for
 * filtered {@link Span} types/* www  . j  a v  a2  s. c  o m*/
 * @param interfaze the Span interface e.g. {@link Token}
 * @param clazz the actual Span implementation e.g. {@link TokenImpl}
 * @return the {@link Iterator} of type {interface} iterating over 
 * {implementation} instances (e.g. 
 * <code>{@link Iterator}&lt;{@link Token}&gt;</code> returning 
 * <code>{@link TokenImpl}</code> instances on calls to {@link Iterator#next()}
 */
@SuppressWarnings("unchecked")
protected <T extends Span> Iterator<T> filter(final Class<T> clazz) {
    return IteratorUtils.filteredIterator(getIterator(), new InstanceofPredicate(clazz));
}

From source file:org.jbpm.bpel.xml.util.XmlUtil.java

/**
 * Gets an iterator over the child elements of the given node with the specified namespace URI and
 * any local name.// w  w w .ja v a2 s . com
 * @param parent the parent node to iterate
 * @param namespaceURI the namespace URI of the desired child elements; if <code>null</code>,
 * only elements with a <code>null</code> or empty namespace URI will be iterated
 * @return an {@link Element} iterator, empty if there is no match
 */
public static Iterator getElements(Node parent, String namespaceURI) {
    return IteratorUtils.filteredIterator(new NodeIterator(parent),
            new NamespaceElementPredicate(namespaceURI));
}

From source file:org.jbpm.bpel.xml.util.XmlUtil.java

/**
 * Gets an iterator over the child elements of the given node with the specified namespace URI and
 * local name./*ww w  .j  av a2  s  .c o  m*/
 * @param parent the parent node to iterate
 * @param namespaceURI the namespace URI of the desired child elements; if <code>null</code>,
 * only elements with a <code>null</code> or empty namespace URI will be iterated
 * @param localName the local name of the desired child elements
 * @return an {@link Element} iterator, empty if there is no match
 */
public static Iterator getElements(Node parent, String namespaceURI, String localName) {
    return IteratorUtils.filteredIterator(new NodeIterator(parent),
            new QualifiedNameElementPredicate(namespaceURI, localName));
}

From source file:org.jbpm.bpel.xml.util.XmlUtil.java

/**
 * Gets an iterator over the child elements of the given node.
 * @param parent the parent node to iterate
 * @return an {@link Element} iterator, empty if there is no match
 *//*from  ww  w.j av a  2 s . c  o  m*/
public static Iterator getElements(Node parent) {
    return IteratorUtils.filteredIterator(new NodeIterator(parent), ElementPredicate.INSTANCE);
}

From source file:org.jbpm.util.XmlUtil.java

public static Iterator elementIterator(Element element, final String tagName) {
    return IteratorUtils.filteredIterator(new NodeIterator(element), new Predicate() {
        public boolean evaluate(Object arg) {
            Node node = (Node) arg;
            return tagName.equals(node.getNodeName());
        }/*  w  w w. j  ava2  s  .  c o m*/
    });
}

From source file:org.jbpm.util.XmlUtil.java

public static Iterator elementIterator(Element element) {
    return IteratorUtils.filteredIterator(new NodeIterator(element), ElementPredicate.INSTANCE);
}