It would help to know what ParseArgs is doing. It looks like you're
expecting it to split the string on "@" and that source would then be
"sf" (assuming name is null on entry).
Have you tried looking at the content of source and name in a
debugger (or use println to write out the values)?
There's nothing wrong with the equals comparison as far as I can see.
Two strings with same length and characters should be equal.
BTW, if all ParseArgs is doing is splitting on "@" you could use
StringTokenizer or more simply name.split("@").
And the series of if could be simplified to if / elseif ...
On 27 Jul 2007, at 05:56, Peizhao Hu wrote:
Hi,
I have the following function.
public static PacketSource makePacketSource(String name) {
if (name == null)
name = "sf@localhost:9002"; // default source
ParseArgs parser = new ParseArgs(name, "@");
String source = parser.next();
String args = parser.next();
PacketSource retVal = null;
if (source.equals("sf"))
retVal = makeArgsSF(args);
if (source.equals("serial"))
retVal = makeArgsSerial(args);
if (source.equals("network"))
retVal = makeArgsNetwork(args);
if (source.equals("tossim-serial"))
retVal = makeArgsTossimSerial(args);
if (source.equals("tossim-radio"))
retVal = makeArgsTossimRadio(args);
return retVal;
}
when I traced it, it failed in the first if statement. so what is
wrong with the equals comparison?
--
regards;
Peizhao
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/adrianm_lists%
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden