/** * Get the state of this boolean field. * @return true if true, false if not boolean or null. */ public boolean getState() // init this field override for other value { if (this.getDataClass() == Boolean.class) { Boolean objData = (Boolean)this.getData(); if (objData != null) return objData.booleanValue(); } return false; } /**
/** * Set the data in this field to true or false. */ public int setState(boolean bState, boolean bDisplayOption, int iMoveMode) { Boolean objData = new Boolean(bState); if (this.getDataClass() == Boolean.class) return this.setData(objData, bDisplayOption, iMoveMode); else if (Number.class.isAssignableFrom(this.getDataClass())) return this.setValue(objData.booleanValue() ? 1 : 0, bDisplayOption, iMoveMode); else if (this.getDataClass() == String.class) return this.setString(objData.booleanValue() ? Constants.TRUE : Constants.FALSE, bDisplayOption, iMoveMode); return super.setState(bState, bDisplayOption, iMoveMode); } /**
/** * Are the data in these fields the same type? * @param field The field to check. * @return True if the raw data type is the same for both fields. */ public boolean isSameType(FieldInfo field) { // Copy this data to a field //Change this to lock the objects down first! boolean bSameType = false; if (this.getClass().getName().equals(field.getClass().getName())) bSameType = true; else { Object data = this.getData(); Class<?> classData = this.getDataClass(); if (data != null) classData = data.getClass(); Object fieldData = field.getData(); Class<?> classField = field.getDataClass(); if (fieldData != null) classField = fieldData.getClass(); if (classData.equals(classField)) bSameType = true; } return bSameType; } /**
/** * Are the data in these fields the same type? * @param field The field to check. * @return True if the raw data type is the same for both fields. */ public boolean isSameType(FieldInfo field) { // Copy this data to a field //Change this to lock the objects down first! boolean bSameType = false; if (this.getClass().getName().equals(field.getClass().getName())) bSameType = true; else { Object data = this.getData(); Class<?> classData = this.getDataClass(); if (data != null) classData = data.getClass(); Object fieldData = field.getData(); Class<?> classField = field.getDataClass(); if (fieldData != null) classField = fieldData.getClass(); if (classData.equals(classField)) bSameType = true; } return bSameType; } /**
Class<?> classData = this.getDataClass(); if (classData != Object.class)
/** * Are the data in these fields the same type? * @param field The field to check. * @return True if the raw data type is the same for both fields. */ public boolean isSameType(FieldInfo field) { // Copy this data to a field //Change this to lock the objects down first! boolean bSameType = false; if (this.getClass().getName().equals(field.getClass().getName())) bSameType = true; else { Object data = this.getData(); Class<?> classData = this.getDataClass(); if (data != null) classData = data.getClass(); Object fieldData = field.getData(); Class<?> classField = field.getDataClass(); if (fieldData != null) classField = fieldData.getClass(); if (classData.equals(classField)) bSameType = true; } return bSameType; } /**
if (objData != null) Class<?> classData = this.getDataClass(); if (classData != Object.class) if (classData == objData.getClass())
/** * Convert and move string to this field. * Override this method to convert the String to the actual Physical Data Type. * @param bState the state to set the data to. * @param bDisplayOption Display the data on the screen if true. * @param iMoveMode INIT, SCREEN, or READ move mode. * @return The error code (or NORMAL_RETURN). */ public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value { try { Object objData = Converter.convertObjectToDatatype(strString, this.getDataClass(), null, m_ibScale); if (objData == null) if (this.getDataClass() != Boolean.class) if (!(Number.class.isAssignableFrom(this.getDataClass()))) if (this.getDataClass() != java.util.Date.class) objData = Constants.BLANK; // To set a null internally, you must call setData directly return this.setData(objData, bDisplayOption, iMoveMode); } catch (Exception ex) { String strError = ex.getMessage(); if (strError == null) strError = ex.getClass().getName(); if (this.getRecord() != null) if (this.getRecord().getTask() != null) return this.getRecord().getTask().setLastError(strError); return Constants.ERROR_RETURN; } } /**
/** * Retrieve (in string format) from this field. * @return This field converted to a string. */ public String getString() { try { return Converter.formatObjectToString(this.getData(), this.getDataClass(), this.getDefault()); } catch (Exception ex) { return null; } } /**
/** * Move the data in this record to the thin version. * @param fieldInfo The destination thin field. * @param field The source field (or null to auto-find) * @param record The source record (or null if field supplied) */ public void moveFieldToThin(FieldInfo fieldInfo, BaseField field, Record record) { if ((field == null) || (!field.getFieldName().equals(fieldInfo.getFieldName()))) { field = null; if (record != null) field = record.getField(fieldInfo.getFieldName()); } if (field != null) { if (field.getDataClass() == fieldInfo.getDataClass()) fieldInfo.setData(field.getData()); else fieldInfo.setString(field.toString()); } } /**
/** * Move the data in this record to the thin version. * @param fieldInfo The destination thin field. * @param field The source field (or null to auto-find) * @param record The source record (or null if field supplied) */ public void moveFieldToThin(FieldInfo fieldInfo, BaseField field, Record record) { if ((field == null) || (!field.getFieldName().equals(fieldInfo.getFieldName()))) { field = null; if (record != null) field = record.getField(fieldInfo.getFieldName()); } if (field != null) { if (field.getDataClass() == fieldInfo.getDataClass()) fieldInfo.setData(field.getData()); else fieldInfo.setString(field.toString()); } } /**
/** * Move the data in this record to the thin version. * @param fieldInfo The destination thin field. * @param field The source field (or null to auto-find) * @param record The source record (or null if field supplied) */ public void moveFieldToThin(FieldInfo fieldInfo, BaseField field, Record record) { if ((field == null) || (!field.getFieldName().equals(fieldInfo.getFieldName()))) { field = null; if (record != null) field = record.getField(fieldInfo.getFieldName()); } if (field != null) { if (field.getDataClass() == fieldInfo.getDataClass()) fieldInfo.setData(field.getData()); else fieldInfo.setString(field.toString()); } } /**
/** * */ private FieldList cloneFieldList(FieldList item) { FieldList fieldList = new FieldList(null); for (int i = 0; i < item.getFieldCount(); i++) { FieldInfo fldSource = item.getField(i); FieldInfo fldDest = new FieldInfo(fieldList, fldSource.getFieldName(), fldSource.getMaxLength(), fldSource.getFieldDesc(), fldSource.getDefault()); fldDest.setDataClass(fldSource.getDataClass()); } return fieldList; } /**
else if ((fieldInfo.getField().getDataClass() == Double.class) && (!fieldInfo.getFieldName().contains("rice")))
else if ((fieldInfo.getField().getDataClass() == Double.class) && (!fieldInfo.getFieldName().contains("Price")))
field.setDataClass(fieldActual.getDataClass());