On 30 May 2011 16:09, Bala <span dir="ltr">&lt;<a href="mailto:bala.ganesh@accenture.com">bala.ganesh@accenture.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Is there a simplified way of mapping than what i have done???<br>
<br>
Java function :<br>
function boolean checkIfVia(Route route, String locationCode)<br>
{<br>
  if(route != null)<br>
 {<br>
   Via[] viaArr = route.getViaArray();<br>
   for(int i=1; i &lt; viaArr.length; i++)<br>
   {<br>
      if(viaArr[i].getLocation().equalsIgnoreCase(locationCode))<br>
          return true;<br>
      else<br>
           return false;<br>
   }<br>
 }<br>
 return false;<br>
}<br>
<br></blockquote><div>I don&#39;t think that <br>   else<br>        return false;<br>is correct, because then the result would only depend on viaArr[1], and that ought to be written differently.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
<br>
<br>
Dsl Mapping:<br>
<br>
[keyword][][Ff][Uu][Nn][Cc]<br>
[Cc][Hh][Ee][Cc][Kk][Ii][Ff][Vv][Ii][Aa]=function boolean checkIfVia(Route<br>
route, String locationCode)\n{checkIfViaBody}<br></blockquote><div><br>Do you mean that you can write in the DSLR:<br>   func checkIfVia<br>A keyword must be a single token.<br><br>There&#39;s no need to split this into several definitions. Put it all in one keyword definition.<br>
Never mind the \n.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[keyword][]checkIfViaBody=\nif(route != null)\n{checkIfViaIfBlock}\nreturn<br>
false;\n<br>
[keyword][]checkIfViaIfBlock=\nVia[] viaArr = route.getViaArray();\nfor(int<br>
i=1; i &lt; viaArr.length; i++)\n{checkIfViaForBlock}\n<br>
[keyword][]checkIfViaForBlock=\nif(viaArr[i].getLocationCode().equalsIgnoreCase(locationCode))\n<br>
return true; \nelse \nreturn false;\n<br>
<br></blockquote><div><br>But it would be much simpler to import a Java function.<br><br>-W<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
<br>
<br>
-----<br>
Thanks,<br>
Bala<br>
<font color="#888888">--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Clarification-needed-in-writing-DSL-function-mapping-tp3002064p3002064.html" target="_blank">http://drools.46999.n3.nabble.com/Clarification-needed-in-writing-DSL-function-mapping-tp3002064p3002064.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>