JDOM2
0.0.2-BETA

org.jdom2.filter
Class ElementFilter

java.lang.Object
  extended by org.jdom2.filter.ElementFilter
All Implemented Interfaces:
java.io.Serializable, Filter<Element>

public class ElementFilter
extends java.lang.Object

A Filter that only matches Element objects.

Author:
Jools Enticknap, Bradley S. Huffman
See Also:
Serialized Form

Constructor Summary
ElementFilter()
          Select only the Elements.
ElementFilter(Namespace namespace)
          Select only the Elements with the supplied Namespace.
ElementFilter(java.lang.String name)
          Select only the Elements with the supplied name in any Namespace.
ElementFilter(java.lang.String name, Namespace namespace)
          Select only the Elements with the supplied name and Namespace.
 
Method Summary
 Filter<?> and(Filter<?> filter)
          Creates an ANDing filter
 boolean equals(java.lang.Object obj)
          Returns whether the two filters are equivalent (i.e. the matching names and namespace are equivalent).
 java.util.List<T> filter(java.util.List<?> content)
          Filter the input list of all content except that which matches the Filter.
 Element filter(java.lang.Object content)
          Check to see if the object matches a predefined set of rules.
 int hashCode()
           
 boolean matches(java.lang.Object content)
          Check to see if the object matches a predefined set of rules.
 Filter<?> negate()
          Creates an 'inverse' filter
 Filter<? extends Content> 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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ElementFilter

public ElementFilter()
Select only the Elements.


ElementFilter

public ElementFilter(java.lang.String name)
Select only the Elements with the supplied name in any Namespace.

Parameters:
name - The name of the Element.

ElementFilter

public ElementFilter(Namespace namespace)
Select only the Elements with the supplied Namespace.

Parameters:
namespace - The namespace the Element lives in.

ElementFilter

public ElementFilter(java.lang.String name,
                     Namespace namespace)
Select only the Elements with the supplied name and Namespace.

Parameters:
name - The name of the Element.
namespace - The namespace the Element lives in.
Method Detail

filter

public Element filter(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 objected matched a predfined set of rules.

equals

public boolean equals(java.lang.Object obj)
Returns whether the two filters are equivalent (i.e. the matching names and namespace are equivalent).

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare against
Returns:
whether the two filters are equal

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

matches

public final boolean matches(java.lang.Object content)
Description copied from interface: Filter
Check to see if the object matches a predefined set of rules.

Specified by:
matches in interface Filter<T>
Parameters:
content - The object to verify.
Returns:
true if the object matches a predfined set of rules.

filter

public java.util.List<T> filter(java.util.List<?> content)
Description copied from interface: Filter
Filter the input list of all content except that which matches the Filter.

Specified by:
filter in interface Filter<T>
Parameters:
content - The content to filter.
Returns:
a new read-only RandomAccess list of the filtered input content.

negate

public final Filter<?> negate()
Description copied from interface: Filter
Creates an 'inverse' filter

Specified by:
negate in interface Filter<T>
Returns:
a Filter that returns all content except what this Filter instance would.

or

public final Filter<? extends Content> or(Filter<?> filter)
Description copied from interface: Filter
Creates an ORing filter

Specified by:
or in interface Filter<T>
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

public final Filter<?> and(Filter<?> filter)
Description copied from interface: Filter
Creates an ANDing filter

Specified by:
and in interface Filter<T>
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

public <R> Filter<R> refine(Filter<R> filter)
Description copied from interface: Filter
This is similar to the and(Filter) method except the generic type is different.

Specified by:
refine in interface Filter<T>
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.