• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selection of Origin , destination or both

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello reader,
My specification says "The user must be able to describe enter the string value "any" for the origin, destination, or both, so as to implement a wildcard-like feature."
With this I think that user would be able to enter the string for example " origin='FRD',destination='klj' ". But I want to ask is only these two column searching is required or other column based searching is required ?. As far as specification goes I think it is only for origin and destination. Secondly, how should I implement wildcard character ?. I mean to say how shall I place asterisk sign (*) in end of value or anywhere in the value. Suggest me how to use sign ? also .
[ July 16, 2002: Message edited by: Gurpreet Saini ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. Yes this area has been confusion to us all. Because they had the following. I took this from my FAQ.
13. What fields should I include in the GUI's search functionality?
In the instructions.html. It is a little unclear as to the minimum fields necessary to search.

The user should be able to select the origin and destination of flights, and the display should update to show only flights that satisfy those criteria. The user must be able to describe enter the string value "any" for the origin, destination, or both, so as to implement a wildcard-like feature.



Is one statement, which makes you need at least origin and destination a must.

Then it also states

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'"



In this example Carrier is also there. Here is where the confusion comes in. In the first statement carrier is not included, but here it is.

My take is to also include carrier.

Now as far as how the client GUI will allow users to enter this information. there are two ways of doing this.
1) have a Jtextfield that the user has to enter the criteria string. This allows the user to type in inccorect string that might make it difficult to program for.
2) Have JComboBox(s) one for each field. Fill them with unique values from the db.db file, and let the user select a value, or leave it blank means "All". Then you can take their selections and make a valid criteria string out of it.
Good luck
Mark
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think option 2 is much better. If you do have more better option then this then also tell me. But you had not mentioned about a wildcard-like feature ?. How can I implement wildcard character by using 3 JComboBoxes ?. Isn't it not talking about (* and ?) characters. Because these two asterisk and question mark are two known wild characters.
Thank you,
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I did to handle * was to have the first option in the JComboBox be "All Departures" or "All Origins" then if the user selected that would be *.
What I really did was to take those and not include them in my criteria string.
For instance
Three JComboBoxes 1,2,3
1 is Origin Airport
2 is Departure Airport
3 is Carrier
User selects 1 to be "All Origins", 2 is "All Departures" and 3 is "All Carriers", then my criteria string is blank or "",
if 1 and 2 are All and 3 is "My Carrier", (I forgot the names of the airports and carriers in db.db) then the criteria string would be "carrier='My Carrier'"
if 1 is All 2 is "SFA" and 3 is "My Carrier" then the criteria string would be "departure='SFA',carrier='My Carrier'"
Hope that makes sense, and ignore that my airport names and field names aren't the exact same as in the db.db file, I just forgot those names.
Mark
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I got the idea of using wild-card characters. As the specifation has mentioned about the criteriaFind(String criteria) method. The parameter criteria should take the argument as follows:
"origin=SFO,carrier=SpeedyAir" .
This parameter will require single client socket communication wih server but will require lot of tiring coding on server side. Single socket will contain all the three values. With this approach coding will be done such that it may split fields and further it's values.
The other way of this approach is to create three different sockets on client side such that it may carry three different field values on to the network. This approach would be easier to code on server side, as there would be three different sockets representing each respective field's value. One socket will represent carrier, second for origin and third for Destination. But does this fullfill the requirement of specifications String crteria parameter.

Waiting for your opinions
Thank you,
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I am not sure how to comment on your use of Sockets. but the Data class will ahve a method called crtieriaFind, which takes the string. You will have to have the entire string passed to that method. So therefore there is no "Spliting up the criteria string.
Now besides that you will find that you will use a StringTokenizer class to break apart the string on the server side.
Mark
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi reader,
I got you. But if I send a string from client like through socket in this way:
1) SpeedyAir,SFO,ATX.
Then StringTokenizer class will also be helpfull. But if String is send in this way:
2) carrier=SpeedyAir,origin=SFO,destination=ATX.
Then you see there are two tokens (ie = and ,) which I think will be problemsome. I had yet not carried out my work with StringTokenizer class. But do suggest me which is the better option to avail out of these two such that specifications requirement can also be retained.
If your answer is option 2. Then I would ask you then what is the use of using JComboBoxes. And if you insist option 1 then I think specifications requirement is not retained. Which is the better way out ?.
thank you,

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gurpreet Saini:
Hi reader,
I got you. But if I send a string from client like through socket in this way:
1) SpeedyAir,SFO,ATX.
Then StringTokenizer class will also be helpfull. But if String is send in this way:
2) carrier=SpeedyAir,origin=SFO,destination=ATX.
Then you see there are two tokens (ie = and ,) which I think will be problemsome. I had yet not carried out my work with StringTokenizer class. But do suggest me which is the better option to avail out of these two such that specifications requirement can also be retained.
If your answer is option 2. Then I would ask you then what is the use of using JComboBoxes. And if you insist option 1 then I think specifications requirement is not retained. Which is the better way out ?.
thank you,


Have a look at the docs for StringTokenizer... you can give it as many delimeting characters as you want, not just one
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used two StringTokenizers, first to tekn by the comma, then the second by the equals sign.
I did not know you could send two characters to the StringTokenizer.
Mark
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used a StreamTokenizer instead of a StringTokenizer. It is much more flexible, maybe too much.
With the StreamTokenizer you can set delimiters on-the-fly, I mean at the middle of the parsing process. It also has different kinds of delimiters.
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How could we can abstract the string contents comprising of more then one delimiters in an String by using StringTokenizer class ?. Please tell me with example (Of two delimeters) if it is possible.
Thank you,
[ July 18, 2002: Message edited by: Gurpreet Saini ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a shortened version, and I changed the names to protect the innocent.

I didn't finish the code there, so there will need some more } in there.
But now imagina a string like this
pair1first,pair1second;pair2first,pair2second;pair3first,pair3second
The above code will first make tokens that look like this
Token 1 = "pair1first,pair1second"
Token 2 = "pair2first,pair2second"
Token 3 = "pair3first,pair3second"
Then the final Tokens will be
First pass for second Tokenizer is
Token 1 = "pair1first"
Token 2 = "pair1second"
Second pass for second Tokenizer is
Token 1 = "pair2first"
Token 2 = "pair2second"
Third pass for second Tokenizer is
Token 1 = "pair3first"
Token 2 = "pair3second"

So basically as you make the second Tokenizer and go through each pass, you can put the values into some kind of Collection Class.
Hope that help and is clear.
I'd be interested in seeing Nate's code because it would lessen the number of lines of code. My lines totalled 9 lines. But Nate's might only be three.
Nate can you show us some code? Make sure you change names so that it isn't your exact SCJD code, as are not allowed to put actual code here as that would break our contract with Sun.
Mark
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:

Nate can you show us some code? Make sure you change names so that it isn't your exact SCJD code, as are not allowed to put actual code here as that would break our contract with Sun.
Mark


Sure thing... here is a sample program that would do it for you... hope this helps

It is mainly just initiallizing a few arrays and running through one loop. Let me know what ya'll think
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very cool. It takes 7 lines, so about 3 lines less than using two Tokenizers.
But one less loop.
Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic