poornima sudharshan

Greenhorn
+ Follow
since May 18, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by poornima sudharshan

I am using the Adapter Pattern to retrofit my application with RMI.
I have 2 interfaces which has all the methods of Data.
The first one is RemoteDataServiceIF which extends Remote.
The second one is LocalDataServiceIF which does not extend Remote.
On the Server side I have a class FBNServer extending UnicastRemoteObject & implementing RemoteDataServiceIF.
I have a class FBNClient which implements the LocalDataServiceIF -
This class connects to the local or Remote Data instance depending upon a boolean value.
Is this Design okay?
Please reply,
poornima.
I have a screen which displays the JTable showing all the flight records selected by the user.Now when the user selects a flight,I lock the record, & take him to the reservation screen where the user selects the number of seats to be booked.
My question is I do not want to take the user to the reservation screen until the I lock the record successfully.( which means that the record is in my HashMap ).
At present in lock method, if the record is already present in the HashMap,the thread simply goes to the wait state.
My only concern is I do not want to show him the number of seats to be booked until I am sure that his record is being locked.
Please reply,
poornima.
In the locking method,I use a HashMap to put the record number to be locked & the time when it would expire.
I put this as - long expireTime = System.currentTimeMillis();
the current time.
There is a timer which works every minute.
Timer lockClean = new Timer( 60000, new TimerListener() );
lockClean.start();
class TimerListener implements ActionListener {

public void actionPerformed( ActionEvent e ) {
Set recordKeys = null;
Iterator recordsIterator = null;
if(Data.lock_hash_map.isEmpty() == false) {
recordKeys = Data.lock_hash_map.keySet();
recordsIterator = recordKeys.iterator();
while( recordsIterator.hasNext() ) {
Object keyValue = recordsIterator.next();
Object timeValue = Data.lock_hash_map.get(
keyValue );
if( System.currentTimeMillis() -
Long.parseLong(
timeValue.toString()) == 300000 ) {
dbFile.unlock( Integer.parseInt(
keyValue.toString()));
System.out.println( " cleaned " );
}
}
}
}
}
In the TimerListener class, I get all the Key values from the HashMap,the key values are the record numbers.for each key I get the value - which is the timeStamp,the time when the record was put to the HashTable.What I am doing here is that I am subtracting the current time with the time stamp the record was put into the HashMap,if the difference is 5 min,the record is unlocked.
But this does not seemed to be working.
Thanks for any reply,
poornima.

I have 2 queries -
1. On the screen which displays the JTable, the user selects a record,but since the assignment does not say that we have to display live records,I have to get the available seats from the database.If the particular record is locked,I wil wait,since my intention is to get the latest information.
Then after getting the current available seats, I will lock the record.
Is this correct?
2.My second question is how do I implement timeout.Can I use a hashtable wherein I put the particular record to be locked & the time stamp- the time this record was put.
when the time elapsed is greater than the certain allocated time,the record has to be unlocked or removed from the hashtable.
Is this correct?
Please reply.
poornima.
How do I add a column with values to an existing JTable
which has been constructed using a AbstractTableModel.
Basically I have a completely constructed JTable, and for Selection of each row,I want to add a column with a RadioButton.By Selecting this RadioButton,the user selects the particular row.
Plz reply,
poornima.
I would like to know in which version of the jdk do we have to submit the assignment.
Please let me know.
poornima.
After the user selects a record displayed using a JTable,
I would like to know what the next screen would be.
Do I display the selected record selected & also ask the user the number of seats to book ?
I am done till the JTable display & confused how do go about it next.
Please reply.
poornima.
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.

Originally posted by Adithya Rayaprolu:
Hi,
This forum is great, it helped me a lot. I am also working on FBN assignment. I have some basic questions.
1. Can I pass program mode(network/local) and database location as command line arguments? Or do I have to provide a dialog box at startup asking the user to enter the mode and location?
2. If I use comboboxes to select origin and destination, I have to get the lists of origins and destination from the database. In our case, the list is small, so this will be fine. what if the list increases? what if the list is changed during runtime?
3. There is a requirement stating that 'If an attempt is made to unlock a record that has not been locked by this connection, then no action is be taken.' This means, we have to somehow get clientID for checking. Can I ignore this? If I do not take the clientID in lock/unlock, is the grader going to fail me?
Thanks.


1.I think it is better to have a frame which asks the mode of the apllication.That's how I have implemented.
2.Write a Helper class which selects all the Origin & Destination airports,You can use a Vector to add all the values,
there is no worry that the list might increase,since the vector automatically increases in size.
poornima.
public DataInfo[] criteriaFind( String criteria ) throws
DatabaseException {
int numberOne = 1;
int numberTwo = 2;
int aIndex, bIndex;
String first, second, firstField, secondField;
aIndex = criteria.indexOf( '=' );
firstField = criteria.substring( 0, aIndex );
bIndex = criteria.indexOf( ',' );
first = criteria.substring( aIndex + numberTwo,
bIndex - numberOne );
aIndex = criteria.lastIndexOf( '=' );
secondField = criteria.substring( bIndex + numberOne,
aIndex );
bIndex = criteria.length();
second = criteria.substring( aIndex + numberTwo,
bIndex - numberOne );
}
Strings first & second represent the values in the Query Column and
Strings first field & second field represent the field names.
Is this parsing Okay,
Or is there a better way to do it?

Thanks for any reply.
Thanks for the reply Matt,
Can u please clear this for me -
If my task now is to match the String in the query column with the values in the database,
first I get the String in the Query column,then with what String do I concatenate this with?
The Query column might be a String representing Origin,or Destination or carrier,or anything else.
Can the String I pass to the criteria Find method be in this fashion -
"Origin airport = 'SFO', Destination airport = 'DEN'";
Why is there a neccessity to use Carrier since the user gets the option to choose only the Origin & Destination from the UI.
Also can I get the 'Origin airport' string & the 'destination airport' string from the database instead of hard coding it?
Please reply,
poornima.
I am concerned regarding how to switch b/w Frames.
Right now in my code,I pass an instance of the first JFrame to the second,& when you press the Back Button in the second screen,
what I am doing now is setting the setVisible to false for the current screen & make the setVisible to true for the first screen(by changing the instance of the first JFrame which has been passed to the second JFrame ).
My concern is if we have a ample number of screens,then it is surely bad design to keep passing objects from one JFrame to the other.
Is there any way out for me to implement this Back button logic?
Please clear this for me,
poornima.
Can I use the Singleton Pattern to switch between the screens(JFrames ) in the Application ?
I have designed a UI class which has a "BACK" JButton in it.
I want to know how to Handle the Action Event when the JButton is pressed, - I mean to say,
Should I have to instantiate the previous class
each time the "BACK" button is pressed to get back to the previous screen.
Any replies would be greatly appreciated.
poornima.