xBaseJ
Class XBASEXMLParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--xBaseJ.XBASEXMLParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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


Constructor Summary
XBASEXMLParser()
          constructor, sets up SAX parser, turns off validation, turns on namespaces, sets up content handler and error handler as this object.
 
Method Summary
 void characters(char[] ch, int start, int length)
          catches the element's value
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          Method called by the SAX parser at the
 void error(org.xml.sax.SAXParseException e)
          catches error SAXParseExceptions this code causes exception to continue
 void fatalError(org.xml.sax.SAXParseException e)
          catches fatal SAXParseExceptions this code causes exception to continue
 void ignorableWhitespace(char[] ch, int start, int length)
          I use this to keep track of line #s
static void main(java.lang.String[] args)
          accepts on String parameter, filename to parse
 void parse(java.lang.String inXMLFile)
          makes the SAX2 parser call
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)
          method called for each xml element found.
 void warning(org.xml.sax.SAXParseException e)
          catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XBASEXMLParser

public XBASEXMLParser()
constructor, sets up SAX parser, turns off validation, turns on namespaces, sets up content handler and error handler as this object. sax exceptions go to System.err

Method Detail

main

public static void main(java.lang.String[] args)
accepts on String parameter, filename to parse


parse

public void parse(java.lang.String inXMLFile)
makes the SAX2 parser call

Parameters:
inXMLFile - String of filename to parse

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
method called for each xml element found.
process logic

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
attributes - Vector of the elements attributes
Throws:
org.xml.sax.SAXException - many possible exceptions

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
catches the element's value

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - char array of the current element value contents
start - int start position within the array
length - int of characters found so far
Throws:
org.xml.sax.SAXException - many possible

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws org.xml.sax.SAXException
Method called by the SAX parser at the
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
Throws:
org.xml.sax.SAXException - many possible

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
I use this to keep track of line #s

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - char array of found whitespaces
start - int start position in array
length - int length of what's been found

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SaxException object
Throws:
org.xml.sax.SAXException - exception

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
catches error SAXParseExceptions this code causes exception to continue

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SaxException object
Throws:
org.xml.sax.SAXException - thrown

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
catches fatal SAXParseExceptions this code causes exception to continue

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SAXException object
Throws:
org.xml.sax.SAXException - thrown