com.thaiopensource.relaxng.impl
Class PatternValidator
java.lang.Object
com.thaiopensource.relaxng.parse.sax.DtdContext
com.thaiopensource.relaxng.impl.PatternValidator
- All Implemented Interfaces:
- Validator, ValidationContext, ContentHandler, DTDHandler
- Direct Known Subclasses:
- VerifierHandlerImpl
public class PatternValidator
- extends DtdContext
- implements Validator, ContentHandler, DTDHandler
Method Summary |
void |
addDatatypeError(String message,
DatatypeException exception)
|
void |
characters(char[] ch,
int start,
int length)
|
void |
endDocument()
|
void |
endElement(String namespaceURI,
String localName,
String qName)
|
void |
endPrefixMapping(String prefix)
|
private void |
error(SAXParseException e)
|
private void |
error(String key)
|
private Pattern |
findElement(Name name)
|
private PatternMemo |
fixAfter(PatternMemo p)
|
private void |
flushCharacters()
|
String |
getBaseUri()
Returns the base URI of the context. |
ContentHandler |
getContentHandler()
Returns the ContentHandler that will receive the XML document. |
DTDHandler |
getDTDHandler()
Returns a DTDHandler. |
void |
ignorableWhitespace(char[] ch,
int start,
int len)
|
private Name |
peek()
|
private Name |
pop()
|
void |
processingInstruction(String target,
String date)
|
private void |
push(Name name)
|
void |
reset()
Cleans up after validating a document. |
String |
resolveNamespacePrefix(String prefix)
Resolves a namespace prefix to the corresponding namespace URI. |
void |
setDocumentLocator(Locator loc)
|
private boolean |
setMemo(PatternMemo m)
|
void |
skippedEntity(String name)
|
private void |
startCollectingCharacters()
|
void |
startDocument()
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
|
void |
startPrefixMapping(String prefix,
String uri)
|
private void |
text()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
builder
private final ValidatorPatternBuilder builder
start
private final Pattern start
eh
private final ErrorHandler eh
recoverPatternTable
private Hashtable recoverPatternTable
memo
private PatternMemo memo
hadError
private boolean hadError
collectingCharacters
private boolean collectingCharacters
charBuf
private final StringBuffer charBuf
prefixMapping
private PatternValidator.PrefixMapping prefixMapping
locator
private Locator locator
datatypeErrors
private final Map datatypeErrors
stack
private Name[] stack
stackLen
private int stackLen
suppressDepth
private int suppressDepth
PatternValidator
public PatternValidator(Pattern pattern,
ValidatorPatternBuilder builder,
ErrorHandler eh)
startCollectingCharacters
private void startCollectingCharacters()
flushCharacters
private void flushCharacters()
throws SAXException
- Throws:
SAXException
startElement
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException
- Specified by:
startElement
in interface ContentHandler
- Throws:
SAXException
fixAfter
private PatternMemo fixAfter(PatternMemo p)
endElement
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException
- Specified by:
endElement
in interface ContentHandler
- Throws:
SAXException
characters
public void characters(char[] ch,
int start,
int length)
throws SAXException
- Specified by:
characters
in interface ContentHandler
- Throws:
SAXException
text
private void text()
throws SAXException
- Throws:
SAXException
endDocument
public void endDocument()
- Specified by:
endDocument
in interface ContentHandler
setDocumentLocator
public void setDocumentLocator(Locator loc)
- Specified by:
setDocumentLocator
in interface ContentHandler
startDocument
public void startDocument()
throws SAXException
- Specified by:
startDocument
in interface ContentHandler
- Throws:
SAXException
processingInstruction
public void processingInstruction(String target,
String date)
- Specified by:
processingInstruction
in interface ContentHandler
skippedEntity
public void skippedEntity(String name)
- Specified by:
skippedEntity
in interface ContentHandler
ignorableWhitespace
public void ignorableWhitespace(char[] ch,
int start,
int len)
- Specified by:
ignorableWhitespace
in interface ContentHandler
startPrefixMapping
public void startPrefixMapping(String prefix,
String uri)
- Specified by:
startPrefixMapping
in interface ContentHandler
endPrefixMapping
public void endPrefixMapping(String prefix)
- Specified by:
endPrefixMapping
in interface ContentHandler
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)
throws SAXException
- Throws:
SAXException
error
private void error(SAXParseException e)
throws SAXException
- Throws:
SAXException
setMemo
private boolean setMemo(PatternMemo m)
findElement
private Pattern findElement(Name name)
resolveNamespacePrefix
public String resolveNamespacePrefix(String prefix)
- Description copied from interface:
ValidationContext
- Resolves a namespace prefix to the corresponding namespace URI.
This method is used for validating the QName type, for example.
If the prefix is "" (empty string), it indicates
an unprefixed value. The callee
should resolve it as for an unprefixed
element, rather than for an unprefixed attribute.
If the prefix is "xml", then the callee must resolve
this prefix into "http://www.w3.org/XML/1998/namespace",
as defined in the XML Namespaces Recommendation.
- Specified by:
resolveNamespacePrefix
in interface ValidationContext
- Returns:
- namespace URI of this prefix.
If the specified prefix is not declared,
the implementation must return null.
getBaseUri
public String getBaseUri()
- Description copied from interface:
ValidationContext
- Returns the base URI of the context. The null string may be returned
if no base URI is known.
- Specified by:
getBaseUri
in interface ValidationContext
addDatatypeError
public final void addDatatypeError(String message,
DatatypeException exception)
push
private final void push(Name name)
pop
private final Name pop()
peek
private final Name peek()