[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/directive DirectiveConstants.java
From:       jvanzyl () locus ! apache ! org
Date:       2000-11-27 23:57:59
[Download RAW message or body]

jvanzyl     00/11/27 15:57:58

  Modified:    src/java/org/apache/velocity/runtime/directive
                        Directive.java Foreach.java Include.java Macro.java
                        Parse.java VelocimacroProxy.java
  Added:       src/java/org/apache/velocity/runtime/directive
                        DirectiveConstants.java
  Removed:     src/java/org/apache/velocity/runtime/directive Dummy.java
  Log:
  - The directives are now initialized in the Velocity Runtime.
    The getName() and getType() have been removed from each
    of the individual directives, and the abstract modifier
    has been removed from corresponding methods in the
    base Directive class.
  
    There are now two fields in each of the directives that
    identify the name and type of the directive:
  
    DIRECTIVE_NAME and
    DIRECTIVE_TYPE
  
    The values of these fields are picked up via reflection
    when the directive is initialized in the Runtime. The
    list of directives is taken from directive.properties
    in the org/apache/velocity/runtime/defaults package.
  
  Revision  Changes    Path
  1.8       +51 -7     \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java  
  Index: Directive.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Directive.java	2000/11/05 23:25:41	1.7
  +++ Directive.java	2000/11/27 23:57:34	1.8
  @@ -63,20 +63,64 @@
   /**
    * Base class for all directives used in Velocity.
    */
  -public abstract class Directive implements Cloneable
  +public abstract class Directive implements DirectiveConstants,Cloneable
   {
  -    /** Block directive indicator */
  -    public static final int BLOCK = 1;
  +    /** The name of this directive */
  +    public String name;
       
  -    /** Line directive indicator */
  -    public static final int LINE = 2;
  +    /** The type of this directive: LINE or BLOCK */
  +    public int type;
       
  +    /**
  +     * Name of the directive that will be set
  +     * via reflection when this directive
  +     * is initialized in the Runtime. This
  +     * value must be set in each of the
  +     * directives.
  +     */
  +    public String DIRECTIVE_NAME = "Directive";
  +
  +    /**
  +     * Type of the directive that will be set
  +     * via reflection when this directive
  +     * is initialized in the Runtime. This
  +     * value must be set in each of the
  +     * directives.
  +     */
  +    public int DIRECTIVE_TYPE = LINE;
  +
       /** Return the name of this directive */
  -    public abstract String getName();
  +    public String getName()
  +    {
  +        return name;
  +    }        
       
       /** Get the directive type BLOCK/LINE */
  -    public abstract int getType();
  +    public int getType()
  +    {
  +        return type;
  +    }        
       
  +    /**
  +     * Set the name of this directive. This
  +     * is done in the Velocity Runtime
  +     * when the directive is initialized.
  +     */
  +    public void setName(String name)
  +    {
  +        this.name = name;
  +    }
  +    
  +    /**
  +     * Set the type of this directive. This
  +     * is done in the Velocity Runtime
  +     * when the directive is initialized.
  +     */
  +    public void setType(int type)
  +    {
  +        this.type = type;
  +    }
  +
       /**
        * How this directive is to be initialized.
        */
  
  
  
  1.25      +17 -18    \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java  
  Index: Foreach.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Foreach.java	2000/11/27 18:19:12	1.24
  +++ Foreach.java	2000/11/27 23:57:37	1.25
  @@ -85,11 +85,27 @@
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  - * @version $Id: Foreach.java,v 1.24 2000/11/27 18:19:12 jvanzyl Exp $
  + * @version $Id: Foreach.java,v 1.25 2000/11/27 23:57:37 jvanzyl Exp $
    */
   public class Foreach extends Directive
   {
       /**
  +     * Name of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be named
  +     * and initialized.
  +     */
  +    public String DIRECTIVE_NAME = "foreach";
  +    
  +    /**
  +     * Type of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be typed
  +     * and initialized.
  +     */
  +    public int DIRECTIVE_TYPE = BLOCK;
  +
  +    /**
        * Flag to indicate that the list object being used
        * in an array.
        */
  @@ -142,23 +158,6 @@
        */
       private String elementKey;
       
  -    /**
  -     * Return the name of this directive to
  -     * the Runtime.
  -     */
  -    public String getName() 
  -    { 
  -        return "foreach"; 
  -    }
  -    
  -    /**
  -     * Return the type of this directive.
  -     */
  -    public int getType() 
  -    { 
  -        return BLOCK; 
  -    }
  -
       public void init(Context context, Node node) throws Exception
       {
           Object sampleElement = null;
  
  
  
  1.5       +17 -11    \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java  
  Index: Include.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Include.java	2000/11/17 02:25:43	1.4
  +++ Include.java	2000/11/27 23:57:38	1.5
  @@ -93,22 +93,28 @@
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Include.java,v 1.4 2000/11/17 02:25:43 daveb Exp $
  + * @version $Id: Include.java,v 1.5 2000/11/27 23:57:38 jvanzyl Exp $
    */
   public class Include extends Directive
   {
  -    private static String ERRORMSG_START =  "include.output.errormsg.start";
  -    private static String ERRORMSG_END  = "include.output.errormsg.end";
  +    /**
  +     * Name of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be named
  +     * and initialized.
  +     */
  +    public String DIRECTIVE_NAME = "include";
       
  -    public String getName() 
  -    { 
  -        return "include"; 
  -    }
  +    /**
  +     * Type of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be typed
  +     * and initialized.
  +     */
  +    public int DIRECTIVE_TYPE = LINE;
       
  -    public int getType() 
  -    { 
  -        return LINE; 
  -    }
  +    private static String ERRORMSG_START =  "include.output.errormsg.start";
  +    private static String ERRORMSG_END  = "include.output.errormsg.end";
       
       /**
        *  iterates through the argument list and renders every
  
  
  
  1.2       +17 -4     \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Macro.java  
  Index: Macro.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Macro.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Macro.java	2000/11/19 23:26:35	1.1
  +++ Macro.java	2000/11/27 23:57:39	1.2
  @@ -70,7 +70,7 @@
    *  macro.  It is used inline in the parser when processing a directive.
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  - * @version $Id: Macro.java,v 1.1 2000/11/19 23:26:35 geirm Exp $
  + * @version $Id: Macro.java,v 1.2 2000/11/27 23:57:39 jvanzyl Exp $
    */
   
   package org.apache.velocity.runtime.directive;
  @@ -87,10 +87,23 @@
   
   public class Macro extends Directive
   {
  +    /**
  +     * Name of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be named
  +     * and initialized.
  +     */
  +    public String DIRECTIVE_NAME = "macro";
  +    
  +    /**
  +     * Type of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be typed
  +     * and initialized.
  +     */
  +    public int DIRECTIVE_TYPE = BLOCK;
  +    
       private static  boolean bDebug_ = false;
  -
  -    public String getName() { return "macro"; }        
  -    public int getType() { return BLOCK; }
   
       /**
        *   render() doesn't do anything in the final output rendering.
  
  
  
  1.4       +17 -11    \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java  
  Index: Parse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Parse.java	2000/11/17 02:26:51	1.3
  +++ Parse.java	2000/11/27 23:57:40	1.4
  @@ -83,24 +83,30 @@
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Parse.java,v 1.3 2000/11/17 02:26:51 daveb Exp $
  + * @version $Id: Parse.java,v 1.4 2000/11/27 23:57:40 jvanzyl Exp $
    */
   public class Parse extends Directive
   {
  +    /**
  +     * Name of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be named
  +     * and initialized.
  +     */
  +    
  +    public String DIRECTIVE_NAME = "parse";
  +    /**
  +     * Type of this directive. Reflection is used
  +     * in the Runtime to grab the value of this
  +     * field so that the directive can be typed
  +     * and initialized.
  +     */
  +    public int DIRECTIVE_TYPE = LINE;
  +    
       SimpleNode nodeTree_ = null;
       int iParseDepth_ = 1;
       boolean bReady_ = false;
   
  -    public String getName() 
  -    { 
  -        return "parse"; 
  -    }
  -    
  -    public int getType() 
  -    { 
  -        return LINE; 
  -    }
  -    
       /**
        *   Initializes the trees
        */
  
  
  
  1.7       +2 -2      \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java \
  Index: VelocimacroProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- VelocimacroProxy.java	2000/11/26 19:38:27	1.6
  +++ VelocimacroProxy.java	2000/11/27 23:57:45	1.7
  @@ -58,7 +58,7 @@
    *   a proxy Directive-derived object to fit with the current directive system
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  - * @version $Id: VelocimacroProxy.java,v 1.6 2000/11/26 19:38:27 geirm Exp $ 
  + * @version $Id: VelocimacroProxy.java,v 1.7 2000/11/27 23:57:45 jvanzyl Exp $ 
    */
   
   package org.apache.velocity.runtime.directive;
  @@ -80,7 +80,7 @@
   import org.apache.velocity.runtime.parser.node.SimpleNode;
   import org.apache.velocity.util.StringUtils;
   
  -public class VelocimacroProxy extends  Directive
  +public class VelocimacroProxy extends Directive
   {
       private String strMacroName_ = "";
       private String strMacro_ = "";
  
  
  
  1.1                  \
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/DirectiveConstants.java
  
  Index: DirectiveConstants.java
  ===================================================================
  package org.apache.velocity.runtime.directive;
  
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  /**
   * Base class for all directives used in Velocity.
   */
  public interface DirectiveConstants
  {
      /** Block directive indicator */
      public static final int BLOCK = 1;
      
      /** Line directive indicator */
      public static final int LINE = 2;
  
      /**
       * Name of the field that contains the
       * name for this directive. It will be grabbed
       * via reflection and set when the directive
       * is initialized in the Velocity Runtime.
       */
      public static final String NAME_FIELD = "DIRECTIVE_NAME";
      
      /**
       * Type of the field that contains the
       * name for this directive. It will be grabbed
       * via reflection and set when the directive
       * is initialized in the Velocity Runtime.
       */
      public static final String TYPE_FIELD = "DIRECTIVE_TYPE";
  }        
  
  
  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic