com.raritech.xml.sax.filter
Class ElementModifier
java.lang.Object
|
+--com.raritech.xml.sax.filter.ElementModifier
- All Implemented Interfaces:
- ElementComparator
- Direct Known Subclasses:
- CDataExtender, ElementAdder, ElementNotifier, XPathNotifier
- public class ElementModifier
- extends java.lang.Object
- implements ElementComparator
Base class for objects that can modify an XML element as it passes through the
ProgrammableSAXFilter -- with which it is designed to work.
This base class can have an AttributesModifier and/or a CDataModifier
to handle basic modification needs. Subclasses can extend/modify this behavior to add
child elements, or delete or add character data sections to the element. This class aggregates
an ElementComparator by implementing this interface and delegating to an implementation of
this interface (if present). This allows the object to detect the elements within the SAX event
stream, that it is designed to modify and simplifies the code needed in ProgrammableSAXFilter.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ElementModifier
public ElementModifier()
ElementModifier
public ElementModifier(ElementComparator comp)
ElementModifier
public ElementModifier(ElementComparator comp,
AttributesModifier attrMod)
ElementModifier
public ElementModifier(ElementComparator comp,
CDataModifier dataMod)
ElementModifier
public ElementModifier(ElementComparator comp,
AttributesModifier attrMod,
CDataModifier dataMod)
ElementModifier
public ElementModifier(CDataModifier dataMod)
ElementModifier
public ElementModifier(CDataModifier dataMod,
boolean defaultMatch)
setElementComparator
public void setElementComparator(ElementComparator comp)
getElementComparator
public ElementComparator getElementComparator()
setAttributesModifier
public void setAttributesModifier(AttributesModifier attrMod)
getAttributesModifier
public AttributesModifier getAttributesModifier()
setCDataModifier
public void setCDataModifier(CDataModifier dataMod)
getCDataModifier
public CDataModifier getCDataModifier()
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
- Following copied from interface:
com.raritech.xml.sax.filter.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
- Following copied from interface:
com.raritech.xml.sax.filter.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
- Following copied from interface:
com.raritech.xml.sax.filter.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
- Following copied from interface:
com.raritech.xml.sax.filter.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.
modifiyAttributes
public org.xml.sax.Attributes modifiyAttributes(org.xml.sax.Attributes source,
boolean isRootTag)
activate
public void activate()
deactivate
public void deactivate()
filterCData
public void filterCData(CDataContent dataContent)
- This method is used to add/modify/delete characters from the character data section of
the element. The default behavior is to do nothing to the event, by passing it to
the passed in ContentHandler unchanged. Subclasses can override this to delete or
otherwise modify the character section by adding or removing character SAX events.
elementStarted
public void elementStarted(org.xml.sax.ContentHandler cHandler,
boolean isRootTag)
- Subclasses may override these to add new children or new CData
elementEnding
public void elementEnding(org.xml.sax.ContentHandler cHandler,
boolean isRootTag)