I think David G wrote:
> Hi! Two questions. For nested Java attributes where data elements are
> inside other data elements inside other data elements, it seems that JESS
> requires a Java program to "add" the items to be placed in "definstance" one
> at a time if pattern matching is to occur. Is there a better (i.e., fewer
> lines of code or adding whole-objects-at-a-time) method to construct objects
> in Java for JESS that are to be pattern-matched?
>
You do have to definstance each item at once, but that's only one
method call (Rete.definstance()) per item. If you've got a "composite"
class with lots of children to definstance, just write a Java function
to definstance the object and all the children.
> Second, there seems to be a trivial error in the following due to something
> I seem to be misunderstanding. I create a "Person" object as a dynamic
> definstance successfully, but get a "Property not found: tn" (from
> DefinstanceList.createFact) message when I call "settn" with one String
> parameter. What am I missing?
Jess uses the java.beans.Introspector class's definition of what a
property is, and Introspector in turns follows the Java Beans spec. In
the absence of an explicit BeanInfo object that says otherwise, the
method settn() does not define a property; the setter method for a
property "tn" is named "setTn()" (note capitalization.)
Even if you change that, Jess won't think "tn" is a property until
there's a getTn() too that allows the property's value to be read. You
can have the getter alone for a read-only property, but not the setter
alone.
>
> Thanks!
>
> David
>
> import java.lang.reflect.Array;
> import java.beans.*;
>
> public class Person extends Object implements java.io.Serializable {
> private String tn;
> private String test[];
>
> public Person (String telephone, String parm[]) {
> super();
> int l = parm.length;
> test = new String[l];
> int i;
>
> for (i=0; i<l; i++)
> test [i] = parm[i];
> tn = telephone;
> }
>
> private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
>
> public void addPropertyChangeListener(PropertyChangeListener pcl)
> {
> pcs.addPropertyChangeListener(pcl);
> }
> public void removePropertyChangeListener(PropertyChangeListener pcl)
> {
> pcs.removePropertyChangeListener(pcl);
> }
>
> public void settn (String value) {
> String temp = tn;
> tn = value;
> pcs.firePropertyChange ("tn", temp, tn);
> }
> }
>
>
> _________________________________________________________________
> Surf the Web without missing calls! Get MSN Broadband.
> http://resourcecenter.msn.com/access/plans/freeactivation.asp
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) 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 9012 [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
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------