com.sun.msv.verifier.identity
Class IDConstraintChecker

java.lang.Object
  extended by com.sun.msv.verifier.AbstractVerifier
      extended by com.sun.msv.verifier.Verifier
          extended by com.sun.msv.verifier.identity.IDConstraintChecker
All Implemented Interfaces:
IDContextProvider2, IVerifier, org.iso_relax.verifier.VerifierHandler, org.relaxng.datatype.ValidationContext, ContentHandler, 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.

Author:
Kohsuke KAWAGUCHI

Field Summary
static String ERR_DOUBLE_MATCH
           
static String ERR_NOT_UNIQUE
           
static String ERR_NOT_UNIQUE_DIAG
           
static String ERR_UNDEFINED_KEY
           
static String ERR_UNMATCHED_KEY_FIELD
           
protected  XMLSchemaGrammar grammar
          the grammar object against which we are validating.
protected  Vector<Matcher> matchers
          active mathcers.
 
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
IDConstraintChecker(XMLSchemaGrammar grammar, ErrorHandler errorHandler)
           
 
Method Summary
protected  void add(Matcher matcher)
           
protected  boolean addKeyValue(SelectorMatcher scope, com.sun.msv.verifier.identity.KeyValue value)
          adds a new KeyValue to the value set.
 void characters(char[] buf, int start, int len)
           
 void endDocument()
           
 void endElement(String namespaceUri, String localName, String qName)
           
protected  org.relaxng.datatype.Datatype[] feedAttribute(Acceptor child, String uri, String localName, String qName, String value)
           
protected  SelectorMatcher getActiveScope(IdentityConstraint c)
           
protected  com.sun.msv.verifier.identity.KeyValue[] getKeyValues(SelectorMatcher scope)
          gets the all KeyValues that were added within the specified scope.
static String localizeMessage(String propertyName, Object arg)
           
static String localizeMessage(String propertyName, Object[] args)
           
protected  void onNextAcceptorReady(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  void popActiveScope(IdentityConstraint c, SelectorMatcher matcher)
           
protected  void pushActiveScope(IdentityConstraint c, SelectorMatcher matcher)
           
protected  void remove(Matcher matcher)
           
protected  void reportError(ErrorInfo ei, String propKey, Object[] args)
          reports an error.
protected  void reportError(Locator loc, ErrorInfo ei, String propKey, Object[] args)
           
 void startDocument()
           
 
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 com.sun.msv.verifier.IVerifier
getLocator
 
Methods inherited from interface org.xml.sax.ContentHandler
endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 

Field Detail

grammar

protected final XMLSchemaGrammar grammar
the grammar object against which we are validating.


matchers

protected final Vector<Matcher> matchers
active mathcers.


ERR_UNMATCHED_KEY_FIELD

public static final String ERR_UNMATCHED_KEY_FIELD
See Also:
Constant Field Values

ERR_NOT_UNIQUE

public static final String ERR_NOT_UNIQUE
See Also:
Constant Field Values

ERR_NOT_UNIQUE_DIAG

public static final String ERR_NOT_UNIQUE_DIAG
See Also:
Constant Field Values

ERR_DOUBLE_MATCH

public static final String ERR_DOUBLE_MATCH
See Also:
Constant Field Values

ERR_UNDEFINED_KEY

public static final String ERR_UNDEFINED_KEY
See Also:
Constant Field Values
Constructor Detail

IDConstraintChecker

public IDConstraintChecker(XMLSchemaGrammar grammar,
                           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,
                              com.sun.msv.verifier.identity.KeyValue value)
adds a new KeyValue to the value set.

Returns:
true if this is a new value.

getKeyValues

protected com.sun.msv.verifier.identity.KeyValue[] getKeyValues(SelectorMatcher scope)
gets the all KeyValues that were added within the specified scope.


startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class Verifier
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class Verifier
Throws:
SAXException

onNextAcceptorReady

protected void onNextAcceptorReady(StartTagInfo sti,
                                   Acceptor next)
                            throws SAXException
Description copied from class: Verifier
this 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:
onNextAcceptorReady in class Verifier
Throws:
SAXException

feedAttribute

protected org.relaxng.datatype.Datatype[] feedAttribute(Acceptor child,
                                                        String uri,
                                                        String localName,
                                                        String qName,
                                                        String value)
                                                 throws SAXException
Overrides:
feedAttribute in class Verifier
Throws:
SAXException

characters

public void characters(char[] buf,
                       int start,
                       int len)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class Verifier
Throws:
SAXException

endElement

public void endElement(String namespaceUri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class Verifier
Throws:
SAXException

reportError

protected void reportError(ErrorInfo ei,
                           String propKey,
                           Object[] args)
                    throws SAXException
reports an error.

Throws:
SAXException

reportError

protected void reportError(Locator loc,
                           ErrorInfo ei,
                           String propKey,
                           Object[] args)
                    throws SAXException
Throws:
SAXException

localizeMessage

public static String localizeMessage(String propertyName,
                                     Object arg)

localizeMessage

public static String localizeMessage(String propertyName,
                                     Object[] args)


MSV