com.cutunes.client
Class ItunesXMLParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.cutunes.client.ItunesXMLParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

Extends the SAX DefaultHandler to correctly parse iTunes XML files in the Apple plist DTD format. Parses and extracts all track information (song name, album, artist, year, playcount, last play date, etc) placed information in a Hashtable which is then passed back to the ClientCommuniciator. When I sufficient number of song Hashtables have been queued in the ClientCommunicator, they are sent to the server.

Author:
hal2001

Constructor Summary
ItunesXMLParser()
           
 
Method Summary
 void characters(char[] buf, int offset, int len)
          SAX DocumentHandler method for XML element characters.
 void endDocument()
          SAX DocumentHandler method for document end.
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          SAX DocumentHandler method for XML element end.
 void startDocument()
          SAX DocumentHandler method for document start.
 void startElement(java.lang.String namespaceURI, java.lang.String lName, java.lang.String qName, org.xml.sax.Attributes attrs)
          SAX DocumentHandler method for XML element start.
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItunesXMLParser

public ItunesXMLParser()
Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
SAX DocumentHandler method for document start.

Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
SAX DocumentHandler method for document end.

Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String lName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
SAX DocumentHandler method for XML element start. Keeps track of how deep in the dict elements we are, and whether we have entered a "Tracks" element or not.

Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
SAX DocumentHandler method for XML element end. Keeps track of how deep in the dict elements we are, and whether we have exited a "Tracks" element or not. If we leave a Tracks element, a new SongHash is added to the SongHash queue in the ClientCommunicator.

Throws:
org.xml.sax.SAXException

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
SAX DocumentHandler method for XML element characters. If currently inside a "Tracks" dictionary element, characters are parsed for all relevant information (Track ID, Name, Artist, Album, etc).

Throws:
org.xml.sax.SAXException