I'm using Apache Commons Digester together with Lucene to index a xml collection. Some fields in the colleciton are not always available. See example:

<doc>
..
<geo></geo>
</doc>

<doc>
..
<geo>
<latitude>2432</latitude>
<longitude>2342</longitude>
</geo>
</doc>

I'm now wondering how to avoid to get a NullPointerException but only execute the following lines if the geo tag is available...

digester.addCallMethod("collection/doc/geo/latitude", "setLatitude", 0);
digester.addCallMethod("collection/doc/geo/longitude", "setLongitude", 0);thanks