fi.iki.hsivonen.xml.checker
Class TextContentChecker

java.lang.Object
  extended by fi.iki.hsivonen.xml.checker.Checker
      extended by fi.iki.hsivonen.xml.checker.TextContentChecker
All Implemented Interfaces:
ContentHandler

public final class TextContentChecker
extends Checker

Checks the textContent of elements whose textContent need special non-schema treatment. To smooth code reuse between a conformance checker and editors that only allow RELAX NG plus custom datatypes, this class uses objects that implement DatatypeStreamingValidator.

Examples of elements handled by this class are time, meter and progress.

Version:
$Id: TextContentChecker.java,v 1.6 2006/12/01 12:34:31 hsivonen Exp $
Author:
hsivonen

Field Summary
private  LinkedList<DatatypeStreamingValidator> stack
          The stack of DatatypeStreamingValidators corresponding to open elements.
 
Constructor Summary
TextContentChecker()
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(String uri, String localName, String qName)
           
 void reset()
          Does nothing.
 void startElement(String uri, String localName, String qName, Attributes atts)
           
private  DatatypeStreamingValidator streamingValidatorFor(String uri, String localName, Attributes atts)
          Returns a DatatypeStreamingValidator for the element if it needs textContent checking or null if it does not.
 
Methods inherited from class fi.iki.hsivonen.xml.checker.Checker
endDocument, endPrefixMapping, err, getDocumentLocator, getErrorHandler, ignorableWhitespace, processingInstruction, setDocumentLocator, setErrorHandler, skippedEntity, startDocument, startPrefixMapping, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

private final LinkedList<DatatypeStreamingValidator> stack
The stack of DatatypeStreamingValidators corresponding to open elements. Stack entry is null if the corresponding element does not need textContent checking. Grows from the tail.

Constructor Detail

TextContentChecker

public TextContentChecker()
Constructor.

Method Detail

streamingValidatorFor

private DatatypeStreamingValidator streamingValidatorFor(String uri,
                                                         String localName,
                                                         Attributes atts)
Returns a DatatypeStreamingValidator for the element if it needs textContent checking or null if it does not.

Parameters:
uri - the namespace URI of the element
localName - the local name of the element
atts - the attributes
Returns:
a DatatypeStreamingValidator or null if checks not necessary

characters

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

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class Checker
Throws:
SAXException
See Also:
Checker.endElement(java.lang.String, java.lang.String, java.lang.String)

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class Checker
Throws:
SAXException
See Also:
Checker.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

reset

public void reset()
Description copied from class: Checker
Does nothing. Subclasses are expected to override this method with an implementation that clears the state of the checker and releases objects the checker might hold references to.

Overrides:
reset in class Checker
See Also:
Checker.reset()