|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
bodhidharma.xml_parsing.ParseFileHandler
bodhidharma.xml_parsing.ParseRecordingsFileHandler
public class ParseRecordingsFileHandler
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 recordings_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.
After parsing, the parsed_file_contents field will hold an
array of objects. All of the objects will be Recording
objects
with fields filled based on the tags in the parsed document.
The leaf_categories fields of these Recording
objects
will be filled, but the ancestor_categories fields will not (set to null).
If a lear category is not specified in the file, it will be filled in with "Unknown".
The file_path fields will be filled with a concatonation of the
file_path tag of the parsed file and the filename tag
for each recording, with the result being a path relative to the
recordings_file file that has been parsed.
Bodhidharma
,
Recording
,
RecordingsPanel
,
ParseFileHandler
,
XMLDocumentParser
,
DefaultHandler
,
ContentHandler
,
XMLReader
,
LinkedList
Field Summary |
---|
Fields inherited from class bodhidharma.xml_parsing.ParseFileHandler |
---|
parsed_file_contents |
Constructor Summary | |
---|---|
ParseRecordingsFileHandler()
|
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
This method responds to the contents of tags in a way determined by the name of the tag (as determined by the startElement method). |
void |
endDocument()
This method is called when the end tag of an XML element is encountered. |
void |
endElement(java.lang.String namespace,
java.lang.String name,
java.lang.String qName)
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 |
---|
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 |
---|
public ParseRecordingsFileHandler()
Method Detail |
---|
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
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
characters
method know what kind of action to take.
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
name
- Name of the element that is encountered.
org.xml.sax.SAXException
- Exception thrown if is wrong type of XML file.public void characters(char[] ch, int start, int length)
startElement
method).
Simply stores the names of the piece title or artist in a
Recording
object if the title or artist
tags were just encountered. Stores the concatonation of the
contents of the file_path and filename tags in
the Recording
object. Sets the appropriate boolean
fields of the Recording
object based on the contents
of the role tag (the acceptable values are training,
testing or classification). Stores the contents of
genre tags in a list that is later converted to an array
and stored in the Recording
object by the
endElement
method.
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
public void endElement(java.lang.String namespace, java.lang.String name, java.lang.String qName)
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
name
- Name of the element that is encountered.public void endDocument()
LinkedList
.
If a lear category is not specified, fills it in with "Unknown".
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |