Package eu.bitfish.jcf.common.expression

Examples of eu.bitfish.jcf.common.expression.AbstractExpression


  }

  @Override
  public <T> List<T> execute(final Collection<T> collection,
      final String query) throws ParsingException, FilterException {
    AbstractExpression ex = getParser().parse(query);

    // TODO allow all whitespaces in value!!!

    final List<T> filtered = new ArrayList<>();
    for (T obj : collection) {
      if (ex.evaluate(obj)) {
        filtered.add(obj);

        // if the order is set we have to add all items before limiting
        // the result
        if (ex.getLimit() != -1 && ex.getOrder() == null
            && ex.getLimit() == filtered.size()) {
          break;
        }
      }
    }

    if (ex.getOrder() != null) {
      Collections.sort(filtered, ex.getOrder());

      if (ex.getLimit() != -1) {
        return filtered.subList(0, ex.getLimit());
      }
    }

    return filtered;
  }
View Full Code Here

TOP

Related Classes of eu.bitfish.jcf.common.expression.AbstractExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.