Listing 1212 Job ListHandlerjava

package com.msi.manning.UnlockingAndroid;

/ / multiple imports omitted for brevity, see full source code public class JobListHandler extends DefaultHandler { Handler phandler = null; JobList _list; JobEntry _job;

String _lastElementName = ""; StringBuilder sb = null;

Context _context; O JobListHandler

JobListHandler (Context c,Handler progresshandler) { <1-I constructor

if (progresshandler != null) { Q Check for phandler = progresshandler; <1-1 progress handler

msg.obj = (Object)("Processing List"); phandler.sendMessage(msg) ;

} © getList public JobList getList () { <-1 method

msg.obj = (Object)("Fetching List"); if (phandler != null) phandler.sendMessage(msg); return _list;

} Q startDocument public void startDocument () throws SAXException { <1-' method

msg.obj = (Object)("Starting Document"); if (phandler != null) phandler.sendMessage(msg); _list = new JobList(_context); _job = new JobEntry () ; } Q endDocument public void endDocument() throws SAXException { <-' method

msg.obj = (Object)("End of Document"); if (phandler != null) phandler.sendMessage(msg);

public void startElement

^ (String namespaceURI, String localName,String qName, ^ Attributes atts) throws SAXException { try {

sb = new StringBuilder("");

if (localName.equals("job")) { Message msg = new Message(); msg. what = 0 ;

msg.obj = (Object)(localName);

if (phandler != null) phandler.sendMessage(msg); _job = new JobEntry() ;

public void endElement

^ (String namespaceURI, String localName, String qName)

^ throws SAXException {

if (localName .equals ("job") ) { <-1 Check for end

_list.addJob(_job); Message msg = new Message(); msg. what = 0 ;

msg.obj = (Object)("Storing Job # " + _job.get_jobid()); if (phandler != null) phandler.sendMessage(msg); return;

// portions of the code omitted for brevity

public void characters(char ch[] , int start, int length) { String theString = new String(ch,start,length); Log.d("CH12","characters[" + theString + "]"); sb. append (theString) ; <1-1

0 0

Post a comment