commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r896944 - in /commons/proper/jexl/trunk/src: main/java/org/apache/commons/jexl2/ main/java/org/apache/commons/jexl2/parser/ test/java/org/apache/commons/jexl2/
Date Thu, 07 Jan 2010 18:57:38 GMT
On 07/01/2010, henrib@apache.org <henrib@apache.org> wrote:
> Author: henrib
>  Date: Thu Jan  7 18:00:07 2010
>  New Revision: 896944
>
>  URL: http://svn.apache.org/viewvc?rev=896944&view=rev
>  Log:
>  JEXL-46; adding Perl-like regular-expression operators (=~ and !~)

[...]

>      /** {@inheritDoc} */
>  +    public Object visit(ASTERNode node, Object data) {
>  +        Object left = node.jjtGetChild(0).jjtAccept(this, data);
>  +        Object right = node.jjtGetChild(1).jjtAccept(this, data);
>  +        try {
>  +            return arithmetic.matches(left, right) ? Boolean.TRUE : Boolean.FALSE;

or could use

     Boolean.valueOf(arithmetic.matches(left, right));

>  +        } catch (RuntimeException xrt) {
>  +            throw new JexlException(node, ">= error", xrt);

s/>=/=~/

>  +        }
>  +    }
>  +
>  +    /** {@inheritDoc} */
>      public Object visit(ASTIdentifier node, Object data) {
>          String name = node.image;
>          if (data == null) {
>  @@ -972,6 +985,17 @@
>      }
>
>      /** {@inheritDoc} */
>  +    public Object visit(ASTNRNode node, Object data) {
>  +        Object left = node.jjtGetChild(0).jjtAccept(this, data);
>  +        Object right = node.jjtGetChild(1).jjtAccept(this, data);
>  +        try {
>  +            return arithmetic.matches(left, right) ? Boolean.FALSE : Boolean.TRUE;
>  +        } catch (RuntimeException xrt) {
>  +            throw new JexlException(node, ">= error", xrt);

s/>=/!~/

>  +        }
>  +    }
>  +
>  +    /** {@inheritDoc} */
>      public Object visit(ASTNotNode node, Object data) {
>          Object val = node.jjtGetChild(0).jjtAccept(this, data);
>          return arithmetic.toBoolean(val) ? Boolean.FALSE : Boolean.TRUE;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message