Top Description Inners Fields Constructors Methods
com.sun.msv.verifier.identity

public abstract Class PathMatcher

extends MatcherBundle
Class Inheritance
Known Direct Subclasses
com.sun.msv.verifier.identity.SelectorMatcher, com.sun.msv.verifier.identity.FieldMatcher
Imports
org.relaxng.datatype.Datatype, org.xml.sax.SAXException, com.sun.msv.grammar.xmlschema.XPath

Base implementation of XPath matching engine. It only supports the subset defined in XML Schema Part 1. Extra care must be taken to call the testInitialMatch method after the creation of an object. Match to an attribute is not supported. It is implemented in FieldPathMatcher class. The onMatched method is called when the specified XPath matches the current element. Derived classes should implement this method to do something useful.
Author
Kohsuke KAWAGUCHI

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
PathMatcher.SinglePathMatcher

the XPath matching engine.

Field Summary

Modifier and TypeField and Description
private boolean
matchFound

a flag that indicates that this element/attribute matches the path expression.

Inherited from com.sun.msv.verifier.identity.MatcherBundle:
children

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
protected abstract void
onAttributeMatched(String namespaceURI, String localName, String value, Datatype type)

this method is called when the attribute matches the XPath.

protected abstract void
onElementMatched(String namespaceURI, String localName)

this method is called when the element matches the XPath.

protected void
start(String namespaceURI, String localName)

this method should be called immediately after the installment of this PathMatcher.

protected void
Inherited from com.sun.msv.verifier.identity.MatcherBundle:
charactersendElementgetDepthonRemoved

Field Detail

matchFoundback to summary
private boolean matchFound

a flag that indicates that this element/attribute matches the path expression. This flag is set by one of the child SinglePathMatcher.

Constructor Detail

PathMatcherback to summary
protected PathMatcher(IDConstraintChecker owner, XPath[] paths)

Method Detail

onAttributeback to summary
protected void onAttribute(String namespaceURI, String localName, String value, Datatype type) throws SAXException

Overrides com.sun.msv.verifier.identity.MatcherBundle.onAttribute.

onAttributeMatchedback to summary
protected abstract void onAttributeMatched(String namespaceURI, String localName, String value, Datatype type) throws SAXException

this method is called when the attribute matches the XPath.

onElementMatchedback to summary
protected abstract void onElementMatched(String namespaceURI, String localName) throws SAXException

this method is called when the element matches the XPath.

startback to summary
protected void start(String namespaceURI, String localName) throws SAXException

this method should be called immediately after the installment of this PathMatcher.

startElementback to summary
protected void startElement(String namespaceURI, String localName) throws SAXException

Overrides com.sun.msv.verifier.identity.MatcherBundle.startElement.

com.sun.msv.verifier.identity back to summary

private Class PathMatcher.SinglePathMatcher

extends Matcher
Class Inheritance

the XPath matching engine.

This class implements the matching engine for single "Path".

The outer PathMatcher uses multiple instances of this class and thereby implements the matching engine for the whole "Selector".

This class only supports the subset defined in XML Schema Part 1. Extra care must be taken to call the testInitialMatch method after the creation of an object.

When a match is found, this class notifies the parent object by using a flag.

Field Summary

Modifier and TypeField and Description
private boolean[][]
activeSteps

stores matched steps.

private boolean
elementMatched

this flag is set to true when the path contains an attribute step and the current element matches the element part of the path.

protected final XPath
Inherited from com.sun.msv.verifier.identity.Matcher:
owner

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
onAttribute(String namespaceURI, String localName, String value, Datatype type)

Implements abstract com.sun.msv.verifier.identity.Matcher.onAttribute.

protected void
Inherited from com.sun.msv.verifier.identity.Matcher:
characters

Field Detail

activeStepsback to summary
private boolean[][] activeSteps

stores matched steps. first dimension is expanded as the depth goes deep. second dimension is always equal to the size of steps.

elementMatchedback to summary
private boolean elementMatched

this flag is set to true when the path contains an attribute step and the current element matches the element part of the path. When this flag is true, we need to honor the onAttribute event and check if the path really matches to the attribute.

pathback to summary
protected final XPath path

Constructor Detail

SinglePathMatcherback to summary
protected SinglePathMatcher(XPath path)

Method Detail

endElementback to summary
protected void endElement(Datatype dt)

Implements abstract com.sun.msv.verifier.identity.Matcher.endElement.

onAttributeback to summary
protected void onAttribute(String namespaceURI, String localName, String value, Datatype type) throws SAXException

Implements abstract com.sun.msv.verifier.identity.Matcher.onAttribute.

startElementback to summary
protected void startElement(String namespaceURI, String localName) throws SAXException

Implements abstract com.sun.msv.verifier.identity.Matcher.startElement.