[muscle] Re: Another Java MUSCLE client patch

  • From: Jeremy Friesner <jaf@xxxxxxxxxxxx>
  • To: Lior Okman <lior.okman@xxxxxxxxxxxxxxxxxx>
  • Date: Thu, 11 Jan 2007 14:27:58 -0800

Hi Lior,

On Thursday 11 January 2007 12:49, Lior Okman wrote:
> I hope I'm not too late to have this patch included in 3.25...

Nope, it's not too late... although actually enough has changed that it's now 
going to be called the 3.30 release instead of the 3.25 release.  I'll 
probably wait until things have settled down a bit before releasing it, but 
in the meantime, here is an unofficial snapshot of the current muscle SVN 
repository (including the patches from your latest email):

   http://www.lcscanada.com/muscle/muscle3.30b.zip

> 1. The flattenedSize() method is only called once for each message being
> flattened.

Very cool :^)

> 2. The various IOGateways are turned public again. The reasoning is that
> you should use the factory if you don't know what you need, but if you
> do know what you need, you should be able to directly create it.
> 3. A few minor cleanups to the previous StringBuffer() patch - no need
> for this type of code, since boolean's toString() is "true" or "false".
>     boolean[] array;
>     ...
>     ret.append((array[i]) ? "true " : "false ");

Okay, those make sense.

> 4. The Message.whatString() was fixed to not return a \0 character in
> case the int being passed was equal to zero. This would cut short data
> being displayed with the toString() methods.

I took this a bit further, and now it checks each byte individually... that 
way it will also work on cases where some of the bytes are zero but not all 
of them (e.g. w==1):

   public static String whatString(int w)
   {
      byte [] temp = new byte[4];
      temp[0] = (byte)((w >> 24) & 0xFF); if (temp[0] == 0) temp[0] = '0';
      temp[1] = (byte)((w >> 16) & 0xFF); if (temp[1] == 0) temp[1] = '0';
      temp[2] = (byte)((w >> 8)  & 0xFF); if (temp[2] == 0) temp[2] = '0';
      temp[3] = (byte)((w >> 0)  & 0xFF); if (temp[3] == 0) temp[3] = '0';
      return new String(temp);
   }

-Jeremy

Other related posts: