<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You have something similar to what you want. If <b>resultState </b>is
a global variable, there is nothing stopping you from writing any
amount of java code you want in the consequence part. Create
whatever you want and then do <b>resultState.add(SOMEOBJECT);<br>
<br>
</b>You already perform a similar action with the code you have
already:<br>
frontAxleAttributes.put("Capacity" ,new
Double(c.attributes.Capacity));<br>
<br>
hth<br>
Minh<br>
<br>
<br>
On 10/18/2010 2:58 PM, Navdeep Kumar wrote:
<blockquote
cite="mid:AANLkTikHOUUp0SCFc3fWbF_zL4bsWWuCKNnyafGwJ=xJ@mail.gmail.com"
type="cite">Hi..
<div><br>
</div>
<div>After execution of each rule, i want to create a new object
of a particular class and want to add that to the list. i know
how to set the global list but i am not sure whether i can
create a new instance in the consequence of the rule.</div>
<div><br>
</div>
<div><br>
</div>
<div>here is the rule file and description that what i am trying
to do.</div>
<div><br>
</div>
<div>import java.util.Map;</div>
<div>global java.util.HashMap availablity;</div>
<div>global java.util.HashMap frontAxleAttributes;</div>
<div>global java.util.HashMap frontSuspensionAttributes;</div>
<div>global java.util.ArrayList resultState;</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>rule "FrontAxle:Capacity|FrontSuspension:Capacity"</div>
<div>dialect "mvel"</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>when</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>b:Feature(featureClass.name=="FrontSuspension") </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>c:Feature(featureClass.name=="FrontAxle")</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>eval(b.attributes.Capacity>=c.attributes.Capacity)</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>then</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(b.attributes.Capacity);</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>frontAxleAttributes.put("Capacity"
,new Double(c.attributes.Capacity));</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>frontSuspensionAttributes.put("Capacity",
new Double(b.attributes.Capacity));</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>frontAxleAttributes.put("Feature
Code",b.getCode());</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>frontSuspensionAttributes.put("Feature
Code",c.getCode());</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>availablity.put(b.featureClass.getName+"-"+c.getFeatureClass().getName(),new
Double(b.attributes.Capacity));</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> <b>
</b></span><b>// i want to create a new Object of a class
named AvailabilityRuleState and want to add that in the list
named resultState. </b></div>
<div><span class="Apple-tab-span" style="white-space: pre;"><b> </b></span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>end</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span> </div>
<div><br>
</div>
<div><span class="Apple-style-span" style="white-space: pre;"><b>//resultState
is a list of AvailabilityRuleState Class. Please do check
the global declaration if that is wrong.</b></span></div>
<div><br>
</div>
<div>will appreciate your help.</div>
<div><br>
</div>
<div>Thanks.</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
</body>
</html>