JESS: Matching Java Objects

View: New views
4 Messages — Rating Filter:   Alert me  

JESS: Matching Java Objects

by Marco Zappatore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear JESS users and devs,
I have to write a group of rules dealing with nested
java beans. The (simplified) scenario is the following:

1) let's suppose I
have three Java beans: JB1, JB2 and JB3; both JB2 and JB3 can be slots of JB1;
JB2 and JB3 have normal slots (with different data types but without other
nested Java beans)
2) I also have proper templates, created on the basis of the
corresponding java beans (declare jb1 from-class ...)
3) the shadow facts have
been added to the working memory using (definstance ...)

Now I have to write a
rule in order to activate something if JB1 has JB2 as slot and something else
on the other case. How can I implement the matching between the slot of JB1 and
the template of JB2 and JB3? Calling "equals" method doesn't work....
In other
words, at this level I have to verify only which Java bean is a slot of JB1
without considering the slots of JB2 and JB3
Is there another way to do that?


Thanks in advance for your replies.
  Marco Zappatore


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: Matching Java Objects

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You mean like an "instanceof" test?

(defrule do-if-jb2
   (JB1 (some-slot ?x&:(instanceof ?x com.whatever.JB2)))
   =>
   ...



On Jul 26, 2009, at 5:57 PM, marcozappatore@... wrote:

> Dear JESS users and devs,
> I have to write a group of rules dealing with nested
> java beans. The (simplified) scenario is the following:
>
> 1) let's suppose I
> have three Java beans: JB1, JB2 and JB3; both JB2 and JB3 can be  
> slots of JB1;
> JB2 and JB3 have normal slots (with different data types but without  
> other
> nested Java beans)
> 2) I also have proper templates, created on the basis of the
> corresponding java beans (declare jb1 from-class ...)
> 3) the shadow facts have
> been added to the working memory using (definstance ...)
>
> Now I have to write a
> rule in order to activate something if JB1 has JB2 as slot and  
> something else
> on the other case. How can I implement the matching between the slot  
> of JB1 and
> the template of JB2 and JB3? Calling "equals" method doesn't work....
> In other
> words, at this level I have to verify only which Java bean is a slot  
> of JB1
> without considering the slots of JB2 and JB3
> Is there another way to do that?
>
>
> Thanks in advance for your replies.
>  Marco Zappatore
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users  
> you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...
> .
> --------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: Matching Java Objects

by Marco Zappatore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, thanks, this kind of test works.
This structure of nested java-beans is a consequence of using object properties in my OWL ontology (properties having OWL classes both as domain and as range).
Do you think that "instanceof" tests could be a not so efficient pattern-matching technique from a computational point of view? (i.e. with some hundreds of "instanceof" tests)

 Marco

Ernest Friedman-Hill wrote:
You mean like an "instanceof" test?

(defrule do-if-jb2
   (JB1 (some-slot ?x&:(instanceof ?x com.whatever.JB2)))
   =>
   ...



On Jul 26, 2009, at 5:57 PM, marcozappatore@libero.it wrote:

> Dear JESS users and devs,
> I have to write a group of rules dealing with nested
> java beans. The (simplified) scenario is the following:
>
> 1) let's suppose I
> have three Java beans: JB1, JB2 and JB3; both JB2 and JB3 can be  
> slots of JB1;
> JB2 and JB3 have normal slots (with different data types but without  
> other...

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@address.com'
in the BODY of a message to majordomo@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-users@sandia.gov.
--------------------------------------------------------------------

Re: JESS: Matching Java Objects

by Marco Zappatore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Yes, thanks, this kind of test works.
This structure of nested java-beans is a consequence of using object
properties in my OWL ontology (properties having OWL classes both as domain
and as range).
Do you think that "instanceof" tests could be a not so efficient
pattern-matching technique from a computational point of view? (i.e. with
some hundreds of "instanceof" tests)

 Marco


Ernest Friedman-Hill wrote:

>
> You mean like an "instanceof" test?
>
> (defrule do-if-jb2
>    (JB1 (some-slot ?x&:(instanceof ?x com.whatever.JB2)))
>    =>
>    ...
>
>
>
> On Jul 26, 2009, at 5:57 PM, marcozappatore@... wrote:
>
>> Dear JESS users and devs,
>> I have to write a group of rules dealing with nested
>> java beans. The (simplified) scenario is the following:
>>
>> 1) let's suppose I
>> have three Java beans: JB1, JB2 and JB3; both JB2 and JB3 can be  
>> slots of JB1;
>> JB2 and JB3 have normal slots (with different data types but without  
>> other...
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@....
> --------------------------------------------------------------------
>
>
>

--
View this message in context: http://www.nabble.com/JESS%3A-Matching-Java-Objects-tp24680602p24681626.html
Sent from the Jess mailing list archive at Nabble.com.



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------