Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-102

Add Support for Static Utility Classes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3-rc1
    • 1.6
    • Engine
    • None
    • Operating System: All
      Platform: All
    • 11924

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            baliuka@mwm.lt Juozas Baliuka
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: