Wednesday, November 17, 2010

Prettier Every Day

After yesterday's brute-force parsing adventure, I set forward to-day to finish what I started... and I succeeded! I really am quite pleased with the pace that this project is going.  In roundabouts two weeks, give or take a few days, I've managed to not only figure out how to get the data I wanted but how to chop it up and display it in a format most would find agreeable.  This is where refinement comes in, different forms of display, different functionalities and all the bells and whistles associated and in excess.

So, more concisely, to-day I went through some parsing adventures, writing out my ResultHandler in a way that it would traverse the haphazardly modified HTML from yesterday.  Misadventures are as follows:

  • Not all the tags had a class attribute, which is what all of the book information had and needed to be checked against.  This rewarded me with a NullPointerException whenever I tried to check it against the tags for each part of the book info, which leads me to...
  • if (atts.getValue("class") == "book-desc") or anything similar will always return false.  Why this is, I'm not entirely sure, but thankfully changing the check around to if (atts.getValue("class").equals("book-desc")) worked perfectly.
  • Doing a book.setTitle(ch.toString()) gave me some weird garble in the title field instead of the proper title, despite the title being read in.  Doing book.setTitle(new String(ch, start, length)) with all the values passed into the character parsing function did fine.
All in all, not too bad.  I'm getting the hang of writing custom SAX handlers, for both XML and what I hesitantly call XHTML to suit my needs.  Things can still be condensed and made more elegant, but for functionality, I've got it more or less down.

Tomorrow I'll make a short video showing off our current place in the process and going over some cool features.  For now, I'm happy with the progress.  I'm getting more confident with my skills as both a Java programmer and as an Android developer, and really, that's all I could ask of this project.  I'm also happy with  how quickly things have gotten up and running, despite all of the setbacks and the general lack of knowledge I started with.

Teaser screencap!


No comments:

Post a Comment