You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2007/09/25 23:00:50 UTC

[jira] Resolved: (VELOCITY-533) Treat arrays like fixed-length lists

     [ https://issues.apache.org/jira/browse/VELOCITY-533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna resolved VELOCITY-533.
-----------------------------------

    Resolution: Fixed

Thanks for the contribution Chris.  I changed the name to reflect that it isn't just for arrays of primitives.   This definitely cleans up and fills out the implementation nicely.

Things to note:
 - When a java.lang.Object method is called on an array in a template, the wrapper is not used.  This preserves backwards compatibility
 - When a length-changing method is called (e.g. add() or remove()), these currently exist but throw UnsupportedOperationExceptions.  I'm not sure this is ideal, but i don't think it's wrong.  So, i'm leaving it like that.

All this is done as of revision 579378

> Treat arrays like fixed-length lists
> ------------------------------------
>
>                 Key: VELOCITY-533
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-533
>             Project: Velocity
>          Issue Type: New Feature
>          Components: Engine
>    Affects Versions: 1.5
>            Reporter: Nathan Bubna
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: PrimitiveArrayList.java, PrimitiveArrayWrapper.java
>
>
> I'd like to see arrays treated like fixed-length List objects as much as possible.  This means auto-magically supporting size(), set(int,Object), get(int), and isEmpty() at a minimum.  Support for something like iterator() probably isn't necessary, since #foreach already handles arrays, but it might be good for completeness.  These should be possible via some Uberspect hackery.
> And since the goal is to free template authors from having to care about the differences between Lists and arrays, we might also consider supporting conversion between the two for method calls, so:
> $foo.wantsListHere($thisisAnArray)
> and
> $bar.wantsArrayHere($thisisAList)
> both work automatically.   I haven't yet looked into what it would take to do this.   If it is too hard or messy, i could be happy with just support for calling List methods on arrays.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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