[xwiki-users] Where's the right parseInt?
I've recycled some code from the tutorials and snippets in my own code, and in particular I've used the following in some velocity scripts: #set($offset = $util.parseInt($request.get('offset'))) which yields the following warning in the log: WARN o.x.v.i.DefaultVelocityEngine - Deprecated usage of method [com.xpn.xwiki.api.Util.parseInt] in 40:xwiki:DemoSpace.DemoPage@4,29 I notice in http://www.xwiki.org/xwiki/bin/view/FAQ/WhyDoIHaveDeprecatedUsageOfMethodXXX... that a very similar warning is mentioned, but in the answer the recomendation is to switch from $xwiki.parseInt to $util.parseInt. But it looks like this has also been deprecated. So what should we be using instead?
Hi, The javadoc says: /** * Convert a {@code String} to a primitive {@code int}. * * @param str the String to convert to an integer * @return the parsed integer or zero if the string is not a valid integer number * @since 1.3 Milestone 2 * @deprecated use {@code $mathtool.toInteger($string)} * ({@link org.apache.velocity.tools.generic.MathTool#toInteger(java.lang.Object)}) */ @Deprecated public int Util.parseInt(String str) Hope it helps, -Vincent On 8 Jan 2015 at 06:49:23, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I've recycled some code from the tutorials and snippets in my own code, and in particular I've used the following in some velocity scripts: #set($offset = $util.parseInt($request.get('offset')))
which yields the following warning in the log: WARN o.x.v.i.DefaultVelocityEngine - Deprecated usage of method [com.xpn.xwiki.api.Util.parseInt] in 40:xwiki:DemoSpace.DemoPage@4,29
I notice in http://www.xwiki.org/xwiki/bin/view/FAQ/WhyDoIHaveDeprecatedUsageOfMethodXXX... that a very similar warning is mentioned, but in the answer the recomendation is to switch from $xwiki.parseInt to $util.parseInt. But it looks like this has also been deprecated. So what should we be using instead?
Thanks. Can you provide a link to that entry? Cheers, Bryn ----- Reply message ----- From: "[email protected]" <[email protected]> To: "XWiki Users" <[email protected]> Cc: "Bryn Jeffries" <[email protected]> Subject: [xwiki-users] Where's the right parseInt? Date: Thu, Jan 8, 2015 19:09 Hi, The javadoc says: /** * Convert a {@code String} to a primitive {@code int}. * * @param str the String to convert to an integer * @return the parsed integer or zero if the string is not a valid integer number * @since 1.3 Milestone 2 * @deprecated use {@code $mathtool.toInteger($string)} * ({@link org.apache.velocity.tools.generic.MathTool#toInteger(java.lang.Object)}) */ @Deprecated public int Util.parseInt(String str) Hope it helps, -Vincent On 8 Jan 2015 at 06:49:23, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I've recycled some code from the tutorials and snippets in my own code, and in particular I've used the following in some velocity scripts: #set($offset = $util.parseInt($request.get('offset')))
which yields the following warning in the log: WARN o.x.v.i.DefaultVelocityEngine - Deprecated usage of method [com.xpn.xwiki.api.Util.parseInt] in 40:xwiki:DemoSpace.DemoPage@4,29
I notice in http://www.xwiki.org/xwiki/bin/view/FAQ/WhyDoIHaveDeprecatedUsageOfMethodXXX... that a very similar warning is mentioned, but in the answer the recomendation is to switch from $xwiki.parseInt to $util.parseInt. But it looks like this has also been deprecated. So what should we be using instead?
On 8 Jan 2015 at 10:06:11, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
Thanks. Can you provide a link to that entry?
https://github.com/xwiki/xwiki-platform/blob/4f92c9fc4dc9d4bb7b42a54f3e289f4... -Vincent
Cheers,
Bryn ----- Reply message ----- From: "[email protected]" To: "XWiki Users" Cc: "Bryn Jeffries" Subject: [xwiki-users] Where's the right parseInt? Date: Thu, Jan 8, 2015 19:09 Hi,
The javadoc says:
/** * Convert a {@code String} to a primitive {@code int}. * * @param str the String to convert to an integer * @return the parsed integer or zero if the string is not a valid integer number * @since 1.3 Milestone 2 * @deprecated use {@code $mathtool.toInteger($string)} * ({@link org.apache.velocity.tools.generic.MathTool#toInteger(java.lang.Object)}) */ @Deprecated public int Util.parseInt(String str)
Hope it helps, -Vincent
On 8 Jan 2015 at 06:49:23, Bryn Jeffries ([email protected](mailto:[email protected])) wrote:
I've recycled some code from the tutorials and snippets in my own code, and in particular I've used the following in some velocity scripts: #set($offset = $util.parseInt($request.get('offset')))
which yields the following warning in the log: WARN o.x.v.i.DefaultVelocityEngine - Deprecated usage of method [com.xpn.xwiki.api.Util.parseInt] in 40:xwiki:DemoSpace.DemoPage@4,29
I notice in http://www.xwiki.org/xwiki/bin/view/FAQ/WhyDoIHaveDeprecatedUsageOfMethodXXX... that a very similar warning is mentioned, but in the answer the recomendation is to switch from $xwiki.parseInt to $util.parseInt. But it looks like this has also been deprecated. So what should we be using instead?
participants (2)
-
Bryn Jeffries -
vincent@massol.net