JDOM2
0.0.2-BETA

org.jdom2.filter
Interface Filter<T>

Type Parameters:
T - The Generic type of content returned by this Filter
All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AttributeFilter, ContentFilter, ElementFilter

public interface Filter<T>
extends java.io.Serializable

A generalized filter to restrict visibility or mutability on a list.

Author:
Jools Enticknap, Bradley S. Huffman

Method Summary
 Filter<?> and(Filter<?> filter)
          Creates an ANDing filter
 java.util.List<T> filter(java.util.List<?> content)
          Filter the input list of all content except that which matches the Filter.
 T filter(java.lang.Object content)
          Check to see if the content matches this Filter.
 boolean matches(java.lang.Object content)
          Check to see if the object matches a predefined set of rules.
 Filter<? extends java.lang.Object> negate()
          Creates an 'inverse' filter
 Filter<? extends java.lang.Object> or(Filter<?> filter)
          Creates an ORing filter
<R> Filter<R>
refine(Filter<R> filter)
          This is similar to the and(Filter) method except the generic type is different.
 

Method Detail

filter

java.util.List<T> filter(java.util.List<?> content)
Filter the input list of all content except that which matches the Filter.

Parameters:
content - The content to filter.
Returns:
a new read-only RandomAccess list of the filtered input content.

filter

T filter(java.lang.Object content)
Check to see if the content matches this Filter. If it does, return the content cast as this filter's return type, otherwise return null.

Parameters:
content - The content to test.
Returns:
The content if it matches the filter, cast as this Filter's type.

matches

boolean matches(java.lang.Object content)
Check to see if the object matches a predefined set of rules.

Parameters:
content - The object to verify.
Returns:
true if the object matches a predfined set of rules.

negate

Filter<? extends java.lang.Object> negate()
Creates an 'inverse' filter

Returns:
a Filter that returns all content except what this Filter instance would.

or

Filter<? extends java.lang.Object> or(Filter<?> filter)
Creates an ORing filter

Parameters:
filter - a second Filter to OR with.
Returns:
a new Filter instance that returns the 'union' of this filter and the specified filter.

and

Filter<?> and(Filter<?> filter)
Creates an ANDing filter

Parameters:
filter - a second Filter to AND with.
Returns:
a new Filter instance that returns the 'intersection' of this filter and the specified filter.

refine

<R> Filter<R> refine(Filter<R> filter)
This is similar to the and(Filter) method except the generic type is different.

Type Parameters:
R - The Generic type of the retuned data is taken from the input instance.
Parameters:
filter - The filter to refine our results with.
Returns:
A Filter that requires content to both match our instance and the refining instance, but the generic type of the retuned data is based on the refining instance, not this instance.

JDOM2
0.0.2-BETA

Copyright � 2011 Jason Hunter, Brett McLaughlin. All Rights Reserved.