You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by dl...@apache.org on 2007/03/28 01:07:09 UTC
svn commit: r523108 -
/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
Author: dlr
Date: Tue Mar 27 16:07:08 2007
New Revision: 523108
URL: http://svn.apache.org/viewvc?view=rev&rev=523108
Log:
* src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
(value): Support use of any sub-class of java.lang.Number as an end
of the integer values used to compose a range.
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java?view=diff&rev=523108&r1=523107&r2=523108
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java Tue Mar 27 16:07:08 2007
@@ -97,13 +97,13 @@
* if not an Integer, not much we can do either
*/
- if ( !( left instanceof Integer ) || !( right instanceof Integer ))
+ if ( !( left instanceof Number ) || !( right instanceof Number ))
{
- log.error((!(left instanceof Integer) ? "Left" : "Right")
+ log.error((!(left instanceof Number) ? "Left" : "Right")
+ " side of range operator is not a valid type. "
- + "Currently only integers (1,2,3...) and Integer type is supported. "
+ + "Currently only integers (1,2,3...) and the Numbertype is supported. "
+ context.getCurrentTemplateName() + " [line " + getLine()
- + ", column " + getColumn() + "]");
+ + ", column " + getColumn() + ']');
return null;
}
@@ -113,8 +113,8 @@
* get the two integer values of the ends of the range
*/
- int l = ( (Integer) left ).intValue() ;
- int r = ( (Integer) right ).intValue();
+ int l = ((Number) left).intValue() ;
+ int r = ((Number) right).intValue();
/*
* find out how many there are
Re: svn commit: r523108 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
Posted by Nathan Bubna <nb...@gmail.com>.
On 3/27/07, Will Glass-Husain <wg...@gmail.com> wrote:
> Does this mean a decimal number is supported in an integer range?
yeah, it just takes the intValue(). i was a little surprised at this
at first, until i realized it basically makes it so that template
authors needn't care about the number's type. numbers just work. i
like that. :)
> WILL
>
> On 3/27/07, dlr@apache.org <dl...@apache.org> wrote:
> > Author: dlr
> > Date: Tue Mar 27 16:07:08 2007
> > New Revision: 523108
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=523108
> > Log:
> > * src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
> > (value): Support use of any sub-class of java.lang.Number as an end
> > of the integer values used to compose a range.
> >
> > Modified:
> > velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
> >
> > Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
> > URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java?view=diff&rev=523108&r1=523107&r2=523108
> > ==============================================================================
> > --- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java (original)
> > +++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java Tue Mar 27 16:07:08 2007
> > @@ -97,13 +97,13 @@
> > * if not an Integer, not much we can do either
> > */
> >
> > - if ( !( left instanceof Integer ) || !( right instanceof Integer ))
> > + if ( !( left instanceof Number ) || !( right instanceof Number ))
> > {
> > - log.error((!(left instanceof Integer) ? "Left" : "Right")
> > + log.error((!(left instanceof Number) ? "Left" : "Right")
> > + " side of range operator is not a valid type. "
> > - + "Currently only integers (1,2,3...) and Integer type is supported. "
> > + + "Currently only integers (1,2,3...) and the Numbertype is supported. "
> > + context.getCurrentTemplateName() + " [line " + getLine()
> > - + ", column " + getColumn() + "]");
> > + + ", column " + getColumn() + ']');
> >
> > return null;
> > }
> > @@ -113,8 +113,8 @@
> > * get the two integer values of the ends of the range
> > */
> >
> > - int l = ( (Integer) left ).intValue() ;
> > - int r = ( (Integer) right ).intValue();
> > + int l = ((Number) left).intValue() ;
> > + int r = ((Number) right).intValue();
> >
> > /*
> > * find out how many there are
> >
> >
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> wglass@forio.com
> www.forio.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: svn commit: r523108 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
Posted by Will Glass-Husain <wg...@gmail.com>.
Does this mean a decimal number is supported in an integer range?
WILL
On 3/27/07, dlr@apache.org <dl...@apache.org> wrote:
> Author: dlr
> Date: Tue Mar 27 16:07:08 2007
> New Revision: 523108
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=523108
> Log:
> * src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
> (value): Support use of any sub-class of java.lang.Number as an end
> of the integer values used to compose a range.
>
> Modified:
> velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
>
> Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
> URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java?view=diff&rev=523108&r1=523107&r2=523108
> ==============================================================================
> --- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java (original)
> +++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java Tue Mar 27 16:07:08 2007
> @@ -97,13 +97,13 @@
> * if not an Integer, not much we can do either
> */
>
> - if ( !( left instanceof Integer ) || !( right instanceof Integer ))
> + if ( !( left instanceof Number ) || !( right instanceof Number ))
> {
> - log.error((!(left instanceof Integer) ? "Left" : "Right")
> + log.error((!(left instanceof Number) ? "Left" : "Right")
> + " side of range operator is not a valid type. "
> - + "Currently only integers (1,2,3...) and Integer type is supported. "
> + + "Currently only integers (1,2,3...) and the Numbertype is supported. "
> + context.getCurrentTemplateName() + " [line " + getLine()
> - + ", column " + getColumn() + "]");
> + + ", column " + getColumn() + ']');
>
> return null;
> }
> @@ -113,8 +113,8 @@
> * get the two integer values of the ends of the range
> */
>
> - int l = ( (Integer) left ).intValue() ;
> - int r = ( (Integer) right ).intValue();
> + int l = ((Number) left).intValue() ;
> + int r = ((Number) right).intValue();
>
> /*
> * find out how many there are
>
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org