com.thaiopensource.validate.nrl
Class ValidatorImpl

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.thaiopensource.validate.nrl.ValidatorImpl
All Implemented Interfaces:
Validator, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

 class ValidatorImpl
extends DefaultHandler
implements Validator


Nested Class Summary
private static class ValidatorImpl.PrefixMapping
           
private static class ValidatorImpl.Program
           
private  class ValidatorImpl.Section
           
 
Field Summary
private  Vector activeHandlersAttributeIndexSets
           
private  Hashtable attributeNamespaceIndexSets
           
private  boolean attributeNamespaceRejected
           
private  Hashset attributeSchemas
           
private static String BEARER_LOCAL_NAME
           
private static String BEARER_URI
           
private  ValidatorImpl.Section currentSection
           
private  ErrorHandler eh
           
private  Attributes filteredAttributes
           
private  Localizer localizer
           
private  Locator locator
           
private static String NO_NS
           
private  Hashset noResultActions
           
private  ValidatorImpl.PrefixMapping prefixMapping
           
private  PropertyMap properties
           
private  Mode startMode
           
private  Hashtable validatorHandlerCache
           
 
Constructor Summary
ValidatorImpl(Mode mode, PropertyMap properties)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
private  void cleanupHandler(ContentHandler vh)
           
private  Validator createValidator(Schema schema)
           
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
           
 void endPrefixMapping(String prefix)
           
private  void endSection()
           
private static Attributes filterAttributes(IntSet indexSet, Attributes attributes)
           
 ContentHandler getContentHandler()
          Returns the ContentHandler that will receive the XML document.
 DTDHandler getDTDHandler()
          Returns a DTDHandler.
 void ignorableWhitespace(char[] ch, int start, int length)
           
private  void initCurrentSection()
           
private  void initHandler(ContentHandler ch)
           
private  boolean processAttributes(Attributes attributes)
           
private  AttributeActionSet processAttributeSection(ModeUsage modeUsage, String ns, IntSet indexSet, Attributes attributes)
           
private  void releaseValidator(Schema schema, Validator vh)
           
 void reset()
          Cleans up after validating a document.
 void setDocumentLocator(Locator locator)
           
 void startElement(String uri, String localName, String qName, Attributes attributes)
           
 void startPrefixMapping(String prefix, String uri)
           
private  void startSection(String uri)
           
private  void validateAttributes(Schema schema, Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEARER_URI

private static final String BEARER_URI
See Also:
Constant Field Values

BEARER_LOCAL_NAME

private static final String BEARER_LOCAL_NAME
See Also:
Constant Field Values

NO_NS

private static final String NO_NS
See Also:
Constant Field Values

eh

private final ErrorHandler eh

properties

private final PropertyMap properties

locator

private Locator locator

currentSection

private ValidatorImpl.Section currentSection

prefixMapping

private ValidatorImpl.PrefixMapping prefixMapping

validatorHandlerCache

private final Hashtable validatorHandlerCache

localizer

private final Localizer localizer

noResultActions

private final Hashset noResultActions

attributeNamespaceIndexSets

private final Hashtable attributeNamespaceIndexSets

activeHandlersAttributeIndexSets

private final Vector activeHandlersAttributeIndexSets

attributeSchemas

private final Hashset attributeSchemas

attributeNamespaceRejected

private boolean attributeNamespaceRejected

filteredAttributes

private Attributes filteredAttributes

startMode

private final Mode startMode
Constructor Detail

ValidatorImpl

ValidatorImpl(Mode mode,
              PropertyMap properties)
Method Detail

initCurrentSection

private void initCurrentSection()

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

filterAttributes

private static Attributes filterAttributes(IntSet indexSet,
                                           Attributes attributes)

processAttributes

private boolean processAttributes(Attributes attributes)
                           throws SAXException
Throws:
SAXException

processAttributeSection

private AttributeActionSet processAttributeSection(ModeUsage modeUsage,
                                                   String ns,
                                                   IntSet indexSet,
                                                   Attributes attributes)
                                            throws SAXException
Throws:
SAXException

validateAttributes

private void validateAttributes(Schema schema,
                                Attributes attributes)
                         throws SAXException
Throws:
SAXException

startSection

private void startSection(String uri)
                   throws SAXException
Throws:
SAXException

initHandler

private void initHandler(ContentHandler ch)
                  throws SAXException
Throws:
SAXException

endElement

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

endSection

private void endSection()
                 throws SAXException
Throws:
SAXException

cleanupHandler

private void cleanupHandler(ContentHandler vh)
                     throws SAXException
Throws:
SAXException

endDocument

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

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException

createValidator

private Validator createValidator(Schema schema)

releaseValidator

private void releaseValidator(Schema schema,
                              Validator vh)

reset

public void reset()
Description copied from interface: Validator
Cleans up after validating a document. After completing validation of a document, reset must be called. After calling reset(), another document may be validated. Calling this method may create new ContentHandler and DTDHandler objects or may simply reinitialize the state of the existing objects.

Specified by:
reset in interface Validator

getContentHandler

public ContentHandler getContentHandler()
Description copied from interface: Validator
Returns the ContentHandler that will receive the XML document. Information about the XML document to be validated must be reported by calling methods on the returned ContentHandler. When validation of an XML document has been completed (either endDocument() has been called or validation has been abandoned prematurely), reset() must be called. If no calls are made on the ContentHandler, then reset() need not be called. Implementations should allocate resources that require cleanup (e.g. threads, open files) lazily, typically in startDocument(). This method does not change the state of the Validator: the same object will always be returned unless reset is called.

Specified by:
getContentHandler in interface Validator
Returns:
a ContentHandler, never null
See Also:
Validator.reset()

getDTDHandler

public DTDHandler getDTDHandler()
Description copied from interface: Validator
Returns a DTDHandler. Information about the DTD must be reported by calling methods on the returned object, unless null is returned. The same object will always be returned unless reset is called: this method does not change the state of the Validator.

Specified by:
getDTDHandler in interface Validator
Returns:
a DTDHandler, maybe null if DTD information is not significant to the Validator