One final comment. The StringBuffer class does not appear to have
a definition for equals ... so equals defaults to the Object equals which
is true only if the objects are the same ones. So,
StringBuffer sb1 = new StringBuffer("a");
StringBuffer sb2 = new StringBuffer("a");
boolean b = sb1.equals(sb2);
will result in b being false.
String does have an equals so
(eq (call (new java.lang.StringBuffer "a") toString) (call (new
java.lang.StringBuffer "a")
toString))
returns TRUE as expected.
As usual it does not pay to assume anything about the way in which Java classes
work.
Sorry for all this dribble but I go caught up in the 'need to know'.
Bob.
> Take a look at the code in MultiFinctions.java and you'll see that to
> do the subsetp test the Values of the list are converted to strings
> with ToString and the type is appended to this string. These strings
> are used to compare and determine 'equality'. This probably works
> most of the time but external addresses (i.e. Objects like StringBuffer)
> convert to string as "External-Address:objectname". This means that
> for objects, all those of the same class are considered to be the same.
> I think this may be intentional (for performance perhaps),but I also
> think it should be done as you say via equals.
>
> Bob.
>
> Bob Johnson wrote:
>
> > Fellow Jessians,
> >
> > I need to populate multislots with Java objects and subsequently
> > perform multislot set comparisons. I was assuming that all
> > comparisons on external addresses would be accomplished via the Java
> > "public boolean equals(Object obj)" method. The following interaction
> > seems to prove otherwise:
> >
> > ----------------------------------------------------------------------
> > Jess, the Java Expert System Shell
> > Jess Version 4.3 12/3/98
> >
> > Output appears in this window.
> > Type your input in the one-line input box below.
> > Jess> (defglobal ?*buffa* = (new java.lang.StringBuffer "a"))
> > TRUE
> > Jess> (defglobal ?*buffb* = (new java.lang.StringBuffer "b"))
> > TRUE
> > Jess> (subsetp (create$ ?*buffa*) (create$ ?*buffb*))
> > TRUE
> > Jess> (subsetp (create$ "a") (create$ "b"))
> > FALSE
> > Jess> (call ?*buffa* toString)
> > "a"
> > Jess> (call ?*buffb* toString)
> > "b"
> > Jess> (call ?*buffa* equals ?*buffb*)
> > FALSE
> > Jess>
> > ----------------------------------------------------------------------
> >
> > Am I expecting something that I shouldn't or is this a bug?
> >
> > Regards,
> >
> > Bob
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> > in the BODY of a message to [EMAIL PROTECTED], NOT to the
> > list. List problems? Notify [EMAIL PROTECTED]
> > ---------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------