not able to read J2ME PIM contact details - java-me

I want to read contact details like firstname , lastname, mobile no, telephone , fax, address, synchronization and UID details using PIM apis in Nokia S60 sdk.
But , I am getting only Contact.TEL and Contact.EMAIL value, none of the other values I am getting , although, I am able to see other fields like first name, last name in the emulator contact details.
I have configures all the required permission .
ContactList addressbook = (ContactList) (PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_ONLY));
Contact contact = null;
Enumeration items = addressbook.items();
while (items.hasMoreElements()) {
String name = "";
String telephone = "";
String mobile = "";
String email = "";
String InternetTelephone = "";
String Company = "";
String JobTitle = "";
String Synchronisation = "";
String UID = "";
String LastModified = "";
String contactRow = "";
System.out.println("\n *** NEW ITEM ***");
contact = (Contact) (items.nextElement());
System.out.println(" * contact : " + contact.toString());
try {
name = contact.getString(Contact.FORMATTED_NAME, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
System.out.println(" Name error "+ ex.getMessage());
}
try {
mobile = contact.getString(Contact.ATTR_MOBILE, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
System.out.println(" Name error "+ ex.getMessage());
}
try
{ telephone = contact.getString(Contact.TEL, 0);
System.out.println("Telephone = " + contact.getString(115, 0)); //field 115: Telephone
} catch (Exception ex) {
System.out.println(" Telephone error "+ ex.getMessage());
}
try
{
email = contact.getString(Contact.EMAIL, 0);
System.out.println("E-mail = " + contact.getString(103, 0));
} catch (Exception ex) {
System.out.println(" E-mail error "+ ex.getMessage());
}
try
{
UID = contact.getString(Contact.UID, 0);
System.out.println(" UID " + UID );
} catch (Exception ex) {
System.out.println(" UID error "+ ex.getMessage());
}
try
{
LastModified = contact.getString(114, 0);
System.out.println(" Last modified " + contact.getString(114, 0));
} catch (Exception ex) {
System.out.println(" Last modified error "+ ex.getMessage());
}
looking forward your valuable suggestions.
Thanks in advance.

some sapmles from Nokia .... !
http://www.developer.nokia.com/Community/Wiki/How_to_read_contacts_using_JSR_75

Related

I have this array class that is not removing items after re-running my recyclerview

The below class is used in an array.
package com.example.ShivitoMGO;
public class RoomTable {
public String RoomName,UpDown,minmaxint;
}
Main Activity
static ArrayList <RoomTable> CountCheck = new ArrayList<>();
public void playerup(View vvv){
st_spinner = v1.findViewById(R.id.spinner);
st_reportLayout = v1.findViewById(R.id.reportlayout);
st_Leanervidimg = v1.findViewById(R.id.Linearvidcopy);
TextView roomname = v1.findViewById(R.id.action_Players1);
RoomTable roomtb = new RoomTable();
if (CountCheck.size() == 0){
//playerupdown = "up";
Toast.makeText(this, "Will notify when " + mRooms.get(position1) + " players increase #" + mRoomSize.get(position1), Toast.LENGTH_LONG).show();
String[] minmaxval = mRoomSize.get(position1).split("/");
CountCheckint = Integer.parseInt(minmaxval[0].trim());
//CountCheck = (String) mRooms.get(position1);
roomtb.RoomName = (String) mRooms.get(position1);
roomtb.minmaxint = minmaxval[0].trim();
roomtb.UpDown = "up";
Log.d("added: ", "it was added");
CountCheck.add(roomtb);
Log.d("RoomTableadd: ",roomtb.RoomName+ " " + roomtb.minmaxint +" " +roomtb.UpDown);
st_reportLayout.setVisibility(View.GONE);
Log.d("Longclickhere: ", mRoomSize.get(position1));
Log.d("RoomNameCount ", String.valueOf(CountCheck.get(0).RoomName));
}else {
int exist1 = 0;
int poss;
for (int i = 0; i < CountCheck.size(); i++) {
if (roomname.getText() == CountCheck.get(i).RoomName) {
Log.d("RoomNametxt: " , CountCheck.get(i).RoomName);
Log.d("RoomNametxt: ", (String) roomname.getText());
Toast.makeText(this, "Notification " + CountCheck.get(i).RoomName + " OFF!", Toast.LENGTH_LONG).show();
Log.d("Removed item: ", String.valueOf(CountCheck.size()));
CountCheck.remove(i);
Log.d("Removed item: ", String.valueOf(CountCheck.size()));
st_reportLayout.setVisibility(View.GONE);
exist1 = 1;
poss = i;
} else {
exist1 = 0;
}
}
if (exist1 == 0) {
Toast.makeText(this, "Will notify when " + mRooms.get(position1) + " players increase #" + mRoomSize.get(position1), Toast.LENGTH_LONG).show();
String[] minmaxval = mRoomSize.get(position1).split("/");
CountCheckint = Integer.parseInt(minmaxval[0].trim());
//CountCheck = (String) mRooms.get(position1);
roomtb.RoomName = (String) mRooms.get(position1);
roomtb.minmaxint = minmaxval[0].trim();
roomtb.UpDown = "up";
Log.d("added: ", "it was added");
CountCheck.add(roomtb);
Log.d("RoomTableadd: ", roomtb.RoomName + " " + roomtb.minmaxint + " " + roomtb.UpDown);
st_reportLayout.setVisibility(View.GONE);
}
Log.d("CountSize: ", String.valueOf(CountCheck.size()));
for (int xb = 0;xb<CountCheck.size();xb++) {
try {
Log.d("RoomNameCount ", String.valueOf(CountCheck.get(xb).RoomName));
} catch (Exception e) {
Log.d("Out of range ", String.valueOf(e));
}
}
}
}
Recycler-View
#Override
public boolean onLongClick(View v) {
// Launch your web intent
if (CountCheck.size() != 0){
Log.d("Longclickhere: ",mRoomSize.get(position));
Toast.makeText(mContext, mRoomSize.get(position), Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "Will notify when "+mRooms.get(position)+" players decrease", Toast.LENGTH_SHORT).show();
String[] minmaxval = mRoomSize.get(position).split("/");
MainActivity.CountCheckint = Integer.parseInt(minmaxval[0].trim());
} else{
//MainActivity.CountCheck = "";
Toast.makeText(mContext, "Player Decrease notification OFF", Toast.LENGTH_SHORT).show();
}
return true;
In this app the recycler view creates the "rooms" and if the room is selected the textview and 2 other values are put in to the RoomTable. these are stored and used in a service to check if ether of the other to values change. Everything works as intended unless i use the swip-to-refresh witch runs the recycler-view again. If i do not refresh and i select the same item in the recycler-view it will remove it from CountCheck . However if i run the refresh and select the same recycler-view item that i selected previously it will add it instead of removing it. This Makes no since to me because i use a for loop to Check the CountCheck.get(i).RoomName aka the textview and if the names are the same then my if statement will remove instead of add. is it somehow possible i'm ending up with 2 CountCheck Objects????? with the same name???? Please I'm out of ideas on this one. Thanks.
I dont remember why. Maybe someone can explain but i changed this line
if (roomname.getText() == CountCheck.get(i).RoomName)
To this
if (roomname.getText().equals(CountCheck.get(i).RoomName));
and that fixed the issue. please let me know the difference if you are reading this.

Storing object in concurrenthashmap created using constructor

This is my code. Am trying to add employees dynamically to the concurrenthashmap. There is no error but i get inputMismatchException. Experts, please help.
CODE:
try {
System.out.println("No of employees: ");
int count = userdata.nextInt();
System.out.println("count: " + count);
System.out.println("enter employee details.");
// with ConcurrentHashMap
ConcurrentHashMap<Integer, employee> employeeDetails = new ConcurrentHashMap<>();
int index = 0;
do {
employeeDetails.put(index, new employee(userdata.nextInt(), userdata.nextLine(), userdata.nextLine()));
index++;
count--;
} while (count != 0);
System.out.println(employeeDetails.toString());
System.out.println("enter item to remove: ");
String removeValue = userdata.nextLine();
employeeDetails.forEach((k, v) -> {
if (v.equals(removeValue)) {
employeeDetails.remove(k);
}
});
System.out.println("afer removal: \n" + employeeDetails.toString());
} catch (Exception e) {
e.printStackTrace();
}
Output:
No of employees:
2
count: 2
enter employee details.
1
name
city
java.util.InputMismatchException

URLConnection dont work on linux

i have a big Problem at the moment and i hope anybody know a fix.
on my server i use this code to check vote counts on a website:
#Override
public int getVoteCount()
{
int votes = 0;
try
{
URL oracle = new URL(getLinkToCheck());
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("<div class='list_8' style=\"font-weight: bold\">"))
{
String line = inputLine.split("<div class='list_8' style=\"font-weight: bold\">")[1].split("</div>")[0].trim().replaceAll(" ", "");
votes = Integer.parseInt(line);
if (VoteManager.VOTE_DEBUG)
{
System.out.println("VoteManager [" + getClass().getSimpleName() + "]: Votes count: [" + votes + "]");
}
return votes;
}
}
in.close();
}
catch (Exception e)
{
System.out.println(e);
}
return votes;
}

Impersonation with different machine's account (remote user)

Is it possible to logon to different machine's account with impersonation? I have to access the folder and read its contents temporarily. After reading process program will revert back to old account which has no access to that folder. I am able to impersonate with different account under same domain and it works. However, I have to update my code for accessing to different machine. I want to modify this code:
public WindowsImpersonationContext ImpersonateUser(string sUsername, string sDomain, string sPassword)
{
// initialize tokens
IntPtr pExistingTokenHandle = new IntPtr(0);
IntPtr pDuplicateTokenHandle = new IntPtr(0);
pExistingTokenHandle = IntPtr.Zero;
pDuplicateTokenHandle = IntPtr.Zero;
// if domain name was blank, assume local machine
if (sDomain == "")
sDomain = System.Environment.MachineName;
try
{
string sResult = null;
const int LOGON32_PROVIDER_DEFAULT = 0;
// create token
const int LOGON32_LOGON_INTERACTIVE = 2;
//const int SecurityImpersonation = 2;
// get handle to token
bool bImpersonated = LogonUser(sUsername, sDomain, sPassword,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref pExistingTokenHandle);
// did impersonation fail?
if (false == bImpersonated)
{
int nErrorCode = Marshal.GetLastWin32Error();
sResult = "Error while logging. Error Code: " + nErrorCode + "\r\n";
// show the reason why LogonUser failed
MessageBox.Show(this, sResult, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
// Get identity before impersonation
sResult += "Before impersonation: " + WindowsIdentity.GetCurrent().Name + "\r\n";
bool bRetVal = DuplicateToken(pExistingTokenHandle, (int)SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, ref pDuplicateTokenHandle);
// did DuplicateToken fail?
if (false == bRetVal)
{
int nErrorCode = Marshal.GetLastWin32Error();
CloseHandle(pExistingTokenHandle); // close existing handle
sResult += "DuplicateToken() failed with error code: " + nErrorCode + "\r\n";
// show the reason why DuplicateToken failed
MessageBox.Show(this, sResult, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
else
{
// create new identity using new primary token
WindowsIdentity newId = new WindowsIdentity(pDuplicateTokenHandle);
WindowsImpersonationContext impersonatedUser = newId.Impersonate();
// check the identity after impersonation
sResult += "After impersonation: " + WindowsIdentity.GetCurrent().Name + "\r\n";
MessageBox.Show(this, sResult, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
return impersonatedUser;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
// close handle(s)
if (pExistingTokenHandle != IntPtr.Zero)
CloseHandle(pExistingTokenHandle);
if (pDuplicateTokenHandle != IntPtr.Zero)
CloseHandle(pDuplicateTokenHandle);
}
}

J2ME Login and Search Record Store

I'm new to J2ME and I'm taking a class where we use it. I created a simple travel reservation MIDlet using choice groups text fields etc. I then added a Record Store to capture this information. I now have a user login that only requires a user name, but i don't know how to verify that the user name is in the Record Store, so instead I accept any one as long as the Textfield for the user name is not empty. My first question is how would I verify that the user exist, I already can create an account. The second question is how can I search a record store not by id but say using a string within a certain range for each row of the Record store.
Here is my code so far:
$import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.util.Date;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.*;
/**
* #author XayBlu
*/
public class tripMe extends MIDlet implements CommandListener {
Form startForm, airForm, trainForm, cruiseForm, autoForm, Ext, Pass,home,login, create;
Command Exit, Trip, Cinfo, AutC,AiC,CrC, info,Tme,trainC, logC,signC, createC, prev, newTrip, Home;
ChoiceGroup trans,hCAP, passCNT,airT,airC,AuC,AuT,CrL,CcabT,Tseat,TOP;
Display Xdisplay;
TextField Eneed, uName, uName2;
Alert Final, FinalT, Sucess, nope;
DateField dDate, rDate;
Date d,r;
Image [] image;
String details =" ",tt="", Trav, Rdate, Ddate, extraA, Pcount,specialA, TT,AIR2, AIR,AUTO,AUTO2,CRUISE,CRUISE2,TRAIN,TRAIN2, USERS="USERS";
String op[] = {"Air","Auto","Cruise","Train"}; //Array Items for Choice Groups
String ep[] = {"Wheel Chair","Baby Seat","Extended Seatbelt","Extra Pillows","Oxygen Tank","GPS"};
String count[] = {"1","2","3","4","5","6","7","8"};
String AL []= {"American Airlines","Delta","US Airways","South West Airlines","United Airlines"};
String Rental [] = {"Alamo","Avis","Budget","Enteprise","Dollar","Hertz"};
String CL [] = {"Carnival","Norwegian","Royal Caribbean","Celebrity X","MSC"};
String CT [] = {"Compact","Standard","Full","SUV","Luxury","Sports"};
String Cabin [] = {"Suite","Ocean Balcony","Standard","Economy"};
String tCAB[] = {"Standard Seat","Sleeper Cart"};
String Toptions[] ={"Extra Luggage room","Salad Buffet","Wifi Access","Extra Blanket"};
RecordStore usr,itt;
RecordEnumeration recEnum = null;
RecordFilter filter = null;
int Umax=5;
int tran1 =6;
String last;
Byte [] data = new Byte[Umax];
/* NEW COMMANDS FOR FLEXIBLE USER INPUT TO RECORD STORES */
public void writeRecord(String str){ // User to insert user input to record stores
byte[] rec = str.getBytes();
try{
usr.addRecord(rec, 0, rec.length);
}catch (Exception e){}
}
public void writeInfo(String str){ // User to insert user input to record stores
byte[] rec = str.getBytes();
try{
usr.addRecord(rec, tran1, rec.length);
}catch (Exception e){}
}
public void updateRecord(String str){
try{
usr.setRecord(1, str.getBytes(), 0, str.length());
}catch (Exception e){}
}
public void deleteRecord(){
try{
usr.deleteRecord(1);
}catch (Exception e){}
}
public void closeRecord(){
try{
usr.closeRecordStore();
}catch (Exception e){}
}
public void deleteRecStore(){
if (RecordStore.listRecordStores() != null){
try{
RecordStore.deleteRecordStore(USERS);
}catch (Exception e){}
}
}
public void openRecStore()
{
try
{
// The second parameter indicates that the record store
// should be created if it does not exist
usr = RecordStore.openRecordStore(USERS, true );
}
catch (Exception e)
{
System.out.print("Could not open record store");
}
}
public void readRecords()
{
try
{
// Intentionally make this too small to test code below
byte[] recData = new byte[5];
int len;
for (int i = 1; i <= usr.getNumRecords(); i++)
{
if (usr.getRecordSize(i) > recData.length)
recData = new byte[usr.getRecordSize(i)];
len = usr.getRecord(i, recData, 0);
home.append(new String(recData,0,len));
// System.out.println("Record #" + i + ": " + new String(recData, 0, len));
// System.out.println("------------------------------");
}
}
catch (Exception e)
{
nope = new Alert("Sorry no match!",null,null,AlertType.INFO);
nope.setTimeout(Alert.FOREVER); //Append string for FinalT Alert
Xdisplay.setCurrent(nope, login);
}
}
}
class Filter implements RecordFilter {
private String search = null;
private ByteArrayInputStream inputstream = null;
private DataInputStream datainputstream = null;
public Filter(String search) {
this.search = search.toLowerCase();
}
public void filterClose() {
try {
if (inputstream != null) {
inputstream.close();
}
if (datainputstream != null) {
datainputstream.close();
}
} catch (Exception error) {
}
}
}
public tripMe (){
try{ //Initializing individual images for Choice Group Icons
Image car = Image.createImage("/car2.png");
Image plane = Image.createImage("/plane2.png");
Image train = Image.createImage("/train2.png");
Image cruise = Image.createImage("/cruise2.png");
image = new Image[] {plane,car,cruise,train}; //Initializing Image array for ChoiceGroup
}
catch (java.io.IOException err) {System.out.print("Could not load pics"); } //Throws exception if pic cannot be found
startForm = new Form("Get Away Today"); //Initialization of forms
Pass = new Form ("Passenger Information");
airForm = new Form("Low Prices!");
autoForm = new Form("Find the best car for you");
Ext = new Form("Itinerary Details");
Ext.setTicker(new Ticker("Enjoy Your Vacation"));
cruiseForm = new Form("Sail Away Today");
trainForm = new Form("Chuuu- Chuuu");
login = new Form("Sign up Today");
home = new Form("Welcome Back");
create = new Form("Create an account");
trans = new ChoiceGroup("Select travel type",ChoiceGroup.EXCLUSIVE,op,image); //Transport tation choice group initialized with corresponding string and image array
Exit = new Command("Exit", Command.EXIT,1);//Adding necessary commands
Trip = new Command("Go", Command.SCREEN,2);//Adding go command which allows you to select travel type
signC = new Command("Sign up",Command.SCREEN,2);
logC = new Command("Log in",Command.SCREEN,2);
createC = new Command("OK",Command.SCREEN,2);
prev = new Command("History",Command.SCREEN,2);
newTrip = new Command("Reservations",Command.SCREEN,2);
Home = new Command("Log out",Command.SCREEN,1);
hCAP = new ChoiceGroup("Extra Assistance", ChoiceGroup.MULTIPLE,ep,null);//Passenger Info items
passCNT = new ChoiceGroup("Number of Passengers:",ChoiceGroup.POPUP,count,null);
rDate = new DateField("Return Date",DateField.DATE_TIME);//Could not get the DateField to return string date value
dDate = new DateField("Departure Date",DateField.DATE_TIME);
Eneed = new TextField("Special Needs","",50,TextField.ANY);
uName = new TextField("User Name","",5,TextField.ANY);
uName2 = new TextField("User Name","",5,TextField.ANY);
info = new Command("Next",Command.SCREEN,2);
AiC = new Command("Complete",Command.SCREEN,2);//Air travel option items
airT = new ChoiceGroup("Choose Airline", ChoiceGroup.POPUP,AL,null);//Airline selection
airC = new ChoiceGroup("Select Class",ChoiceGroup.EXCLUSIVE);//Economy or first cass?
airC.append("First Class", null);//Adding elements to Choice Group
airC.append("Economy", null);
AuC = new ChoiceGroup("Choose rental company", ChoiceGroup.POPUP,Rental,null);//Auto travel option items
AuT = new ChoiceGroup("Select Vehicle Type", ChoiceGroup.EXCLUSIVE, CT,null);//Choicegroup for Vehicle type
AutC = new Command("Drive away", Command.SCREEN,2);//Adding drive away command to form
CrL = new ChoiceGroup("Select Cruise Line Comp.", ChoiceGroup.POPUP,CL,null);//Cruise option Items, Cruise line choicegroup
CcabT = new ChoiceGroup("Select Cabin Type", ChoiceGroup.EXCLUSIVE,Cabin,null);//Cabin type choice group
CrC = new Command("Cruise", Command.SCREEN,2);//Cruise form command being added
trainC = new Command("Track!", Command.SCREEN,2);//Train option items, Train form command
Tseat = new ChoiceGroup("Seat Type", ChoiceGroup.EXCLUSIVE,tCAB,null);//Choicegroup for train seat type
TOP = new ChoiceGroup("Extra Options", ChoiceGroup.POPUP,Toptions,null);//Train extra options choice group
/* Appending Items to necessary Forms*/
create.append(uName2);
create.addCommand(createC);
create.setCommandListener(this);
home.addCommand(prev);
home.addCommand(newTrip);
home.setCommandListener(this);
login.append(uName);
login.addCommand(logC);
login.addCommand(signC);
login.setCommandListener(this);
startForm.append(trans);
startForm.addCommand(Exit);
startForm.addCommand(Trip);
startForm.setCommandListener(this);
Pass.append(dDate);
Pass.append(rDate);
Pass.append(hCAP);
Pass.append(passCNT);
Pass.append(Eneed);
Pass.addCommand(info);
Pass.setCommandListener(this);
airForm.append(airT);
airForm.append(airC);
airForm.addCommand(AiC);
airForm.setCommandListener(this);
autoForm.addCommand(AutC);
autoForm.append(AuC);
autoForm.append(AuT);
autoForm.setCommandListener(this);
cruiseForm.addCommand(CrC);
cruiseForm.append(CrL);
cruiseForm.append(CcabT);
cruiseForm.setCommandListener(this);
trainForm.addCommand(trainC);
trainForm.append(Tseat);
trainForm.append(TOP);
trainForm.setCommandListener(this);
Ext.addCommand(Exit);
Ext.addCommand(Home);
Ext.setCommandListener(this);
}
public void startApp() {
Xdisplay= Display.getDisplay(this);
Xdisplay.setCurrent(login);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command c, Displayable displayable){
try {
usr = RecordStore.openRecordStore(USERS, false);
} catch (Exception e) {
Sucess = new Alert("Error","Could not open Record Strore",null,AlertType.INFO);
Sucess.setTimeout(Alert.FOREVER); //Append string for FinalT Alert
Xdisplay.setCurrent(Sucess, login);
}
if(c==signC)
{
Xdisplay.setCurrent(create);
}
else if(c == newTrip)
{
Xdisplay.setCurrent(startForm);
}
else if(c == prev)
{
try {
String record = "";
for (int i = 1; i < usr.getNextRecordID(); i++) {
record = new String(usr.getRecord(i));
}
home.append(record);
} catch (Exception e) {
home.append("Could not retrieve data");
try {
usr.closeRecordStore();
RecordStore.deleteRecordStore(USERS);
} catch (Exception x) {
}
}
try {
usr.closeRecordStore();
} catch (Exception e) {
}
}
else if(c==createC)
{
try {
usr = RecordStore.openRecordStore(USERS, true);
} catch (RecordStoreException ex) {
ex.printStackTrace();
}
if(!"".equals(uName2.getString()))
{
writeRecord(uName2.getString());
}
Sucess = new Alert("Welcome to the mile high club","Hello:"+uName2.getString(),null,AlertType.INFO);
Sucess.setTimeout(Alert.FOREVER); //Append string for FinalT Alert
Xdisplay.setCurrent(Sucess, login);
}
else if (c == logC)
{
if(!"".equals(uName.getString()))
{
String name = uName.getString();
byte[] data = name.getBytes();
Xdisplay.setCurrent(home);
}
else
{
Sucess = new Alert("Please enter user name!","Invalid user name",null,AlertType.INFO);
Sucess.setTimeout(Alert.FOREVER); //Append string for FinalT Alert
Xdisplay.setCurrent(Sucess, login);
}
}
else if(c==Trip)
{
tt +="Travel Mode: "+ trans.getString(trans.getSelectedIndex())+"\n";
if(trans.isSelected(0))
{
TT="A"; //Sets the type of travel based on choicegroup user selection
Xdisplay.setCurrent(Pass);
}
else if(trans.isSelected(1))
{
TT="B";
Xdisplay.setCurrent(Pass);
}
else if(trans.isSelected(2))
{
TT="C";
Xdisplay.setCurrent(Pass);
}
else if(trans.isSelected(3))
{
TT="D";
Xdisplay.setCurrent(Pass);
}
}
else if (c == info)
{
for(int i = 0; i < hCAP.size(); i++) //Checks to see what items are selected in a ChoiceGrou
{
if(hCAP.isSelected(i))
{
details += hCAP.getString(i)+","; //If item is selected then it is appended to the string details
}
}
Rdate = rDate.getDate().toString();
Ddate = dDate.getDate().toString();
tt+= "Departure Date: "+ Ddate.substring(0, 10)+"\n";
tt+= "Return Date: "+ Rdate.substring(0, 10)+"\n";
Pcount = passCNT.getString(passCNT.getSelectedIndex()); //Gets passenger count from choicegroup of integers
specialA = Eneed.getString();
Final = new Alert("Your travel details: \n","Requested Devices:"+details+"\nPassenger Count: "+Pcount+
"\nSpecific Request: "+specialA,null,AlertType.INFO); //Appends string for alert
Final.setTimeout(Alert.FOREVER);
if("A".equals(TT)){ //Directs user to form based on travel type choice
Xdisplay.setCurrent(Final,airForm);
}
else if("B".equals(TT)){//Directs user to form based on travel type choice
Xdisplay.setCurrent(Final, autoForm);
}
else if ("C".equals(TT)){//Directs user to form based on travel type choice
Xdisplay.setCurrent(Final, cruiseForm);
}
else if ("D".equals(TT)){//Directs user to form based on travel type choice
Xdisplay.setCurrent(Final, trainForm);
}
}
else if(c==AiC)
{
AIR = airT.getString(airT.getSelectedIndex());//Retrieves selected item from choicegroup
tt+="Company: "+AIR+"\n";
AIR2 = airC.getString(airC.getSelectedIndex());//Retrieves selected item from choicegroup
FinalT = new Alert("Flight Details: \n","Airline Company:"+AIR+"\nSeat Class: "+AIR2,null,AlertType.INFO);
FinalT.setTimeout(Alert.FOREVER); //Append string for FinalT Alert
Trav ="Customer Details \nRequested Devices:\n"+details+"\n# of Passengers:\n "+Pcount+"\nSpecific customer request:\n "+specialA+
"\nDeparture Date: "+Ddate+"\nReturn Date: "+Rdate;
Ext.append(Trav);
extraA ="Carrier Details\n"+"Airline Carrier: "+AIR+"\nSeat Type: "+AIR2; //Append string for final display of info to user
Ext.append(extraA);
try {
usr = RecordStore.openRecordStore(USERS, true);
} catch (RecordStoreException ex) {
}
writeRecord("\n"+tt);
Xdisplay.setCurrent(FinalT,Ext);
}
else if (c == AutC)
{
AUTO = AuC.getString(AuC.getSelectedIndex());//Retrieves selected item from choicegroup
tt += "Company: "+AUTO+"\n";
AUTO2 = AuT.getString(AuT.getSelectedIndex());//Retrieves selected item from choicegroup
FinalT = new Alert("Auto Details: \n","Car Rental Company:"+AUTO+"\nVehicle Class: "+AUTO2,null,AlertType.INFO);
FinalT.setTimeout(Alert.FOREVER);
Trav ="Customer Details \nRequested Devices:\n"+details+"\n# of Passengers:\n "+Pcount+"\nSpecific customer request:\n "+specialA+
"\nDeparture Date: "+Ddate+"\nReturn Date: "+Rdate;
Ext.append(Trav);
extraA ="Carrier Details\n"+"Rental Company: "+AUTO+"\nVehicle Class: "+AUTO2; //Append string for final display of info to user
Ext.append(extraA);
try {
usr = RecordStore.openRecordStore(USERS, true);
} catch (RecordStoreException ex) {
}
writeRecord("\n"+tt);
Xdisplay.setCurrent(FinalT, Ext);
}
else if (c == CrC)
{
CRUISE = CrL.getString(CrL.getSelectedIndex());
tt += "Company: "+CRUISE+"\n";
CRUISE2 = CcabT.getString(CcabT.getSelectedIndex());
FinalT = new Alert("Cruise Details: \n","Cruise Line Company:"+CRUISE+"\nCabin Type:"+CRUISE2,null,AlertType.INFO);
FinalT.setTimeout(Alert.FOREVER);
Trav ="Customer Details \nRequested Devices:\n"+details+"\n# of Passengers:\n "+Pcount+"\nSpecific customer request:\n "+specialA+
"\nDeparture Date: "+Ddate+"\nReturn Date: "+Rdate;
Ext.append(Trav);
extraA ="Carrier Details\n"+"Cruise Line Company: "+CRUISE+"\nCabin Type: "+CRUISE2; //Append string for final display of info to user
Ext.append(extraA);
try {
usr = RecordStore.openRecordStore(USERS, true);
} catch (RecordStoreException ex) {
}
writeRecord("\n"+tt);
Xdisplay.setCurrent(FinalT, Ext);
}
else if (c == trainC)
{
TRAIN = Tseat.getString(Tseat.getSelectedIndex());
TRAIN2 = TOP.getString(TOP.getSelectedIndex());
FinalT = new Alert("Train Details: \n","Train Seat Type:"+TRAIN+"\nExtra Amenities:"+TRAIN2,null,AlertType.INFO);
FinalT.setTimeout(Alert.FOREVER);
Trav ="Customer Details \nRequested Devices:\n"+details+"\n# of Passengers:\n "+Pcount+"\nSpecific customer request:\n "+specialA+
"\nDeparture Date: "+Ddate+"\nReturn Date: "+Rdate;
Ext.append(Trav);
extraA ="Carrier Details\n"+"Train Seat Type: "+TRAIN+"\nExtra Amenities: "+TRAIN2; //Append string for final display of info to user
Ext.append(extraA);
try {
usr = RecordStore.openRecordStore(USERS, true);
} catch (RecordStoreException ex) {
}
writeRecord("\n"+tt);
Xdisplay.setCurrent(FinalT, Ext);
}
else if(c == Home)
{
home.deleteAll();
Xdisplay.setCurrent(login);
}
else if(c==Exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}

Resources