org.apache.xerces.impl.xpath
Class XPathMatcher

java.lang.Object
  |
  +--org.apache.xerces.impl.xpath.XPathMatcher
Direct Known Subclasses:
Field.Matcher, Selector.Matcher

public class XPathMatcher
extends java.lang.Object
implements org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.XMLDocumentFragmentHandler

XPath matcher.

Version:
$Id: XPathMatcher.java,v 1.1.2.9 2001/07/26 08:03:37 andyc Exp $
Author:
Andy Clark, IBM

Inner Class Summary
protected static class XPathMatcher.IntegerStack
          A simple integer stack.
 
Constructor Summary
XPathMatcher(XPath xpath)
          Constructs an XPath matcher that implements a document fragment handler.
XPathMatcher(XPath xpath, boolean shouldBufferContent)
          Constructs an XPath matcher that implements a document fragment handler.
 
Method Summary
 void characters(org.apache.xerces.xni.XMLString text)
          Character content.
 void comment(org.apache.xerces.xni.XMLString text)
          A comment.
 void endCDATA()
          The end of a CDATA section.
 void endDocumentFragment()
          The end of the document fragment.
 void endElement(org.apache.xerces.xni.QName element)
          The end of an element.
 void endEntity(java.lang.String name)
          This method notifies the end of an entity.
 void endPrefixMapping(java.lang.String prefix)
          The end of a namespace prefix mapping.
 java.lang.String getMatchedString()
          Returns the matched string.
 java.lang.String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 java.lang.String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
 void ignorableWhitespace(org.apache.xerces.xni.XMLString text)
          Ignorable whitespace.
 boolean isMatched()
          Returns true if XPath has been matched.
static void main(java.lang.String[] argv)
          Main program.
protected  void matched(java.lang.String content)
          This method is called when the XPath handler matches the XPath expression.
 void processingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data)
          A processing instruction.
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
 void setFeature(java.lang.String featureId, boolean state)
          Sets the state of a feature.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Sets the value of a property.
 void startCDATA()
          The start of a CDATA section.
 void startDocumentFragment(org.apache.xerces.xni.XMLLocator locator, org.apache.xerces.xni.NamespaceContext namespaceContext)
          The start of the document fragment.
 void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes)
          The start of an element.
 void startEntity(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String baseSystemId, java.lang.String encoding)
          This method notifies the start of an entity.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          The start of a namespace prefix mapping.
 void textDecl(java.lang.String version, java.lang.String encoding)
          Notifies of the presence of a TextDecl line in an entity.
 java.lang.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

XPathMatcher

public XPathMatcher(XPath xpath)
Constructs an XPath matcher that implements a document fragment handler.
Parameters:
xpath - The xpath.
symbols - The symbol table.

XPathMatcher

public XPathMatcher(XPath xpath,
                    boolean shouldBufferContent)
Constructs an XPath matcher that implements a document fragment handler.
Parameters:
xpath - The xpath.
symbols - The symbol table.
shouldBufferContent - True if the matcher should buffer the matched content.
Method Detail

isMatched

public boolean isMatched()
Returns true if XPath has been matched.

getMatchedString

public java.lang.String getMatchedString()
Returns the matched string.

matched

protected void matched(java.lang.String content)
                throws org.apache.xerces.xni.XNIException
This method is called when the XPath handler matches the XPath expression. Subclasses can override this method to provide default handling upon a match.

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.XNIException
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.
Specified by:
reset in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
componentManager - The component manager.
Throws:
SAXException - Thrown by component on initialization error. For example, if a feature or property is required for the operation of the component, the component manager may throw a SAXNotRecognizedException or a SAXNotSupportedException.

getRecognizedFeatures

public java.lang.String[] getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this component. This method may return null if no features are recognized by this component.
Specified by:
getRecognizedFeatures in interface org.apache.xerces.xni.parser.XMLComponent

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the state of a feature. This method is called by the component manager any time after reset when a feature changes state.

Note: Components should silently ignore features that do not affect the operation of the component.

Specified by:
setFeature in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.

getRecognizedProperties

public java.lang.String[] getRecognizedProperties()
Returns a list of property identifiers that are recognized by this component. This method may return null if no properties are recognized by this component.
Specified by:
getRecognizedProperties in interface org.apache.xerces.xni.parser.XMLComponent

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note: Components should silently ignore properties that do not affect the operation of the component.

Specified by:
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.

startDocumentFragment

public void startDocumentFragment(org.apache.xerces.xni.XMLLocator locator,
                                  org.apache.xerces.xni.NamespaceContext namespaceContext)
                           throws org.apache.xerces.xni.XNIException
The start of the document fragment.
Specified by:
startDocumentFragment in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
baseSystemId - The base system identifier for this fragment.
namespaceContext - The namespace context in effect at the start of this document fragment. This object only represents the current context. Implementors of this class are responsible for copying the namespace bindings from the the current context (and its parent contexts) if that information is important.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

startEntity

public void startEntity(java.lang.String name,
                        java.lang.String publicId,
                        java.lang.String systemId,
                        java.lang.String baseSystemId,
                        java.lang.String encoding)
                 throws org.apache.xerces.xni.XNIException
This method notifies the start of an entity.

Note: This method is not called for entity references appearing as part of attribute values.

Specified by:
startEntity in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
name - The name of the entity.
publicId - The public identifier of the entity if the entity is external, null otherwise.
systemId - The system identifier of the entity if the entity is external, null otherwise.
baseSystemId - The base system identifier of the entity if the entity is external, null otherwise.
encoding - The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

textDecl

public void textDecl(java.lang.String version,
                     java.lang.String encoding)
              throws org.apache.xerces.xni.XNIException
Notifies of the presence of a TextDecl line in an entity. If present, this method will be called immediately following the startEntity call.

Note: This method will never be called for the document entity; it is only called for external general entities referenced in document content.

Note: This method is not called for entity references appearing as part of attribute values.

Specified by:
textDecl in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
version - The XML version, or null if not specified.
encoding - The IANA encoding name of the entity.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endEntity

public void endEntity(java.lang.String name)
               throws org.apache.xerces.xni.XNIException
This method notifies the end of an entity.

Note: This method is not called for entity references appearing as part of attribute values.

Specified by:
endEntity in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
name - The name of the entity.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

comment

public void comment(org.apache.xerces.xni.XMLString text)
             throws org.apache.xerces.xni.XNIException
A comment.
Specified by:
comment in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
text - The text in the comment.
Throws:
org.apache.xerces.xni.XNIException - Thrown by application to signal an error.

processingInstruction

public void processingInstruction(java.lang.String target,
                                  org.apache.xerces.xni.XMLString data)
                           throws org.apache.xerces.xni.XNIException
A processing instruction. Processing instructions consist of a target name and, optionally, text data. The data is only meaningful to the application.

Typically, a processing instruction's data will contain a series of pseudo-attributes. These pseudo-attributes follow the form of element attributes but are not parsed or presented to the application as anything other than text. The application is responsible for parsing the data.

Specified by:
processingInstruction in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
target - The target.
data - The data or null if none specified.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.apache.xerces.xni.XNIException
The start of a namespace prefix mapping. This method will only be called when namespace processing is enabled.
Specified by:
startPrefixMapping in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
prefix - The namespace prefix.
uri - The URI bound to the prefix.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

startElement

public void startElement(org.apache.xerces.xni.QName element,
                         org.apache.xerces.xni.XMLAttributes attributes)
                  throws org.apache.xerces.xni.XNIException
The start of an element. If the document specifies the start element by using an empty tag, then the startElement method will immediately be followed by the endElement method, with no intervening methods.
Specified by:
startElement in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
element - The name of the element.
attributes - The element attributes.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

characters

public void characters(org.apache.xerces.xni.XMLString text)
                throws org.apache.xerces.xni.XNIException
Character content.
Specified by:
characters in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
text - The content.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

ignorableWhitespace

public void ignorableWhitespace(org.apache.xerces.xni.XMLString text)
                         throws org.apache.xerces.xni.XNIException
Ignorable whitespace. For this method to be called, the document source must have some way of determining that the text containing only whitespace characters should be considered ignorable. For example, the validator can determine if a length of whitespace characters in the document are ignorable based on the element content model.
Specified by:
ignorableWhitespace in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
text - The ignorable whitespace.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endElement

public void endElement(org.apache.xerces.xni.QName element)
                throws org.apache.xerces.xni.XNIException
The end of an element.
Specified by:
endElement in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
element - The name of the element.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.apache.xerces.xni.XNIException
The end of a namespace prefix mapping. This method will only be called when namespace processing is enabled.
Specified by:
endPrefixMapping in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Parameters:
prefix - The namespace prefix.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

startCDATA

public void startCDATA()
                throws org.apache.xerces.xni.XNIException
The start of a CDATA section.
Specified by:
startCDATA in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endCDATA

public void endCDATA()
              throws org.apache.xerces.xni.XNIException
The end of a CDATA section.
Specified by:
endCDATA in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endDocumentFragment

public void endDocumentFragment()
                         throws org.apache.xerces.xni.XNIException
The end of the document fragment.
Specified by:
endDocumentFragment in interface org.apache.xerces.xni.XMLDocumentFragmentHandler
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Main program.


Copyright © 1999-2001 Apache XML Project. All Rights Reserved.