Hello everybody,
Following are the lines from requirements
/* Start here*/
public DataInfo[] criteriaFind(
String criteria)
This method searches the database for entries matching the criteria supplied. Criteria take the form of a comma separated list of <field name>=<value to match> specifications. For example, the following argument string would select all records describing flights by the SpeedyAir carrier that originate in San Francisco.
"Carrier='SpeedyAir',Origin='SFO'" /*Line A*/ /*ends here*/
I got stuck with construction of String criteria. As per my understanding, once I get values of Origin and destination airports from JComboBoxes, then I have to convert that values into String criteria = "Origin airport='SFO',Destination airport='Bom' ". And pass this String to public DataInfo[] criteriaFind(Strring criteria).
For costructing this String criteria in the format given by line A, I have used follwoing method
/* following is a Search class to populate the values from Database and construct the String criteria
public class Search extends JFrame implements ActionListener{
....
...
...
jlb1 = new JLabel("Origin airport");
jlb2 = new JLabel("Destination airport");
jcb1 = new JComboBox(fbn.getFlight());
jcb2 = new JComboBox(fbn.getFlight());
jb1 = new JButton("Search");
jb2 = new JButton("Clear");
/* all these components are added in a Panel using GridBgaLayout and added actionListener to "search" and "Clear" Buttons*/
public void actionPerformed(ActionEvent event){
Object source = event.getSource();
if(source == jb1){
sb = (jlb1.getText()+"='"+jcb1.getSelectedItem() +"',"+jlb2.getText()+"='" +jcb2.getSelectedItem()+"'");...................Line B
/* String sb is then passed to criteriaFind() method.
}
Question 1: So my Line B constructs String into form
"Origin airport='SFO', Destination airport='Bom'" . Is this a correct way of doing it? Or I am going in wrong direction? Any hint to construct the String is appreciated.
Question 2: I am constructing String critaria as
"Origin airport='SFO', Destination airport='Bom'" and not as
[b]"Origin='SFO', Destination='Bom'"[b] given as per SUN requirements. Because my criteriaFind() methos needs complete name of fields to passed. So that it compares with database fieldnames. I will document in my Design documnet all this stuff.
Is this O.K.? Or the marks will be reduced.
Thanks
Pratibha