ldonahue

iFeature.getValue - null pointer - Java

Discussion created by ldonahue on Jun 4, 2010
Latest reply on Jun 4, 2010 by ldonahue
ArcGIS Server 9.3.1

I have a featureCursor that contains the result of a spatial query.  There is one record returned from the spatial query.

Some of the field values in my record have no values, which I guess are null values?  Everytime I run this program, I get a null pointer exception, whenever the loop encounters a field value that is null.

I've tried assinging the result of iFeature.getValue(int) to a temp Object, then testing whether that temp Object==null.  If it is null, then don't assign this value to a Bean property.

This works on most of the fields, except some.  I looked up the Java Docs for IField to see what type of field value I should have from the SDE featureclass.
http://resources.esri.com/help/9.3/arcgisserver/adf/java/help/api/arcobjects/com/esri/arcgis/geodatabase/IField.html#getType()

Should I get the value of the field using either of the following?

iFeature.getFields().getField(int).getDefaultValue();
or
iFeature.getValue(int).toString();

featureCursor = featureClass.search(spatFilter, true);
...
iFeature = featureCursor.nextFeature();

if iFeature is not null
  loop through the number of features
    loop through the number of fields
      get the value of each field using the index - this is where I have a problem
      iFeature.getValue(int).toString();

Outcomes