com.raritantechnologies.xml.sax.filter.comparators
Class TagListComparator

java.lang.Object
  extended bycom.raritantechnologies.xml.sax.filter.comparators.TagListComparator
All Implemented Interfaces:
ElementComparator

public class TagListComparator
extends java.lang.Object
implements ElementComparator

Implementation of ElementComparator which compares a tag name with a list of names. returns true for matchesTag is any string in its list matches the tag.

Can be used for example by ProgrammableSAXFilter to delete any child element that is in (or not in) a given list.

XML Configuration Template:
    <Comparator class="TagListComparator" >
      <TagName>[ tag name to match ]</TagName>
      <TagName>[ alternate name to match ]</TagName>
      <TagName>[ etc... ]</TagName>
    </Comparator>
  

Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Constructor Summary
TagListComparator()
           
TagListComparator(java.util.List tags)
           
TagListComparator(java.util.List tags, boolean matchList)
           
TagListComparator(java.lang.String[] tagNames)
           
TagListComparator(java.lang.String[] tagNames, boolean matchList)
           
 
Method Summary
 void initialize(org.w3c.dom.Element compElem)
           
 boolean matchesData(char[] data, int start, int length)
          Checks if the character data matches the criteria of this comparator.
 boolean matchesPath(java.lang.String path)
          Checks if the XML tag at the specified path matches the criteria of this comparator.
 boolean matchesTag(java.lang.String path, org.xml.sax.Attributes atts)
          Checks if the XML tag at the specified path with given attribute list matches the criteria of this comparator.
 boolean needsData()
          Checks if this comparator needs to see the data section to make a decision.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagListComparator

public TagListComparator()

TagListComparator

public TagListComparator(java.lang.String[] tagNames)

TagListComparator

public TagListComparator(java.lang.String[] tagNames,
                         boolean matchList)

TagListComparator

public TagListComparator(java.util.List tags)

TagListComparator

public TagListComparator(java.util.List tags,
                         boolean matchList)
Method Detail

matchesTag

public boolean matchesTag(java.lang.String path,
                          org.xml.sax.Attributes atts)
Description copied from interface: ElementComparator
Checks if the XML tag at the specified path with given attribute list matches the criteria of this comparator.

Specified by:
matchesTag in interface ElementComparator
Parameters:
path - XML path to the element.
atts - Attribute list of the element.
Returns:
true if parameters match criteria of this comparator, false otherwise.

matchesPath

public boolean matchesPath(java.lang.String path)
Description copied from interface: ElementComparator
Checks if the XML tag at the specified path matches the criteria of this comparator.

Specified by:
matchesPath in interface ElementComparator
Parameters:
path - XML path to the element.
Returns:
true if path matches criteria of this comparator, false otherwise.

needsData

public boolean needsData()
Description copied from interface: ElementComparator
Checks if this comparator needs to see the data section to make a decision.

Specified by:
needsData in interface ElementComparator
Returns:
true if this comparator requires character data to match, false otherwise.

matchesData

public boolean matchesData(char[] data,
                           int start,
                           int length)
Description copied from interface: ElementComparator
Checks if the character data matches the criteria of this comparator.

Specified by:
matchesData in interface ElementComparator
Parameters:
data - source character array.
start - start position of source characters.
length - number of source characters.
Returns:
true if data matches criteria of this comparator, false otherwise.

initialize

public void initialize(org.w3c.dom.Element compElem)
Specified by:
initialize in interface ElementComparator