SoarBean setter for variable not working

2 views
Skip to first unread message

John Finnson

unread,
Jun 21, 2010, 11:55:56 AM6/21/10
to jsoar...@googlegroups.com
Hi, according to this link: http://code.google.com/p/jsoar/wiki/JSoarOutput. "A bean property must either be public, or provide a setter method. "

I created this class and my Eclipse generated setter methods do not work.

public class Printer {

    private int PrintID;
    private String PrintString;
   
    public Printer(){
       
    }

    public int getPrintID() {
        return PrintID;
    }

    public void setPrintID(int printID) {
        PrintID = printID;
    }

    public String getPrintString() {
        return PrintString;
    }

    public void setPrintString(String printString) {
        PrintString = printString;
    }
   
   
}

--
Sincerely,
John Finnson

Dave Ray

unread,
Jun 21, 2010, 4:33:54 PM6/21/10
to jsoar...@googlegroups.com
John. I'll take a look at this tonight. Can you provide any more
detail? In particular, how are you registering the output handler and
what does your Soar code look like that should trigger the bean.

Thanks

Dave

> --
> You received this message because you are subscribed to the Google Groups "jsoar-user" group.
> To post to this group, send email to jsoar...@googlegroups.com.
> To unsubscribe from this group, send email to jsoar-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jsoar-user?hl=en.
>

John Finnson

unread,
Jun 21, 2010, 6:27:20 PM6/21/10
to jsoar...@googlegroups.com
Hi, here is my JSoar code:

final SoarBeanOutputManager manager = new SoarBeanOutputManager(threaded.getEvents());
        final SoarBeanOutputHandler<Printer> handler = new SoarBeanOutputHandler<Printer>() {



            @Override
            public void handleOutputCommand(SoarBeanOutputContext context,Printer bean) {
                // TODO Auto-generated method stub
                System.out.println("Printing!"+bean.getPrintString());
               
                tempPrinter = bean;

                context.setStatus("complete");
            }
        };
        manager.registerHandler("testing.types.Printer", handler, Printer.class);

The soar code that triggers the bean was created using Herbal and this is the output Soar code:

sp {apply*testing-problemspaces-initial*PrintTheString
    (state <local> ^top <top> ^parent <parent> ^name testing-problemspaces-initial ^operator <o>)
    (<o> ^name testing-operators-PrintTheString)
    (<top> ^io <i1>)
    (<i1> ^output-link <i2>)
    (<o> ^Printer <Printer>)
    (<Printer> ^PrintString <Printer-PrintString>)
    (<Printer> ^PrintID <Printer-PrintID>)
    -->
    (write |<hdb>testing.operators.PrintTheString</hdb>| (crlf))
    (write |<hdb>testing.actions.PrintTheString</hdb>| (crlf))
    (<i2> ^|testing.types.Printer| <testing-types-Printer5>)
    (<testing-types-Printer5> ^PrintID 11 ^PrintString |neww| )
    (write <Printer-PrintString> )
    (<Printer> ^PrintString <Printer-PrintString> -)
    (<Printer> ^PrintString |changed| )
}

It is a little ugly because it does a few other things but the important lines are:

(<i2> ^|testing.types.Printer| <testing-types-Printer5>)
    (<testing-types-Printer5> ^PrintID 11 ^PrintString |neww| )


Thanks in advance for helping me with this issue.
--
Sincerely,
John Finnson

Dave Ray

unread,
Jun 21, 2010, 8:09:19 PM6/21/10
to jsoar...@googlegroups.com
Hey John,

JavaBean properties
(http://docstore.mik.ua/orelly/java-ent/jnut/ch06_02.htm) start with a
lower case letter, so if the setter is called setPrintID(), then the
property is "printID". JSoar does log a warning about it, but maybe
something more drastic should happen if it doesn't know what to do. So
in your rule, change PrintID to printID and PrintString to printString
and it will work fine. I tested it and got the expected results.

Let me know if you have any other issues with SoarBeans. They haven't
been used that much so I'm interested in any feedback you might have
about what's tricky, etc.

Thanks,

Dave

Reply all
Reply to author
Forward
0 new messages