Java IDL parser updated to use derived field array index
authorBill Erickson <berick@esilibrary.com>
Fri, 24 Feb 2012 21:33:58 +0000 (16:33 -0500)
committerJason Stephenson <jstephenson@mvlc.org>
Fri, 14 Dec 2012 21:59:01 +0000 (16:59 -0500)
The "array_position" IDL attribute is deprecated.  Determine the
index by field position within the XML.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/java/org/open_ils/idl/IDLParser.java

index a82b25d..4da147f 100644 (file)
@@ -29,6 +29,7 @@ public class IDLParser {
     InputStream inStream;
     HashMap<String, IDLObject> IDLObjects;
     IDLObject current;
+    private int fieldIndex;
 
     /** If true, we retain the full set of IDL objects in memory.  This is true by default. */
     private boolean keepIDLObjects;
@@ -39,6 +40,7 @@ public class IDLParser {
         IDLObjects = new HashMap<String, IDLObject>();
         keepIDLObjects = true;
         parsedObjectCount = 0;
+        fieldIndex = 0;
     }
 
     public IDLParser(String fileName) throws IOException {
@@ -122,6 +124,7 @@ public class IDLParser {
         String localpart = reader.getLocalName();
     
         if( "class".equals(localpart) ) {
+            fieldIndex = 0;
             current = new IDLObject();
             current.setIDLClass(reader.getAttributeValue(null, "id"));
             current.setController(reader.getAttributeValue(null, "controller"));
@@ -133,7 +136,7 @@ public class IDLParser {
         if( "field".equals(localpart) ) {
             IDLField field = new IDLField();
             field.setName(reader.getAttributeValue(null, "name"));
-            field.setArrayPos(new Integer(reader.getAttributeValue(OILS_NS_OBJ, "array_position")));
+            field.setArrayPos(fieldIndex++);
             field.setIsVirtual("true".equals(reader.getAttributeValue(OILS_NS_PERSIST, "virtual")));
             current.addField(field);
         }