psnarula All American 1540 Posts user info edit post |
I'm parsing XML using SAX for a class I'm taking at Johns Hopkins. The teacher gave us a class to extend. His class extends DefaultHandler. Here is his class:
public abstract class XMLLoaderBase extends DefaultHandler {
public abstract void endElement(String uri, String localName, String qName) throws SAXException;
// other stuff... }
His class has lots of stuff in it but the endElement method is all I care about right now. He's overriding this method from the DefaultHandler class.
My class extends his:
public class JobRequestXMLLoader extends XMLLoaderBase {
SimpleDateFormat sdf_;
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("due-date")) { date_ = sdf_.parse(text); } } }
so basically whenever I see the end of the "due-date" tag, I want to turn the enclosed String (which I'm calling "text") into a java.util.Date by using the SimpleDateFormat.parse() method. The problem is that the parse method throws a ParseException. I can't add the ParseException to the endElement method signature because then I'm not overriding the abstract method from my instructor's class.
I tried adding the ParseException to endElement and then renaming the method "myEndElement" while also making another endElement method that just calls myEndElement but Eclipse complains that the myEndElement method has "Unhandled exception type ParseException". So how do I fix this?2/24/2006 1:10:33 PM |