×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




<snip>
Just 1 question. Is there any restriction or scoping as to what can be
called from the ContentHandler methods against ordinary methods? I
instantiated the Date class in the startDocument method to a member level
variable and then did t oString() to print the start time:
        d = new Date();
        System.out.println(d.toString());
This printed OK but when I did  System.out.println(d.toString());  to
print the end time in the endDocument method I got a null exception on
reference d. I expected this to work since d was a member variable. Does
anyone the cause of this and a workaround other than a second Date
instantiation.
</snip>

No, the Java compilers don't apply any extra rules because you happen to be
using a ContentHandler.  It's just Java code.  The ContentHandler methods
**are** ordinary methods.  Your problem probably arises because variable d
is also a local variable in the startDocument method (or maybe the
endDocument method) as well as being a member variable.  Or perhaps d was a
member variable of something else.  Would be easier to tell by looking at
the code.

And, if you wanted to print the end time you would have had to create a
second Date object to do that anyway, in the endDocument method.  A Date
object doesn't change its value as time goes on.

PC2


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.