bodhidharma.xml_parsing
Class ParseClassifiersFileHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by bodhidharma.xml_parsing.ParseFileHandler
          extended by bodhidharma.xml_parsing.ParseClassifiersFileHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ParseClassifiersFileHandler
extends ParseFileHandler

An extension of the Xerces XML DefaultHandler class that implements the SAX ContentHandler. The methods of this class are called by an instance of an XMLReader while it is parsing an XML document.

This particular implementation is custom designed to parse XML files of the classifiers_file type used by the Bodhidharma music classification system. A custom exceptions is thrown if the file is not of this type. At the end of parsing, the contents of the files elements are stored in the parsed_file_contents field.

See Also:
ParseFileHandler, Bodhidharma, XMLDocumentParser, DefaultHandler, ContentHandler, XMLReader
Author:
Cory McKay

Field Summary
 
Fields inherited from class bodhidharma.xml_parsing.ParseFileHandler
parsed_file_contents
 
Constructor Summary
ParseClassifiersFileHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          This stores the contents of elements in the appropriate element of the parsed_file_contents array.
 void endDocument()
          This method is called when the end tag of an XML element is encountered.
 void startDocument()
          This method is called when the start of the XML file to be parsed is reached.
 void startElement(java.lang.String namespace, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atts)
          This method is called when the start of an XML element is encountered.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseClassifiersFileHandler

public ParseClassifiersFileHandler()
Method Detail

startDocument

public void startDocument()
This method is called when the start of the XML file to be parsed is reached. Initializes the parsed_file_contents field to an array of empty strings and initializes the count to 0.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(java.lang.String namespace,
                         java.lang.String name,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
This method is called when the start of an XML element is encountered. Increments the count when this occurs.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
name - Name of the element that is encountered.
Throws:
org.xml.sax.SAXException - Exception thrown if is wrong type of XML file.

characters

public void characters(char[] ch,
                       int start,
                       int length)
This stores the contents of elements in the appropriate element of the parsed_file_contents array.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
This method is called when the end tag of an XML element is encountered. Fills the parsed_file_contents field with the set_paths and ensemble_file_paths.

After this mehtod is called, the parsed_file_contents field will hold information in the following order: classifier_sub_folder_path, testing_recordings_file_path, model_testing_classifications_file_path and each of the NN_BioKNN_Ensemble_file_paths.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler