You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by stefano masiero <st...@gmail.com> on 2012/09/21 17:33:31 UTC

[jxpath] - Is it possible to override Number comparison in CoreOperationCompare?

Hi all!
First of all sorry for my english!

I'm using jxpath-1.2 since 2009 in production environment.

I'm a great fan of jxpath and I'm using it in a dao framework to load xml
files and run xpath queries on them.

I've a problem using filter expressions on an xml element of type decimal
(mapped on a BigDecimal) exceed 18 digits.

I'm expecting one object as result of the query but I've two.

The problem is at the line 131 of the method equal in the class
org.apache.commons.jxpath.ri.compiler.CoreOperationCompare:

        else if (l instanceof Number || r instanceof Number) {
            return (InfoSetUtil.doubleValue(l) ==
InfoSetUtil.doubleValue(r));
        }

These are the two BigDecimal that the query has to compare:
l = 4618200845616818081
r = 4618200845616818593
and the method returns true :(

I've understand that the problem is the conversion to double type.
How I can override this method without implementing a new compiler?

If I can, do you see side effects in using the compareTo?

Thanks in advance for any help.

Stefano