com.thaiopensource.validate.mns
Class ValidatorImpl
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.thaiopensource.validate.mns.ValidatorImpl
- All Implemented Interfaces:
- Validator, ContentHandler, DTDHandler, EntityResolver, ErrorHandler
class ValidatorImpl
- extends DefaultHandler
- implements Validator
Method Summary |
void |
characters(char[] ch,
int start,
int length)
|
private Validator |
createValidator(Schema schema)
|
void |
endDocument()
|
void |
endElement(String uri,
String localName,
String qName)
|
void |
endPrefixMapping(String prefix)
|
private void |
endSubtree(ContentHandler ch)
|
private void |
error(String key,
String arg)
|
ContentHandler |
getContentHandler()
Returns the ContentHandler that will receive the XML document. |
DTDHandler |
getDTDHandler()
Returns a DTDHandler. |
private SchemaImpl.Mode |
getMode()
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
|
private boolean |
namespaceCovered(String ns)
|
private void |
releaseValidator(Schema schema,
Validator validator)
|
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 |
startSubtree(ContentHandler ch)
|
private void |
validateAttributes(String ns,
Attributes attributes)
|
private boolean |
wantsEvent(ValidatorImpl.Subtree st)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
currentMode
private SchemaImpl.Mode currentMode
laxDepth
private int laxDepth
eh
private final ErrorHandler eh
properties
private final PropertyMap properties
locator
private Locator locator
subtrees
private ValidatorImpl.Subtree subtrees
attributeNamespaces
private final Hashset attributeNamespaces
prefixMapping
private ValidatorImpl.PrefixMapping prefixMapping
localizer
private final Localizer localizer
validatorCache
private final Hashtable validatorCache
ValidatorImpl
ValidatorImpl(SchemaImpl.Mode mode,
PropertyMap properties)
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
getMode
private SchemaImpl.Mode getMode()
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
namespaceCovered
private boolean namespaceCovered(String ns)
wantsEvent
private boolean wantsEvent(ValidatorImpl.Subtree st)
validateAttributes
private void validateAttributes(String ns,
Attributes attributes)
throws SAXException
- Throws:
SAXException
startSubtree
private void startSubtree(ContentHandler ch)
throws SAXException
- Throws:
SAXException
endSubtree
private void endSubtree(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
createValidator
private Validator createValidator(Schema schema)
releaseValidator
private void releaseValidator(Schema schema,
Validator validator)
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
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
error
private void error(String key,
String arg)
throws SAXException
- Throws:
SAXException