velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11924] New: - Add Support for Static Utility Classes
Date Thu, 22 Aug 2002 10:20:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11924>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11924

Add Support for Static Utility Classes

           Summary: Add Support for Static Utility Classes
           Product: Velocity
           Version: 1.3-rc1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Source
        AssignedTo: velocity-dev@jakarta.apache.org
        ReportedBy: baliuka@mwm.lt


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

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


Mime
View raw message