gate.xml
Class XmlPositionCorrectionHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bygate.xml.XmlPositionCorrectionHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
XmlDocumentHandler

public class XmlPositionCorrectionHandler
extends org.xml.sax.helpers.DefaultHandler

This class correct a Xerces parser bug in reported position in file during the parsing process. Xerces parser cut processed file to 16K peaces. If the parser cross the 16K border reported in the characters() position is zerro. This bug could be covered if you extend this content handler instead of org.xml.sax.helpers.DefaultHandler. The real content handler should call methods startDocument() and characters() in order to compute correct position in file. The corrected position could be received throug protected data member m_realOffset or with getRealOffset().


Field Summary
private static boolean DEBUG
          Debug flag
private  int m_lastPosition
           
private  int m_lastSize
           
private  int m_multiplyer
           
protected  long m_realOffset
          Variables for correction of 16K parser limit for offset
 
Constructor Summary
XmlPositionCorrectionHandler()
          Constructor for initialization of variables
 
Method Summary
 void characters(char[] text, int offset, int len)
          Here is the correction of the Xerces parser bug.
 long getRealOffset()
          Return corrected offset for last characters() call
 void startDocument()
          Initialization of variables on start of document parsing
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values

m_realOffset

protected long m_realOffset
Variables for correction of 16K parser limit for offset


m_lastPosition

private int m_lastPosition

m_lastSize

private int m_lastSize

m_multiplyer

private int m_multiplyer
Constructor Detail

XmlPositionCorrectionHandler

public XmlPositionCorrectionHandler()
Constructor for initialization of variables

Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Initialization of variables on start of document parsing

Throws:
org.xml.sax.SAXException

getRealOffset

public long getRealOffset()
Return corrected offset for last characters() call


characters

public void characters(char[] text,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
Here is the correction of the Xerces parser bug.

Throws:
org.xml.sax.SAXException