Hi Lauren,

I'm sure you could make something work with multislots and
array-returning properties (the basic design here is sound) but it
would not be very efficient. 

One correspondent has suggested generating a Bean class and compiling
it at runtime. While this would work, it would be tricky, and would
require a compiler as part of the runtime system, which may or may not
work for your application.

Another idea, and one which I -think- you could make work, would be to
use a peculiar custom BeanInfo object. BeanInfo objects are used to
specify what properties a bean has, when they can't be determined by
reflection. The BeanInfo maps between the pseudo-Bean's methods and
the actual property names. Anyway, I haven't worked out exactly how
you'd do this, but imagine a BeanInfo class that read a file (or other data)
file to determine what properties to reflect. Now at runtime, you can
just supply it with the proper data, and when Jess loads your
BeanInfo, it will reflect the appropriate properties.


I think Lauren Blau Halverson x1285 wrote:
> 
> I have the following design problem and possible solution, but I'm
> hoping that maybe I'm overlooking something obvious (and more
> straightforward):
> 
> We have a system that inputs elements that have variable
> attributes. There is a known list of "legal" attributes at runtime,
> but not during development. The Java class representing this element
> has a HashTable that holds the attribute values keyed on the attribute 
> name. The accessor function for an attribute is 
> 
> public String getAttributeValue(String attributeName);
> 
> We would like the end-user of our system to be able to write Jess
> rules that use all of the legal attributes. Since we cannot define
> bean pattern accessor methods at development time, we need some way
> to either do this definition at runtime, or to access these varied
> attributes through a single slot in JESS.
> 
> My partial solution would be to have a single attribute that is
> multivalued (think of an association list) and have the rules written
> like
> 
> (defrule match-on-attribute-values ...
>    (element (OBJECT ?element) 
>             (attribute $?front SOMEATTRIBUTENAME ?attribute_value1 
>                $?unneeded ANOTHERATTRIBUTENAME ?attribute_value2 
>              $?rest))
>    (element (OBJECT ?element2)
>              (attribute $?front SOMEATTRIBUTENAME ?attribute_value1 
>                 $?unneeded ANOTHERATTRIBUTENAME ?attribute_value2 
>              $?rest))
> =>
>  action
> )
> 
> would this work if the getAttribute method returns a String array?
> I've done this kind of pattern matching on facts before, but never on
> a multislot. What if the matching needed to get more
> complicated...like:
> 
>  (defrule match-on-attribute-values ...
>    (element (OBJECT ?element) 
>             (attribute $?front SOMEATTRIBUTENAME ?attribute_value1 
>                $?unneeded ANOTHERATTRIBUTENAME ?attribute_value2 
>              $?rest))
>    (element (OBJECT ?element2)
>              (attribute $?front SOMEATTRIBUTENAME
>                         ?att_value3&:(< ?att_value3  ?attribute_value1) 
>                 $?unneeded ANOTHERATTRIBUTENAME 
>                        ?att_value4&:(> ?att_value4 ?attribute_value2 )
>              $?rest))
> =>
>  action
> )
> 
> alternatively, does anyone have a pattern for generating accessor
> methods and properties at runtime so that we could get one property
> per attribute?
> 
> Thanks,
> Lauren
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9214                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
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]
---------------------------------------------------------------------

Reply via email to