com.jayway.jsonpath
Class Filter<T>

java.lang.Object
  extended by com.jayway.jsonpath.Filter<T>
Direct Known Subclasses:
Filter.FilterAdapter

public abstract class Filter<T>
extends Object

A filter is used to filter the content of a JSON array in a JSONPath. Sample String doc = {"items": [{"name" : "john"}, {"name": "bob"}]} List names = JsonPath.read(doc, "$items[?].name", Filter.filter(Criteria.where("name").is("john"));

Author:
Kalle Stenflo
See Also:
Criteria

Nested Class Summary
static class Filter.FilterAdapter<T>
           
 
Constructor Summary
Filter()
           
 
Method Summary
abstract  boolean accept(T obj)
          Check if this filter will accept or reject the given object
abstract  Filter addCriteria(Criteria criteria)
          Adds a new criteria to this filter
 List<T> doFilter(List<T> filterItems)
          Filters the provided list based on this filter configuration
static Filter filter(Criteria criteria)
          Creates a new filter based on given criteria
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()
Method Detail

filter

public static Filter filter(Criteria criteria)
Creates a new filter based on given criteria

Parameters:
criteria - the filter criteria
Returns:
a new filter

doFilter

public List<T> doFilter(List<T> filterItems)
Filters the provided list based on this filter configuration

Parameters:
filterItems - items to filter
Returns:
the filtered list

accept

public abstract boolean accept(T obj)
Check if this filter will accept or reject the given object

Parameters:
obj - item to check
Returns:
true if filter matches

addCriteria

public abstract Filter addCriteria(Criteria criteria)
Adds a new criteria to this filter

Parameters:
criteria - to add
Returns:
the updated filter


Copyright © 2011-2012. All Rights Reserved.