[rules-users] Multiple Object referencing error

Fnu Mahalakshmi FMahalakshmi at nyx.com
Tue Jun 8 10:13:15 EDT 2010


Hi,
Sorry about not posting the code. My mistake.

Classes :

public class Room {
    private String name
    private int number;
    // getter and setter methods here
}
public classs Sprinkler {
    private Room room;
    private boolean on;
    // getter and setter methods here
}
public class Fire {
    private Room room;
    // getter and setter methods here
}
 

I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}

                     2. with data of sprinkler and Room {"n/a",r1,"n/a",r3}

 

I am writing rule " if fire exists in room start sprinkler" { so if f1 and r1 in this case: I should get s1, r1 } But since no sprinkler in r2 , That data should not get outputted.
I want my ouput file to look like:
Name	Number
Xyz	1

# xyz is my room name and 1 is the room number : r1(xyz,1) . But I am unable to delete entries.Is there anyway I can do it?

#only this should appears as the other room does not have a sprinkler.

when

    Fire($room : room)

    $sprinkler : Sprinkler( room == $room, modified == false )

Then

    $sprinkler.setmodified(true);     

    modify( $sprinkler ) { setSprinkle( "s1" ) };

end


Error:
I am getting the error at a place where I am trying to write back from my working memory to my output file.
It is happening because the second rule to turn on the sprinkler does not work and as a result a null value is getting stored.
Is it possible that there can exists 2 different Room() objects with the same room.name ??
Because the room objects are getting stored from different files to the working memory ??
Do you think it better to store room objects in a separate list?? 
I store all information into a list and load that into the memory.
Am I going wrong here?

Please help.

Thank you.
-M
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.





More information about the rules-users mailing list