com.raritantechnologies.xml.sax.filter.selectors
Class AncestorElementSelector

java.lang.Object
  extended bycom.raritantechnologies.xml.sax.filter.ElementSelector
      extended bycom.raritantechnologies.xml.sax.filter.selectors.AncestorElementSelector

public class AncestorElementSelector
extends ElementSelector

This class can be used to cause the selection of an ancestor tag, based on the properties of a decendent tag.

Used in conjunction with the DispatchFilter and SAXDeleteFilter. It overrides the processChildElement( ) method to achieve its functionality. This method allows a parent element to be marked for selection by the SAXDeleteFilter. The selecter can work either on the decendant tag or on its character data.


Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Nested Class Summary
 
Nested classes inherited from class com.raritantechnologies.xml.sax.filter.ElementSelector
ElementSelector.ElementData
 
Constructor Summary
AncestorElementSelector()
           
AncestorElementSelector(ElementComparator ancestorComp, ElementComparator decendantComp)
          Constructor: takes a childComp that is used to match decendent Tags that should cause the selection of an ancestor.
AncestorElementSelector(ElementComparator ancestorComp, ElementComparator decendantComp, CDataComparator decendantDataComp)
          Overloaded version of the constructor that allows a tag to be selected if a decendant tag's character data matches the criteria specified in the CDataComparator.
 
Method Summary
 void processCharacters(java.lang.String path, char[] ch, int start, int length)
          processes character data if decendant data comparator is set.
 void processChildElement(java.lang.String childPath, ElementSelector.ElementData parentElement, java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
          sets the Element at path to be selected if the element comparator matches input.
 boolean shouldSelectElement(int startIndex)
          This method is called by SAXDeleteFilter to determine if this ElementSelector has any Elements that start at the given index and that should be selected.
 
Methods inherited from class com.raritantechnologies.xml.sax.filter.ElementSelector
couldSelectElement, getEndMark, initialize, processChildElement, reset, selectElement, setEndMark, setSelecting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AncestorElementSelector

public AncestorElementSelector()

AncestorElementSelector

public AncestorElementSelector(ElementComparator ancestorComp,
                               ElementComparator decendantComp)
Constructor: takes a childComp that is used to match decendent Tags that should cause the selection of an ancestor.

Parameters:
ancestorComp - element comparator used to identify the tag that will be selected by the selecter (if the decendant's properties are matched)
decendantComp - element comparator used to identity decendant tag that can trigger the selection of its ancestor. selection will occur if a decendant tag matches the criteria of this element comparator.

AncestorElementSelector

public AncestorElementSelector(ElementComparator ancestorComp,
                               ElementComparator decendantComp,
                               CDataComparator decendantDataComp)
Overloaded version of the constructor that allows a tag to be selected if a decendant tag's character data matches the criteria specified in the CDataComparator.

Parameters:
ancestorComp - element comparator used to identify the tag that will be selected by the selecter (if the decendant's properties are matched)
decendantComp - element comparator used to identity decendant tag that can trigger the selection of its ancestor. In this case, the selection is deferred to analysis of the character data section of the tag.
Method Detail

processChildElement

public void processChildElement(java.lang.String childPath,
                                ElementSelector.ElementData parentElement,
                                java.lang.String uri,
                                java.lang.String localName,
                                java.lang.String qName,
                                org.xml.sax.Attributes attrs)
sets the Element at path to be selected if the element comparator matches input.

Overrides:
processChildElement in class ElementSelector

processCharacters

public void processCharacters(java.lang.String path,
                              char[] ch,
                              int start,
                              int length)
processes character data if decendant data comparator is set.

Overrides:
processCharacters in class ElementSelector

shouldSelectElement

public boolean shouldSelectElement(int startIndex)
Description copied from class: ElementSelector
This method is called by SAXDeleteFilter to determine if this ElementSelector has any Elements that start at the given index and that should be selected. Either: we have an element at this index that shouldn't be selected, should be selected or we don't have an element at this index.

Overrides:
shouldSelectElement in class ElementSelector