]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/FieldList.java
Version 8, September 2009
[GpsPrune.git] / tim / prune / data / FieldList.java
index 58cf6d50ec318ab20bd40e7a7efa5a165f5b69ca..1542f09eab32e593ef1522f49d518e4ac87e2dcc 100644 (file)
@@ -6,6 +6,7 @@ package tim.prune.data;
  */
 public class FieldList
 {
+       /** Array of Field objects making the list */
        private Field[] _fieldArray;
 
 
@@ -29,7 +30,7 @@ public class FieldList
 
        /**
         * Constructor giving array of Field objects
-        * @param inFieldArray
+        * @param inFieldArray array of Field objects
         */
        public FieldList(Field[] inFieldArray)
        {
@@ -62,8 +63,7 @@ public class FieldList
 
 
        /**
-        * Check whether the FieldList contains the given
-        * Field object
+        * Check whether the FieldList contains the given Field object
         * @param inField Field to check
         * @return true if the FieldList contains the given field
         */
@@ -135,6 +135,27 @@ public class FieldList
        }
 
 
+       /**
+        * Extend the field list to include the specified field
+        * @param inField Field to add
+        * @return new index of added Field
+        */
+       public int extendList(Field inField)
+       {
+               // See if field is already in list
+               int currIndex = getFieldIndex(inField);
+               if (currIndex >= 0) return currIndex;
+               // Need to extend - increase array size
+               int oldNumFields = _fieldArray.length;
+               Field[] fields = new Field[oldNumFields + 1];
+               System.arraycopy(_fieldArray, 0, fields, 0, oldNumFields);
+               _fieldArray = fields;
+               // Add new field and return index
+               _fieldArray[oldNumFields] = inField;
+               return oldNumFields;
+       }
+
+
        /**
         * Convert to String for debug
         */