[rules-dev] doubt in the rules
Edson Tirelli
tirelli at post.com
Thu Jul 12 16:07:56 EDT 2007
Hmm, this seems like a bug... may I ask you please to open a JIRA and
attach your test case?
Thank you,
Edson
2007/7/12, hare ram <hare.bond at gmail.com>:
>
> Hello everyone,
>
> The rules I wrote are
>
>
> rule "Test 1 Rule"
> salience 1000
> when
> Line ( $admin : line)
> eval (
> $admin.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
> Line ( $lineSecond : line)
> eval (
> $lineSecond.matches("^\\s*(\\S+)\\s+is\\s+(up|down|administratively
> down),\\s*line\\s+protocol\\s+is\\s+(up|down)\\s*$"))
> device : Device()
> then
> System.out.println
> ("********************************************");
> device.setVendorType("Foundry");
>
> end
>
> rule "Juniper Show Interface CanIParse() Rule"
> salience 5000
>
> when
> Line ( $regex : line)
> eval (
> $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
> Line ( $lineStr : line)
> eval (
> $lineStr.matches("^.*\\s*Physical\\s+interface:\\s*([^,\\s]+),\\s+([^,]+),.*$"))
>
> device : Device()
> then
> System.out.println
> ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
> device.setVendorType("Juniper");
> end
>
>
> Basically the rules are searching for two regular expressions, of which
> one is same for the both of the rules.But when i write the rules like the
> above
> I do not get the correct o/p, but however if i change my rules to (bold)
> as below, I get the correct output.So is it necessary the the declaration
> has
> to be same if the both the rules have same regex
>
> rule "Test 1 Rule"
> salience 1000
> when
> Line ( $regex : line)
> eval ( $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"
> ))
> Line ( $lineSecond : line)
> eval (
> $lineSecond.matches("^\\s*(\\S+)\\s+is\\s+(up|down|administratively
> down),\\s*line\\s+protocol\\s+is\\s+(up|down)\\s*$"))
> device : Device()
> then
> System.out.println
> ("********************************************");
> device.setVendorType("Foundry");
>
> end
>
> rule "Juniper Show Interface CanIParse() Rule"
> salience 5000
>
> when
> Line ( $regex : line)
> eval (
> $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
> Line ( $lineStr : line)
> eval (
> $lineStr.matches("^.*\\s*Physical\\s+interface:\\s*([^,\\s]+),\\s+([^,]+),.*$"))
>
> device : Device()
> then
> System.out.println
> ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
> device.setVendorType("Juniper");
> end
>
> Thanks
> Shiva
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20070712/d73eee43/attachment.html
More information about the rules-dev
mailing list