org.apache.commons.collections.iterators.TransformIterator Java Examples

The following examples show how to use org.apache.commons.collections.iterators.TransformIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XJoinQParserPlugin.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Query parse() throws SyntaxError {
  Method method = Method.valueOf(localParams.get(METHOD, Method.termsFilter.name()));
  JoinSpec<T> js = JoinSpec.parse(localParams.get(QueryParsing.V));
  Iterator<T> it = js.iterator(this);
  if (joinField == null) {
    throw new Exception("No XJoin component referenced by query");
  }
  FieldType ft = req.getSchema().getFieldTypeNoEx(joinField);
  Iterator<BytesRef> bytesRefs = new TransformIterator(it, transformer(ft));
  if (! bytesRefs.hasNext()) {
    return new BooleanQuery.Builder().build(); // matches nothing
  }
  Query query = method.makeQuery(joinField, bytesRefs);
  return new SolrConstantScoreQuery(new QueryWrapperFilter(query));
}
 
Example #2
Source File: XJoinQParserPlugin.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Query parse() throws SyntaxError {
  Method method = Method.valueOf(localParams.get(METHOD, Method.termsFilter.name()));
  JoinSpec<T> js = JoinSpec.parse(localParams.get(QueryParsing.V));
  Iterator<T> it = js.iterator(this);
  if (joinField == null) {
    throw new Exception("No XJoin component referenced by query");
  }
  FieldType ft = req.getSchema().getFieldTypeNoEx(joinField);
  Iterator<BytesRef> bytesRefs = new TransformIterator(it, transformer(ft));
  if (! bytesRefs.hasNext()) {
    return new BooleanQuery.Builder().build(); // matches nothing
  }
  Query query = method.makeQuery(joinField, bytesRefs);
  return new SolrConstantScoreQuery(new QueryWrapperFilter(query));
}
 
Example #3
Source File: XJoinQParserPlugin.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Query parse() throws SyntaxError {
  Method method = Method.valueOf(localParams.get(METHOD, Method.termsFilter.name()));
  JoinSpec<T> js = JoinSpec.parse(localParams.get(QueryParsing.V));
  Iterator<T> it = js.iterator(this);
  if (joinField == null) {
    throw new Exception("No XJoin component referenced by query");
  }
  FieldType ft = req.getSchema().getFieldTypeNoEx(joinField);
  Iterator<BytesRef> bytesRefs = new TransformIterator(it, transformer(ft));
  if (! bytesRefs.hasNext()) {
    return new BooleanQuery(); // matches nothing
  }
  return new SolrConstantScoreQuery(method.makeFilter(joinField, bytesRefs));
}
 
Example #4
Source File: ChildrenDataSourceServlet.java    From commerce-cif-connector with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Iterator<Resource> listChildren() {
    return new TransformIterator(new FilterIterator(super.listChildren(), predicate), o -> new PredicatedResourceWrapper(
        (Resource) o, predicate));
}
 
Example #5
Source File: IteratorUtils.java    From Penetration_Testing_POC with Apache License 2.0 3 votes vote down vote up
/**
 * Gets an iterator that transforms the elements of another iterator.
 * <p>
 * The transformation occurs during the next() method and the underlying
 * iterator is unaffected by the transformation.
 *
 * @param iterator  the iterator to use, not null
 * @param transform  the transform to use, not null
 * @return a new transforming iterator
 * @throws NullPointerException if either parameter is null
 */
public static Iterator transformedIterator(Iterator iterator, Transformer transform) {
    if (iterator == null) {
        throw new NullPointerException("Iterator must not be null");
    }
    if (transform == null) {
        throw new NullPointerException("Transformer must not be null");
    }
    return new TransformIterator(iterator, transform);
}