Re: java.util.Enumeration - Array List Question
Re: java.util.Enumeration - Array List Question
- Subject: Re: java.util.Enumeration - Array List Question
- From: Radwar <email@hidden>
- Date: Fri, 9 Apr 2004 12:00:59 -0400
Your code returns the first Contact which has a valid phone number. You
have the "return con;" inside the while loop. What is you want the
method to return? a string of phone numbers? Also your 3 if statement
are checking the same device type of Phone. I think you need something
like:
public String getPersonContact(){
NSArray pc = (NSArray)storedValueForKey("contacts");
java.util.Enumeration e = pc.objectEnumerator();
String contacts = "";
while (e.hasMoreElements()) {
Contact con = (Contact)e.nextElement();
if ((con.phoneNumer() != null)) {
if ((con.deviceType().equals("Phone")))
contacts = contacts + formatPhoneNumber(con.phoneNumber()) + "
(w)\n";
if ((con.deviceType().equals("Fax")))
contacts = contacts + formatPhoneNumber(con.phoneNumber()) + "
(f)\n";
if ((con.deviceType().equals("Cell")))
contacts = contacts + formatPhoneNumber(con.phoneNumber()) + "
(c)\n";
}
}
return contacts;
}
On Apr 9, 2004, at 11:15 AM, Janice M. Cheung wrote:
Greetings!
I'm having problems returning an array List of PersonContacts ..
Is there a way for the InterfaceEnumeration method to return
e.allElements() instead of e.nextElement() ?
My function is only returning one phone number, instead of a list
of all work, cell, and fax numbers..
Here is my function:
public Contact getPersonContact(){
NSArray pc = (NSArray)storedValueForKey("contacts");
java.util.Enumeration e = pc.objectEnumerator();
String myTels = "";
while (e.hasMoreElements()) {
Contact con = (Contact)e.nextElement();
String phone = " ";
String fax = " " ;
String cell = " " ;
if ((con.phoneNumer() != null)) {
if ((con.deviceType().equals("Phone"))) {
phone =
formatPhoneNumber(con.phoneNumber()) + " (w)\n";
}
if ((con.deviceType().equals("Phone"))) {
fax =
formatPhoneNumber(con.phoneNumber()) + " (w)\n";
}
if ((con.deviceType().equals("Phone"))) {
cell =
formatPhoneNumber(con.phoneNumber()) + " (w)\n";
}
myTels = myTels + " " + phone + " " +
fax + " " + phone;
} return con;
}
return null;
}
I'm not sure of what I'm exactly missing .. but
I would like for:
Contact con = (Contact)e.nextElement();
to somehow include + con .. to generate the entire list
..
Any help or guidance would be greatly appreciated!
Thanks very much!!
Happy Good Friday!!! :-)
Janice
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.