de.fu_berlin.ties.xml.dom
Class ElementNameFilter

java.lang.Object
  extended by de.fu_berlin.ties.xml.dom.ElementNameFilter
All Implemented Interfaces:
NodeFilter

public class ElementNameFilter
extends Object
implements NodeFilter

A node filter that only accepts elements with a specified name.

Version:
$Revision: 1.5 $, $Date: 2004/09/07 10:02:00 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
ElementNameFilter(List<String> nameList)
          Creates a new instance.
ElementNameFilter(Set<String> nameSet)
          Creates a new instance.
ElementNameFilter(String elementName)
          Creates a new instance that accepts only elements of a single type.
ElementNameFilter(String[] nameArray)
          Creates a new instance.
 
Method Summary
 Set getNames()
          Returns the set of element names accepted by this filter.
 boolean matches(Node node)
          Tests whether a node is accected by this filter.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ElementNameFilter

public ElementNameFilter(Set<String> nameSet)
Creates a new instance.

Parameters:
nameSet - set of element name strings to accept, format must be compatible to DOMUtils.name(Element)

ElementNameFilter

public ElementNameFilter(List<String> nameList)
Creates a new instance.

Parameters:
nameList - array of element name strings to accept, format must be compatible to DOMUtils.name(Element)

ElementNameFilter

public ElementNameFilter(String[] nameArray)
Creates a new instance.

Parameters:
nameArray - array of element name strings to accept, format must be compatible to DOMUtils.name(Element)

ElementNameFilter

public ElementNameFilter(String elementName)
Creates a new instance that accepts only elements of a single type.

Parameters:
elementName - Only elements with this name are accepted, format must be compatible to DOMUtils.name(Element)
Method Detail

getNames

public Set getNames()
Returns the set of element names accepted by this filter.

Returns:
an immutable set containing the element names (Strings) accepted by this filter

matches

public boolean matches(Node node)
Tests whether a node is accected by this filter. To match a node must fulfill two conditions: (a) it must be an Element and (b) getNames() must contain the name of the element as returned by DOMUtils.name(Element).

Specified by:
matches in interface NodeFilter
Parameters:
node - the node to test
Returns:
true iff this filter matches the given node

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.