Velocity
  1. Velocity
  2. VELOCITY-102

Add Support for Static Utility Classes

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3-rc1
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All

      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

        Activity

        Juozas Baliuka created issue -
        Jeff Turner made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 11924 12314972
        Henning Schmiedehausen made changes -
        Component/s Source [ 12310214 ]
        Bugzilla Id 11924
        Fix Version/s 1.6 [ 12310290 ]
        Component/s Engine [ 12311337 ]
        Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
        Nathan Bubna made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12324977 ] Default workflow, editable Closed status [ 12551819 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551819 ] jira [ 12552297 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Juozas Baliuka
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development