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 2008/08/19 21:07:45 UTC

[jira] Resolved: (VELOCITY-102) Add Support for Static Utility Classes

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

Nathan Bubna resolved VELOCITY-102.
-----------------------------------

    Resolution: Fixed

> Add Support for Static Utility Classes
> --------------------------------------
>
>                 Key: VELOCITY-102
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-102
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.3-rc1
>         Environment: Operating System: All
> Platform: All
>            Reporter: Juozas Baliuka
>            Priority: Minor
>             Fix For: 1.6
>
>
> Support for Static Utility Classes is:
> 1) define namespaces
>   
>   context.defineNamespace("Math").add( java.lang.Math.class  ) ;
>    used as $Math.sin(0)
> 2) Add / Replace / remove methods in namespace :
>   context.getNamespace("Math").add(MyRandom.class.getMethod("randomString",new 
> Class[]{int.class}))
>   used as $Math.randomString(12)
> 3) "union" on namespaces
>  context.defineNamespace("Utils")
>           .add(context.getNamespace("Math"))
>           .add(context.defineNamespace("Collections",Collections.class ) );
>  used as:
>   $Utils.sin(0)
>   $Utils.sort($list)
> 4) Global namespace
>   context.getGlobalNamespace().add( Math.class ); 
>   used as $sin(0)
> 5) inline namespaces:
>  #use java.lang.Math as Math
>    $Math.sin(0)
>  #end
>  #with Math
>    $sin(0)
>  #end

-- 
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