Package com.sun.msv.verifier.identity
Class IDConstraintChecker
- java.lang.Object
-
- com.sun.msv.verifier.AbstractVerifier
-
- com.sun.msv.verifier.Verifier
-
- com.sun.msv.verifier.identity.IDConstraintChecker
-
- All Implemented Interfaces:
IDContextProvider2,IVerifier,org.iso_relax.verifier.VerifierHandler,org.relaxng.datatype.ValidationContext,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler
public class IDConstraintChecker extends Verifier
Verifier with XML Schema-related enforcement.This class can be used in the same way as
Verifier. This class also checks XML Schema's identity constraint.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.MapactiveScopesa map fromIdentityConstraintto aLightStackofSelectorMatcher.static java.lang.StringERR_DOUBLE_MATCHstatic java.lang.StringERR_NOT_UNIQUEstatic java.lang.StringERR_NOT_UNIQUE_DIAGstatic java.lang.StringERR_UNDEFINED_KEYstatic java.lang.StringERR_UNMATCHED_KEY_FIELDprotected XMLSchemaGrammargrammarthe grammar object against which we are validating.private java.util.MapkeyValuesa map fromSelectorMatcherto set ofKeyValues.protected java.util.Vectormatchersactive mathcers.private java.util.MapreferenceScopea map from keyrefSelectorMatcherto key/uniqueSelectorMatcher.-
Fields inherited from class com.sun.msv.verifier.Verifier
current, docDecl, ERR_DUPLICATE_ID, ERR_MISSING_ATTRIBUTE, ERR_UNCOMPLETED_CONTENT, ERR_UNEXPECTED_ATTRIBUTE, ERR_UNEXPECTED_ELEMENT, ERR_UNEXPECTED_STARTTAG, ERR_UNEXPECTED_TEXT, ERR_UNSOLD_IDREF, errorHandler, hadError, panicLevel
-
Fields inherited from class com.sun.msv.verifier.AbstractVerifier
dummyLocator, idrefs, ids, locator, namespaceSupport, performIDcheck
-
-
Constructor Summary
Constructors Constructor Description IDConstraintChecker(XMLSchemaGrammar grammar, org.xml.sax.ErrorHandler errorHandler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(Matcher matcher)protected booleanaddKeyValue(SelectorMatcher scope, KeyValue value)adds a new KeyValue to the value set.voidcharacters(char[] buf, int start, int len)voidendDocument()voidendElement(java.lang.String namespaceUri, java.lang.String localName, java.lang.String qName)protected org.relaxng.datatype.Datatype[]feedAttribute(Acceptor child, java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String value)protected SelectorMatchergetActiveScope(IdentityConstraint c)protected KeyValue[]getKeyValues(SelectorMatcher scope)gets the allKeyValues that were added within the specified scope.static java.lang.StringlocalizeMessage(java.lang.String propertyName, java.lang.Object arg)static java.lang.StringlocalizeMessage(java.lang.String propertyName, java.lang.Object[] args)protected voidonNextAcceptorReady(StartTagInfo sti, Acceptor next)this method is called from the startElement method after the tag name is processed and the child acceptor is created.protected voidpopActiveScope(IdentityConstraint c, SelectorMatcher matcher)protected voidpushActiveScope(IdentityConstraint c, SelectorMatcher matcher)protected voidremove(Matcher matcher)protected voidreportError(ErrorInfo ei, java.lang.String propKey, java.lang.Object[] args)reports an error.protected voidreportError(org.xml.sax.Locator loc, ErrorInfo ei, java.lang.String propKey, java.lang.Object[] args)voidstartDocument()-
Methods inherited from class com.sun.msv.verifier.Verifier
getCurrentElementType, getErrorHandler, getLastCharacterType, ignorableWhitespace, init, isValid, onDuplicateId, onError, onError, setErrorHandler, setPanicMode, startElement, verifyText
-
Methods inherited from class com.sun.msv.verifier.AbstractVerifier
endPrefixMapping, getBaseUri, getLocator, isNotation, isUnparsedEntity, notationDecl, onID, processingInstruction, resolveNamespacePrefix, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xml.sax.ContentHandler
endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
-
Methods inherited from interface com.sun.msv.verifier.IVerifier
getLocator
-
-
-
-
Field Detail
-
grammar
protected final XMLSchemaGrammar grammar
the grammar object against which we are validating.
-
matchers
protected final java.util.Vector matchers
active mathcers.
-
keyValues
private final java.util.Map keyValues
a map fromSelectorMatcherto set ofKeyValues. One SelectorMatcher correponds to one scope of the identity constraint.
-
referenceScope
private final java.util.Map referenceScope
a map from keyrefSelectorMatcherto key/uniqueSelectorMatcher. Given a keyref scope, this map stores which key scope should it refer to.
-
activeScopes
private final java.util.Map activeScopes
a map fromIdentityConstraintto aLightStackofSelectorMatcher. Each stack top keeps the currently active scope for the given IdentityConstraint.
-
ERR_UNMATCHED_KEY_FIELD
public static final java.lang.String ERR_UNMATCHED_KEY_FIELD
- See Also:
- Constant Field Values
-
ERR_NOT_UNIQUE
public static final java.lang.String ERR_NOT_UNIQUE
- See Also:
- Constant Field Values
-
ERR_NOT_UNIQUE_DIAG
public static final java.lang.String ERR_NOT_UNIQUE_DIAG
- See Also:
- Constant Field Values
-
ERR_DOUBLE_MATCH
public static final java.lang.String ERR_DOUBLE_MATCH
- See Also:
- Constant Field Values
-
ERR_UNDEFINED_KEY
public static final java.lang.String ERR_UNDEFINED_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IDConstraintChecker
public IDConstraintChecker(XMLSchemaGrammar grammar, org.xml.sax.ErrorHandler errorHandler)
-
-
Method Detail
-
add
protected void add(Matcher matcher)
-
remove
protected void remove(Matcher matcher)
-
getActiveScope
protected SelectorMatcher getActiveScope(IdentityConstraint c)
-
pushActiveScope
protected void pushActiveScope(IdentityConstraint c, SelectorMatcher matcher)
-
popActiveScope
protected void popActiveScope(IdentityConstraint c, SelectorMatcher matcher)
-
addKeyValue
protected boolean addKeyValue(SelectorMatcher scope, KeyValue value)
adds a new KeyValue to the value set.- Returns:
- true if this is a new value.
-
getKeyValues
protected KeyValue[] getKeyValues(SelectorMatcher scope)
gets the allKeyValues that were added within the specified scope.
-
startDocument
public void startDocument() throws org.xml.sax.SAXException- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classVerifier- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classVerifier- Throws:
org.xml.sax.SAXException
-
onNextAcceptorReady
protected void onNextAcceptorReady(StartTagInfo sti, Acceptor next) throws org.xml.sax.SAXException
Description copied from class:Verifierthis method is called from the startElement method after the tag name is processed and the child acceptor is created.This method is called before the attributes are consumed.
derived class can use this method to do something useful.
- Overrides:
onNextAcceptorReadyin classVerifier- Throws:
org.xml.sax.SAXException
-
feedAttribute
protected org.relaxng.datatype.Datatype[] feedAttribute(Acceptor child, java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String value) throws org.xml.sax.SAXException
- Overrides:
feedAttributein classVerifier- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] buf, int start, int len) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classVerifier- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String namespaceUri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classVerifier- Throws:
org.xml.sax.SAXException
-
reportError
protected void reportError(ErrorInfo ei, java.lang.String propKey, java.lang.Object[] args) throws org.xml.sax.SAXException
reports an error.- Throws:
org.xml.sax.SAXException
-
reportError
protected void reportError(org.xml.sax.Locator loc, ErrorInfo ei, java.lang.String propKey, java.lang.Object[] args) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
localizeMessage
public static java.lang.String localizeMessage(java.lang.String propertyName, java.lang.Object arg)
-
localizeMessage
public static java.lang.String localizeMessage(java.lang.String propertyName, java.lang.Object[] args)
-
-