org.biojava.dasobert.das.validation
Class RegVerifier

java.lang.Object
  extended by AbstractVerifier
      extended by org.biojava.dasobert.das.validation.RegVerifier

public class RegVerifier
extends AbstractVerifier

SAX ContentHandler that verifies incoming SAX event stream. This object can be reused to validate multiple documents. Just be careful NOT to use the same object to validate more than one documents at the same time.

Author:
Kohsuke KAWAGUCHI

Nested Class Summary
static class RegVerifier.BadAttribute
          Bad attribute.
 
Field Summary
protected  Acceptor current
           
protected  DocumentDeclaration docDecl
          Schema object against which the validation will be done
static String ERR_DUPLICATE_ID
           
static String ERR_MISSING_ATTRIBUTE
           
static String ERR_UNCOMPLETED_CONTENT
           
static String ERR_UNEXPECTED_ATTRIBUTE
           
static String ERR_UNEXPECTED_ELEMENT
           
static String ERR_UNEXPECTED_STARTTAG
           
static String ERR_UNEXPECTED_TEXT
           
static String ERR_UNSOLD_IDREF
           
protected  ErrorHandler errorHandler
          Error handler
protected  boolean hadError
          This flag will be set to true if an error is found
protected  int panicLevel
          Panic level.
 
Constructor Summary
RegVerifier(DocumentDeclaration documentDecl, ErrorHandler errorHandler)
           
 
Method Summary
 void characters(char[] buf, int start, int len)
           
 void endDocument()
           
 void endElement(String namespaceUri, String localName, String qName)
           
protected  Datatype[] feedAttribute(Acceptor child, String uri, String localName, String qName, String value)
           
 Object getCurrentElementType()
           
 ErrorHandler getErrorHandler()
           
 Datatype[] getLastCharacterType()
           
 void ignorableWhitespace(char[] buf, int start, int len)
           
protected  void init()
           
 boolean isValid()
           
static String localizeMessage(String propertyName, Object[] args)
           
 void onDuplicateId(String id)
           
protected  ValidityViolation onError(String msg, ErrorInfo ei)
           
protected  ValidityViolation onError(StringRef ref, String defaultMsg, ErrorInfo ei)
          signals an error.
protected  void onNextAcceptorReady(StartTagInfo sti, Acceptor nextAcceptor)
          this method is called from the startElement method after the tag name is processed and the child acceptor is created.
 void setErrorHandler(ErrorHandler handler)
           
 void setPanicMode(boolean usePanicMode)
           
 void startDocument()
           
 void startElement(String namespaceUri, String localName, String qName, Attributes atts)
           
protected  void verifyText()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected Acceptor current

errorHandler

protected ErrorHandler errorHandler
Error handler


hadError

protected boolean hadError
This flag will be set to true if an error is found


docDecl

protected final DocumentDeclaration docDecl
Schema object against which the validation will be done


panicLevel

protected int panicLevel
Panic level. If the level is non-zero, createChildAcceptors will silently recover from error. This effectively suppresses spurious error messages. This value is set to INITIAL_PANIC_LEVEL when first an error is encountered, and is decreased by successful stepForward and createChildAcceptor. This value is also propagated to child acceptors.


ERR_UNEXPECTED_TEXT

public static final String ERR_UNEXPECTED_TEXT
See Also:
Constant Field Values

ERR_UNEXPECTED_ATTRIBUTE

public static final String ERR_UNEXPECTED_ATTRIBUTE
See Also:
Constant Field Values

ERR_MISSING_ATTRIBUTE

public static final String ERR_MISSING_ATTRIBUTE
See Also:
Constant Field Values

ERR_UNEXPECTED_STARTTAG

public static final String ERR_UNEXPECTED_STARTTAG
See Also:
Constant Field Values

ERR_UNCOMPLETED_CONTENT

public static final String ERR_UNCOMPLETED_CONTENT
See Also:
Constant Field Values

ERR_UNEXPECTED_ELEMENT

public static final String ERR_UNEXPECTED_ELEMENT
See Also:
Constant Field Values

ERR_UNSOLD_IDREF

public static final String ERR_UNSOLD_IDREF
See Also:
Constant Field Values

ERR_DUPLICATE_ID

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

RegVerifier

public RegVerifier(DocumentDeclaration documentDecl,
                   ErrorHandler errorHandler)
Method Detail

getErrorHandler

public final ErrorHandler getErrorHandler()

setErrorHandler

public final void setErrorHandler(ErrorHandler handler)

isValid

public final boolean isValid()

setPanicMode

public final void setPanicMode(boolean usePanicMode)

getLastCharacterType

public Datatype[] getLastCharacterType()

verifyText

protected void verifyText()
                   throws SAXException
Throws:
SAXException

startElement

public void startElement(String namespaceUri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Throws:
SAXException

onNextAcceptorReady

protected void onNextAcceptorReady(StartTagInfo sti,
                                   Acceptor nextAcceptor)
                            throws SAXException
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.

Throws:
SAXException

feedAttribute

protected Datatype[] feedAttribute(Acceptor child,
                                   String uri,
                                   String localName,
                                   String qName,
                                   String value)
                            throws SAXException
Throws:
SAXException

endElement

public void endElement(String namespaceUri,
                       String localName,
                       String qName)
                throws SAXException
Throws:
SAXException

onError

protected ValidityViolation onError(StringRef ref,
                                    String defaultMsg,
                                    ErrorInfo ei)
                             throws SAXException
signals an error. This method can be overrided by the derived class to provide different behavior.

Throws:
SAXException

onError

protected ValidityViolation onError(String msg,
                                    ErrorInfo ei)
                             throws SAXException
Throws:
SAXException

getCurrentElementType

public Object getCurrentElementType()

characters

public void characters(char[] buf,
                       int start,
                       int len)
                throws SAXException
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] buf,
                                int start,
                                int len)
                         throws SAXException
Throws:
SAXException

init

protected void init()

startDocument

public void startDocument()
                   throws SAXException
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Throws:
SAXException

onDuplicateId

public void onDuplicateId(String id)

localizeMessage

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