com.simonstl.ool
Class OolBaseSAXFilter

java.lang.Object
  |
  +--org.xml.sax.helpers.XMLFilterImpl
        |
        +--com.simonstl.ool.OolBaseSAXFilter
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

public class OolBaseSAXFilter
extends org.xml.sax.helpers.XMLFilterImpl

This class is the first phase of converting XML documents into Oolish XML documents. It replaces all character events with empty ool:text elements and diverts the text to a separate file.

Version:
0.01 $Date: 2002/04/12 $
Author:
Simon St.Laurent

Field Summary
protected  java.io.Writer content
           
protected  int currentPosition
           
protected  boolean preserveWhitespace
           
 
Constructor Summary
OolBaseSAXFilter(org.xml.sax.XMLReader parent)
          A constructor that takes the parser which will feed it SAX events
 
Method Summary
 void characters(char[] ch, int start, int len)
          the characters event does the bulk of the work, sending text one way and elements (supplemented with Ool elements) another.
 java.io.Writer getContent()
          Returns the Writer containing all the text.
 int getCurrentPosition()
          gets the current character position.
 boolean getPreserveWhitespace()
          returns whether or not the filter is preserving "ignorable whitespace", per SAX rules.
 void ignorableWhitespace(char[] ch, int start, int len)
          the ignorableWhitespace event sends its information the characters() method if whitespace is being preserved, and passes it up the SAX chain otherwise.
 void setContent(java.io.Writer _content)
          Takes a writer into which all the text of the document will go.
 void setCurrentPosition(int _position)
          sets the current character position.
 void setPreserveWhitespace(boolean _preserve)
          sets whether or not to preserve "ignorable whitespace", per SAX rules.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
           
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

content

protected java.io.Writer content

currentPosition

protected int currentPosition

preserveWhitespace

protected boolean preserveWhitespace
Constructor Detail

OolBaseSAXFilter

public OolBaseSAXFilter(org.xml.sax.XMLReader parent)
A constructor that takes the parser which will feed it SAX events
Method Detail

setContent

public void setContent(java.io.Writer _content)
Takes a writer into which all the text of the document will go.

getContent

public java.io.Writer getContent()
Returns the Writer containing all the text.

setCurrentPosition

public void setCurrentPosition(int _position)
sets the current character position. useful only if you've inserted or deleted text content.

getCurrentPosition

public int getCurrentPosition()
gets the current character position.

setPreserveWhitespace

public void setPreserveWhitespace(boolean _preserve)
sets whether or not to preserve "ignorable whitespace", per SAX rules.

getPreserveWhitespace

public boolean getPreserveWhitespace()
returns whether or not the filter is preserving "ignorable whitespace", per SAX rules.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl

characters

public void characters(char[] ch,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
the characters event does the bulk of the work, sending text one way and elements (supplemented with Ool elements) another.
Overrides:
characters in class org.xml.sax.helpers.XMLFilterImpl

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int len)
                         throws org.xml.sax.SAXException
the ignorableWhitespace event sends its information the characters() method if whitespace is being preserved, and passes it up the SAX chain otherwise.
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.XMLFilterImpl