/** this method will write its value from the row to the record data byte array */ public void writeOnArray(CobolRow row, byte[] recordData) { Object value = row.get(this.getName()); ByteConverter converter; if (this.isArray()) { // check for array first adjust size if necessary if (this.dependsOn()) { adjustArraySize(row); } int offset = this.getOffset(); Iterator elements = ((List) value).iterator(); for (int i = this.getArraySize(); i > 0; i--) { FieldMetaData fieldCopy = this.deepCopy(); fieldCopy.setOffset(offset); converter = new ByteConverter(fieldCopy, recordData); String elementValue = (String) elements.next(); converter.setBytesToValue(elementValue); offset += mySize; } } else { converter = new ByteConverter(this, recordData); converter.setBytesToValue((String) value); } }
/** this method adjusts the array size to the value in its dependent field */ protected void adjustArraySize(CobolRow row) { Integer intValue = Helper.integerFromString(row.get(this.getDependentFieldName()).toString()); if (intValue != null) { this.setArraySize(intValue.intValue()); } }