diff options
author | jestin | 2001-10-10 15:36:44 +0000 |
---|---|---|
committer | jestin | 2001-10-10 15:36:44 +0000 |
commit | cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319 (patch) | |
tree | d5d5f8469189d441124072f5ea06313cfdbeab12 /src/Ivy.java | |
parent | 5ef7f02fef093aebb79ef1a1f37908664702b1cb (diff) | |
download | ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.zip ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.gz ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.bz2 ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.xz |
Bugfix related to the "a(.*) (.*)' regexp causing the loss of front empty
messages.
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-x | src/Ivy.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/Ivy.java b/src/Ivy.java index f7511ba..ad8a4e6 100755 --- a/src/Ivy.java +++ b/src/Ivy.java @@ -12,7 +12,6 @@ import java.net.*; import java.io.*; import java.util.Vector; import java.util.Hashtable; -import java.util.StringTokenizer; /** * A class connecting to the Ivy software bus. @@ -260,11 +259,29 @@ public class Ivy implements Runnable, IvyApplicationListener { if (callback==null){ throw new IvyException("(callCallback) Not regexp matching id "+key.intValue()); } - StringTokenizer st = new StringTokenizer(msgarg,IvyClient.EndArg); - String args[] = new String[st.countTokens()]; - int i=0; - while (st.hasMoreTokens()){ args[i++] = st.nextToken();} - callback.receive( client, args ); + String[] tab= myTokenize(msgarg,IvyClient.EndArg); + System.out.println("received " + tab.length + " args"); + callback.receive( client, tab); + } + + private static String[] myTokenize(String s,String separator) { + int index=0, last=0, length=s.length(); + Vector v = new Vector(); + if (length!=0) while (true) { + index=s.indexOf(separator,last); + if (index==-1) { + v.add(s.substring(last,length)); + break; + } else if (index<s.length()) { + v.add(s.substring(last,index)); + last=index+1; + } else { + break; + } + } + String[] tab = new String[v.size()]; + v.copyInto(tab); + return tab; } |