<br>   When you fall back into pure java (i.e., inside eval) there is nothing drools can do. <br>   Did you tried writing the rule in a drools pattern itself, instead of java eval?<br><br>when<br>   $f : Fact( details.END_SET == true, details[&quot;set&quot;] == 1, details[&#39;PLAYER1_SCORE&#39;] &gt; details.PLAYER2_SCORE )<br>
then<br>   // do something<br>end<br><br>   In the example above I mixed several ways you have to access Map elements, just to show it is possible. I prefer the &quot;.&quot; notation, but up to you.<br><br>   I didn&#39;t tested this, though... you need to check if that will raise NPE (I think it won&#39;t, but not sure) and also the use of the map element on the right side of the expression (details.PLAYER2_SCORE).<br>
<br>   []s<br>   Edson<br><br><div class="gmail_quote">2009/2/24 Zevenbergen, Alex <span dir="ltr">&lt;<a href="mailto:azevenbergen@paddypower.com">azevenbergen@paddypower.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">















<div link="blue" vlink="blue" lang="EN-GB">

<div>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">Thanks for replying. </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">rule &quot;Player
1 wins first set &quot; </span></font></p>

<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">    when</span></font></p>

<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">      $f : Fact()</span></font></p>

<p style="margin-left: 36pt;"><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">eval
($f.getDetails().get(&quot;END_SET&quot;).toString() == &quot;true&quot;
&amp;&amp; </span></font><font size="2" face="Courier New"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; font-family: &quot;Courier New&quot;; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">Integer.valueOf($f.getDetails().get(&quot;SET&quot;).toString())
</span></font><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">== 1 &amp;&amp; Integer.valueOf($f.getDetails().get(&quot;PLAYER1_SCORE&quot;).toString())
&gt; Integer.valueOf($f.getDetails().get(&quot;PLAYER2_SCORE&quot;).toString()))</span></font></p>

<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">    then</span></font></p>

<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">      <font color="red"><span style="color: red;">//then settle selection;</span></font></span></font></p>


<p style=""><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">end</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">this rules runs perfectly as long as the
hashmap contained in the ‘fact’ object has all the required keys and their
values are not null. For the time being I have just changed any null values to
a value of ‘DEFAULT’ but it would be preferable to be able to look for </span></font><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-IE">f.getDetails().get(&quot;END_SET&quot;) </span></font><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;" lang="EN-IE">(for example) knowing that the engine that sent
it might not be in an end_set state so may not have added that key. </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;" lang="EN-IE"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;" lang="EN-IE">That example is very
basic but as I create more rules for more sports it could become very
cumbersome to have to ensure that every key referenced in the rules is in the
hashmap each time!</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;" lang="EN-IE"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;" lang="EN-IE">Alex </span></font><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"></span></font></p>


<div>

<div style="text-align: center;" align="center"><font size="3" face="Times New Roman"><span style="font-size: 12pt;" lang="EN-US">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;" lang="EN-US">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;" lang="EN-US">
<a href="mailto:rules-dev-bounces@lists.jboss.org" target="_blank">rules-dev-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-dev-bounces@lists.jboss.org" target="_blank">rules-dev-bounces@lists.jboss.org</a>] <b><span style="font-weight: bold;">On Behalf Of </span></b>David Sinclair<br>

<b><span style="font-weight: bold;">Sent:</span></b> 24 February 2009 17:27<br>
<b><span style="font-weight: bold;">To:</span></b> Rules Dev List<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-dev] Dealing
with null pointer exceptions thrown by parsing rules</span></font><span lang="EN-US"></span></p>

</div><div><div></div><div class="Wj3C7c">

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

<p style="margin-bottom: 12pt;"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">I understand what you are
saying Alex, but could you post an example rule to see exactly how you are
doing it? It may be that you could simply rewrite the rule so you don&#39;t get the
NPE.</span></font></p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;">On Tue, Feb 24, 2009 at 4:24 AM, Zevenbergen, Alex &lt;<a href="mailto:azevenbergen@paddypower.com" target="_blank">azevenbergen@paddypower.com</a>&gt;
wrote:</span></font></p>

<div link="blue" vlink="purple">

<div>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Hi
all,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I
have started writing my rules packages and so have had a decent amount of
success. However all my rules are based on value pairs from a hashmap object
that is contained within my fact object. This approach works fine if the
parameter the rule is looking for is in the map and has a value.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">But
I will need to be able to pass null values to the rules (and expect them to
just not fire any rule that looks for that param), however this always throws a
null pointer exception.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">So
my question is: Is there any mechanism to deal with this in drools.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Simply
setting all nulls to a default value isn’t preferable in this situation as the
app is going to be used by several different sources and has to be able to take
in many different types of info.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Thanking
you,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Alex</span></font></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><br>
________________________________________________________________________<br>
Privileged, confidential and/or copyright information may be contained in this
communication. This e-mail and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to whom they are
addressed. If you are not the intended addressee, you may not copy, forward,
disclose or otherwise use this e-mail or any part of it in any way whatsoever.
To do so is prohibited and may be unlawful. If you have received this email in
error <br>
please notify the sender immediately.<br>
<br>
Paddy Power PLC may monitor the content of e-mail sent and received for the
purpose of ensuring compliance with its policies and procedures.<br>
<br>
Paddy Power plc, Airton House, Airton
  Road, Tallaght, Dublin
24 Registered in Ireland:
16956<br>
________________________________________________________________________</span></font></p>

</div>

<p style="margin-bottom: 12pt;"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a></span></font></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

</div></div></div><div><div></div><div class="Wj3C7c">


<br>
________________________________________________________________________<br>
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error <br>

please notify the sender immediately.<br>
<br>
Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.<br>
<br>
Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24  Registered in Ireland: 16956<br>
________________________________________________________________________<br>
</div></div></div>


<br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>