X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FFieldList.java;h=26ac966a28a94eff7f45ca953b07f08d36545106;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=58cf6d50ec318ab20bd40e7a7efa5a165f5b69ca;hpb=312fec956e43f5d0a38617da5d0add9c62563e2c;p=GpsPrune.git diff --git a/tim/prune/data/FieldList.java b/tim/prune/data/FieldList.java index 58cf6d5..26ac966 100644 --- a/tim/prune/data/FieldList.java +++ b/tim/prune/data/FieldList.java @@ -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,18 +135,39 @@ 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 */ public String toString() { StringBuffer buffer = new StringBuffer(); - buffer.append("("); + buffer.append('('); for (int i=0; i<_fieldArray.length; i++) { buffer.append(_fieldArray[i].getName()).append(','); } - buffer.append(")"); + buffer.append(')'); return buffer.toString(); } }