This piece of code constructs the String which is passed to the criteria find method.I would like to know whether this is appropriate. /** I have used 2 constants to get the corresponding column name from the database */ public static final int SEARCH_FIELD_FIRST_INDEX = 1; public static final int SEARCH_FIELD_SECOND_INDEX = 2; FieldInfo[] schema; FieldInfo info; String fieldOne, fieldTwo; schema = dbFile.getFieldInfo(); info = schema[ SEARCH_FIELD_FIRST_INDEX ]; fieldOne = info.getName(); info = schema[ SEARCH_FIELD_SECOND_INDEX ]; fieldTwo = info.getName(); /** Here I do the concatenation */ String toFind = fieldOne + "=" + "'" + (String)listOrg .getSelectedItem() + "'" + "," + fieldTwo + "=" + "'" + (String)listDes.getSelectedItem() + "'"; dbFile.criteriaFind( toFind ); This string goes to the criteria find method of the Data class. I thought if the application is modified later & some other search criteria is used, then all they have to do is to change the constants. Is this construction of the String correct? plz reply. poornima.
Vivek Viswanathan
Ranch Hand
Joined: Mar 03, 2001
Posts: 350
posted
0
Hi Probally you could shift the constants to an interface, and declare the constants as public static final and use this constans in your program as interfaceName.CONSTANT_NAME that will be a better desing, as it will allow for a more gracefull change. Actually that is what I did. Vivek Viswanathan
[This message has been edited by Vivek Viswanathan (edited June 19, 2001).]