I would like to add a new attribute to a schema and then start adding values
to the added attribute however I am 

having problems with it.

 

I have a shapefile from which I get:

 

FeatureCollection allFeatures;

FeatureSchema lyrSchema = allFeatures.getFeatureSchema();

Iterator fIt = allFeatures.iterator();

 

                        //check to see if attribute does not exist already

        if(!lyrSchema.hasAttribute("myField")){

          lyrSchema.addAttribute("myField",AttributeType.STRING);

        } 

                        //loop through all the features and add an attribute
value in the 'myField' column

                        while (fIt.hasNext()){

            Feature currFeature = (Feature)fIt.next();

            currFeature.setSchema(lyrSchema);

            String attrValue = "someText";

            currFeature.setAttribute("myField",attrValue); // program
crashes here

        }

                        

                        

I have checked and I am sure I can get the attribute index of the 'myField'
attribute that has just been added.

However, for some reason I am not able to add the attribute value.   

 

It gives me this error:

Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 4

 

Any ideas or help will be appreciated.  

Thanks,

Anthony


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.6/900 - Release Date: 7/14/2007
3:36 PM
 
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to