After looking at XPath 2.0 which introduces XSD types, maybe we should
return java.lang.Number again?

Maybe the method returning a double could be named doubleValueOf()?

James
----- Original Message -----
From: "Elliotte Rusty Harold" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 16, 2002 2:40 AM
Subject: [Jaxen] Return type of numberValueOf


> Consider these two methods from org.jaxen.BaseXPath:
>
> public boolean *booleanValueOf*(Object
<http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Object.html>
context) throws JaxenException <cid:[EMAIL PROTECTED]>
>
>
> public Number
<http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Number.html>
numberValueOf(Object
<http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Object.html>
context) throws JaxenException <cid:[EMAIL PROTECTED]>
>
>
> The first one returns a primitive data type. The second one returns a
> fairly generic Object type. Since XPath 1.0 numbers are in fact IEEE 754
> doubles, just like Java doubles, I suggest that the second method should
> instead be
>
> public double *numberValueOf*(Object
<http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Object.html>
context) throws JaxenException <cid:[EMAIL PROTECTED]>
>
>
> If there's some good reason for returning an Object type I haven't
> noticed yet, then it should return a java.lang.Double rather than a
> java.lang.Number; and for consistency the booleanValueOf() method should
> return a java.lang.Boolean. However, I think most programmers would
> prefer to receive the primitve types from these methods.
>
> --
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |           The XML Bible, 2nd Edition (IDG Books, 2001)             |
> |             http://www.cafeconleche.org/books/bible2/              |
> |   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     |
> |  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
> +----------------------------------+---------------------------------+
>
>


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to