|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.XMLFilterImpl
org.inria.ns.reflex.xml.sax.SAXFilter
org.inria.ns.reflex.xml.sax.XPathFilter
public class XPathFilter
A SAX filter that support XPath patterns and expressions in a very acceptable way.
A single branch of the XML tree is maintained by this class in order to cross forward axis. For each node of the branch, one can retrieve its attributes, namespaces, ancestors, and the index and size counters necessary when using the position(), last() and count() functions.
The datas that has been read previously can't be used in XPath expressions : preceding-sibling:: can't be used but ancestor:: can. More formally, the preceding:: axis is no longer reachable.
When a forward-axis is involved (when using following-sibling:: or count() or whatever that expect further reading), a cache is used to store events until the XPath expression becomes resolvable. Once done, the stored events are fired before the reading goes on.
Read this article.
An internal coroutine implements AbstractFilter
for applying rules.
Received SAX events are tested upon rules ; the rule with the highest priority is applied. Default rules are passing the non-matched events to the handler unmodified.
SAXNode| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.inria.ns.reflex.structures.Lockable |
|---|
Lockable.Monitor |
| Constructor Summary | |
|---|---|
XPathFilter(List rules,
boolean normalize,
PatternContext context,
FilterContextFactory filterContextFactory)
Create a new XPath filter. |
|
XPathFilter(ParserConfiguration parserConfiguration,
List rules,
boolean normalize,
PatternContext context,
FilterContextFactory filterContextFactory)
Create a new XPath filter. |
|
XPathFilter(RuleBasedFilter filterDef,
PatternContext context)
Create a new XPath filter. |
|
XPathFilter(XPathFilter model,
PatternContext context,
FilterContextFactory filterContextFactory)
Create a new XPath filter. |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Bufferize adjacent character events. |
void |
comment(char[] ch,
int start,
int length)
Process an event : lookup for a rule and apply it, or fire the event. |
void |
endAnticipate()
This method is called by the 2nd thread when further parsing is no longer needed. |
void |
endCDATA()
This event is ignored, as adjacent text nodes must be merged. |
void |
endDocument()
Process an event. |
void |
endDTD()
Fire or ignore this event according to the class of filters. |
void |
endElement(String uri,
String localName,
String qName)
Process an event. |
void |
endPrefixMapping(String prefix)
Remove a stored prefix mapping. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Fire character events. |
boolean |
isAnticipating()
Indicates whether the cache is active or not. |
boolean |
isSleeping()
Indicates whether the thread that owns this lockable is sleeping or not. |
void |
parse(InputSource input)
Parse an input. |
void |
parse(String systemId)
Parse an input. |
void |
processingInstruction(String target,
String data)
Process an event : lookup for a rule and apply it, or fire the event. |
void |
resumeThread()
Wake up the thread locked by this lockable. |
void |
startAnticipate()
This method is called by the 2nd thread when further parsing is needed. |
void |
startCDATA()
This event is ignored, as adjacent text nodes must be merged. |
void |
startDocument()
Process an event : lookup for a rule and apply it, or ignore the event. |
void |
startDTD(String name,
String publicId,
String systemId)
Fire or ignore this event according to the class of filters. |
void |
startElement(String uri,
String localName,
String qName,
Attributes atts)
Process an event : lookup for a rule and apply it, or fire the event. |
void |
startPrefixMapping(String prefix,
String uri)
Store a prefix mapping. |
void |
suspendThread()
Suspends this thread. |
String |
toString()
Return the rules of this filter, sorted in reverse priority order. |
| Methods inherited from class org.inria.ns.reflex.xml.sax.SAXFilter |
|---|
attributeDecl, elementDecl, endEntity, externalEntityDecl, getDeclHandler, getLexicalHandler, getLocation, getProperty, internalEntityDecl, isLocalizable, setDeclHandler, setLexicalHandler, setLocation, setProperty, startEntity |
| Methods inherited from class org.xml.sax.helpers.XMLFilterImpl |
|---|
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, notationDecl, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.xml.sax.ContentHandler |
|---|
setDocumentLocator, skippedEntity |
| Methods inherited from interface org.xml.sax.DTDHandler |
|---|
notationDecl, unparsedEntityDecl |
| Constructor Detail |
|---|
public XPathFilter(ParserConfiguration parserConfiguration,
List rules,
boolean normalize,
PatternContext context,
FilterContextFactory filterContextFactory)
*** The variable context MUST NOT be shared by filters. If it is backed by a DataSet, the local properties MUST NOT be shared. Each filter has to manage its own private properties ; this is critical for some properties used internally. ***
parserConfiguration - The configuration of the parser.rules - The list of rules used for event filtering.normalize - The default value for text normalization if not specified at rule level.context - The context that can resolve XPath functions, variables, and namespaces.filterContextFactory - The factory that create a filter context for each matched node.Rule,
AbstractFilter
public XPathFilter(XPathFilter model,
PatternContext context,
FilterContextFactory filterContextFactory)
*** See {@link #XPathFilter(ParserConfiguration, List, PatternContext)} ***
model - The new XPath filter will be the same as those one.
The parser configuration and the rules are shared
by both filters.context - The context that can resolve XPath functions, variables, and namespaces.filterContextFactory - The factory that create a filter context for each matched node.Rule,
AbstractFilter
public XPathFilter(List rules,
boolean normalize,
PatternContext context,
FilterContextFactory filterContextFactory)
*** See {@link #XPathFilter(ParserConfiguration, List, PatternContext)} ***
rules - The list of rules used for event filtering.normalize - The default value for text normalization if not specified at rule level.context - The context that can resolve XPath functions, variables, and namespaces.filterContextFactory - The factory that create a filter context for each matched node.Rule,
AbstractFilter,
ParserConfiguration.NAMESPACEAWARE_PARSER_CONFIGURATION
public XPathFilter(RuleBasedFilter filterDef,
PatternContext context)
*** See {@link #XPathFilter(ParserConfiguration, List, PatternContext)} ***
filterDef - The rule-based filter.context - The context that can resolve XPath functions, variables, and namespaces.filterContextFactory - The factory that create a filter context for each matched node.Rule,
AbstractFilter,
ParserConfiguration.NAMESPACEAWARE_PARSER_CONFIGURATION| Method Detail |
|---|
public void parse(InputSource input)
throws SAXException,
IOException
parse in interface XMLReaderparse in class XMLFilterImplinput - The input to parse.
SAXException
IOExceptionXMLFilterImpl.parse(org.xml.sax.InputSource)
public void parse(String systemId)
throws SAXException,
IOException
parse in interface XMLReaderparse in class SAXFiltersystemId - The system ID of the input to parse.
SAXException
IOExceptionSAXFilter.parse(java.lang.String)
public void startAnticipate()
throws IllegalStateException
startAnticipate in interface AnticipableIllegalStateException - When the end of the document is reached.Anticipable.startAnticipate()public boolean isAnticipating()
isAnticipating in interface Anticipabletrue if the cache is active, false otherwise.Anticipable.isAnticipating()public void endAnticipate()
endAnticipate in interface AnticipableAnticipable.endAnticipate()
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class SAXFilterSAXException - The client may throw
an exception during processing.XMLFilterImpl.startDocument()
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class SAXFilterSAXException - The client may throw
an exception during processing.XMLFilterImpl.endDocument()
public void comment(char[] ch,
int start,
int length)
throws SAXException
comment in interface LexicalHandlercomment in class SAXFilterSAXExceptionSAXFilter.comment(char[], int, int),
pushEvent(NamedEvent)
public void processingInstruction(String target,
String data)
throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class XMLFilterImplSAXExceptionXMLFilterImpl.processingInstruction(java.lang.String, java.lang.String),
pushEvent(NamedEvent)
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class XMLFilterImplSAXExceptionXMLFilterImpl.characters(char[], int, int)
public void startCDATA()
throws SAXException
startCDATA in interface LexicalHandlerstartCDATA in class SAXFilterSAXExceptionSAXFilter.startCDATA()
public void endCDATA()
throws SAXException
endCDATA in interface LexicalHandlerendCDATA in class SAXFilterSAXExceptionSAXFilter.endCDATA()
public void startDTD(String name,
String publicId,
String systemId)
throws SAXException
startDTD in interface LexicalHandlerstartDTD in class SAXFilterSAXExceptionFilterContextFactory.processDTD(),
LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)
public void endDTD()
throws SAXException
endDTD in interface LexicalHandlerendDTD in class SAXFilterSAXExceptionFilterContextFactory.processDTD(),
LexicalHandler.endDTD()
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class XMLFilterImplSAXExceptioncharacters(char[], int, int),
XMLFilterImpl.ignorableWhitespace(char[], int, int)
public void endElement(String uri,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class XMLFilterImplSAXExceptionXMLFilterImpl.endElement(java.lang.String, java.lang.String, java.lang.String)
public void startElement(String uri,
String localName,
String qName,
Attributes atts)
throws SAXException
startElement in interface ContentHandlerstartElement in class XMLFilterImplSAXExceptionXMLFilterImpl.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes),
pushEvent(NamedEvent)
public void startPrefixMapping(String prefix,
String uri)
throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class XMLFilterImplSAXExceptionXMLFilterImpl.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(String prefix)
throws SAXException
endPrefixMapping in interface ContentHandlerendPrefixMapping in class XMLFilterImplSAXExceptionXMLFilterImpl.endPrefixMapping(java.lang.String)public boolean isSleeping()
isSleeping in interface Lockabletrue if the thread is sleeping, false otherwise.Lockable.isSleeping()
public void suspendThread()
throws InterruptedException
suspendThread in interface LockableInterruptedExceptionLockable.suspendThread()public void resumeThread()
resumeThread in interface LockableLockable.resumeThread()public String toString()
toString in class ObjectObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||