You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2002/02/28 06:24:00 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime VelocimacroManager.java

geirm       02/02/27 21:24:00

  Modified:    src/java/org/apache/velocity/runtime VelocimacroManager.java
  Log:
  be explicit with the namespace dump on a parse, and some reformatting
  
  Revision  Changes    Path
  1.16      +53 -53    jakarta-velocity/src/java/org/apache/velocity/runtime/VelocimacroManager.java
  
  Index: VelocimacroManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/VelocimacroManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- VelocimacroManager.java	22 Oct 2001 11:47:06 -0000	1.15
  +++ VelocimacroManager.java	28 Feb 2002 05:24:00 -0000	1.16
  @@ -3,7 +3,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -82,7 +82,7 @@
    *
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:JFernandez@viquity.com">Jose Alberto Fernandez</a>
  - * @version $Id: VelocimacroManager.java,v 1.15 2001/10/22 11:47:06 geirm Exp $ 
  + * @version $Id: VelocimacroManager.java,v 1.16 2002/02/28 05:24:00 geirm Exp $ 
    */
   public class VelocimacroManager
   {
  @@ -139,9 +139,9 @@
            
           boolean isLib = true;
           
  -        if ( registerFromLib)
  +        if (registerFromLib)
           {
  -           libraryMap.put( namespace, namespace );
  +           libraryMap.put(namespace, namespace);
           }
           else
           {
  @@ -153,18 +153,18 @@
                *  global
                */
            
  -            isLib = libraryMap.containsKey( namespace);
  +            isLib = libraryMap.containsKey(namespace);
           }
                  
  -        if ( !isLib && usingNamespaces( namespace ) )
  +        if ( !isLib && usingNamespaces(namespace) )
           {
               /*
                *  first, do we have a namespace hash already for this namespace?
                *  if not, add it to the namespaces, and add the VM
                */
   
  -            Hashtable local = getNamespace( namespace, true );
  -            local.put( (String) vmName, me );
  +            Hashtable local = getNamespace(namespace, true);
  +            local.put((String) vmName, me);
            
               return true;
           }
  @@ -175,18 +175,18 @@
                *  already have it to preserve some of the autoload information
                */
   
  -            MacroEntry exist = (MacroEntry) (getNamespace( GLOBAL_NAMESPACE )).get( vmName );
  +            MacroEntry exist = (MacroEntry) getNamespace(GLOBAL_NAMESPACE).get(vmName);
               
               if (exist != null)
               {
  -                me.setFromLibrary( exist.getFromLibrary());
  +                me.setFromLibrary(exist.getFromLibrary());
               }
   
               /*
                *  now add it
                */
   
  -            (getNamespace( GLOBAL_NAMESPACE )).put( vmName, me );
  +            getNamespace(GLOBAL_NAMESPACE).put(vmName, me);
   
               return true;
           }
  @@ -196,24 +196,24 @@
        * gets a new living VelocimacroProxy object by the 
        * name / source template duple
        */
  -    public VelocimacroProxy get( String vmName, String namespace )
  +    public VelocimacroProxy get(String vmName, String namespace)
       {
    
  -        if ( usingNamespaces( namespace ) )
  +        if (usingNamespaces(namespace))
           {
  -            Hashtable local =  getNamespace( namespace, false );
  +            Hashtable local =  getNamespace(namespace, false);
            
               /*
                *  if we have macros defined for this template
                */
   
  -            if ( local != null)
  +            if (local != null)
               {
  -                MacroEntry me = (MacroEntry) local.get( vmName );
  +                MacroEntry me = (MacroEntry) local.get(vmName);
                  
                   if (me != null)
                   {
  -                    return me.createVelocimacro( namespace );
  +                    return me.createVelocimacro(namespace);
                   }
               }
           }
  @@ -223,11 +223,11 @@
            * if it's in the global namespace
            */
           
  -        MacroEntry me = (MacroEntry) (getNamespace( GLOBAL_NAMESPACE )).get( vmName );
  +        MacroEntry me = (MacroEntry) getNamespace(GLOBAL_NAMESPACE).get( vmName );
           
           if (me != null)
           {
  -            return me.createVelocimacro( namespace );
  +            return me.createVelocimacro(namespace);
           }
    
           return null;
  @@ -241,15 +241,15 @@
        * @param namespace namespace to dump
        * @return boolean representing success
        */
  -    public boolean dumpNamespace( String namespace )
  +    public boolean dumpNamespace(String namespace)
       {
  -        synchronized( this )
  +        synchronized(this)
           {
  -            if (usingNamespaces( namespace ) )
  +            if (usingNamespaces(namespace))
               {
  -                Hashtable h = (Hashtable) namespaceHash.remove( namespace );
  +                Hashtable h = (Hashtable) namespaceHash.remove(namespace);
   
  -                if ( h == null )
  +                if (h == null)
                       return false;
               
                   h.clear();
  @@ -266,17 +266,17 @@
        *  usage indep of properties.  That way, for example, at startup the 
        *  library files are loaded into global namespace
        */
  -    public void setNamespaceUsage( boolean b )
  +    public void setNamespaceUsage(boolean b)
       {
           namespacesOn = b;
       }
   
  -    public void setRegisterFromLib( boolean b )
  +    public void setRegisterFromLib(boolean b)
       {
           registerFromLib = b;
       }
   
  -    public void setTemplateLocalInlineVM( boolean b )
  +    public void setTemplateLocalInlineVM(boolean b)
       {
           inlineLocalMode = b;
       }
  @@ -288,9 +288,9 @@
        *  @param namespace  name of the namespace :)
        *  @return namespace Hashtable of VMs or null if doesn't exist
        */
  -    private Hashtable getNamespace( String namespace )
  +    private Hashtable getNamespace(String namespace)
       {
  -        return getNamespace( namespace, false );
  +        return getNamespace(namespace, false);
       }
   
       /**
  @@ -301,13 +301,13 @@
        *  @param addIfNew  flag to add a new namespace if it doesn't exist
        *  @return namespace Hashtable of VMs or null if doesn't exist
        */
  -    private Hashtable getNamespace( String namespace, boolean addIfNew )
  +    private Hashtable getNamespace(String namespace, boolean addIfNew)
       {
  -        Hashtable h = (Hashtable)  namespaceHash.get( namespace );
  +        Hashtable h = (Hashtable) namespaceHash.get(namespace);
   
           if (h == null && addIfNew)
           {
  -            h = addNamespace( namespace );
  +            h = addNamespace(namespace);
           }
     
           return h;
  @@ -319,12 +319,12 @@
        *  @param namespace name of namespace to add
        *  @return Hash added to namespaces, ready for use
        */
  -    private Hashtable addNamespace( String namespace )
  +    private Hashtable addNamespace(String namespace)
       {
           Hashtable h = new Hashtable();
           Object oh;
   
  -        if ((oh = namespaceHash.put( namespace, h )) != null)
  +        if ((oh = namespaceHash.put(namespace, h)) != null)
           {
             /*
              * There was already an entry on the table, restore it!
  @@ -333,7 +333,7 @@
              * But just in case, this way of testing for it is much
              * more efficient than testing before hand using get().
              */
  -          namespaceHash.put( namespace, oh );
  +          namespaceHash.put(namespace, oh);
             /*
              * Should't we be returning the old entry (oh)?
              * The previous code was just returning null in this case.
  @@ -350,13 +350,13 @@
        *  @param namespace currently ignored
        *  @return true if using namespaces, false if not
        */
  -    private boolean usingNamespaces( String namespace )
  +    private boolean usingNamespaces(String namespace)
       {
           /*
            *  if the big switch turns of namespaces, then ignore the rules
            */
   
  -        if ( !namespacesOn )
  +        if (!namespacesOn)
           {
               return false;
           }
  @@ -365,7 +365,7 @@
            *  currently, we only support the local template namespace idea
            */
   
  -        if ( inlineLocalMode )
  +        if (inlineLocalMode)
           {
               return true;
           }
  @@ -373,11 +373,11 @@
           return false;
       }
   
  -    public String getLibraryName( String vmName, String namespace )
  +    public String getLibraryName(String vmName, String namespace)
       {
  -        if ( usingNamespaces( namespace ) )
  +        if (usingNamespaces(namespace))
           {
  -            Hashtable local =  getNamespace( namespace, false );
  +            Hashtable local =  getNamespace(namespace, false);
            
               /*
                *  if we have this macro defined in this namespace, then
  @@ -387,7 +387,7 @@
   
               if ( local != null)
               {
  -                MacroEntry me = (MacroEntry) local.get( vmName );
  +                MacroEntry me = (MacroEntry) local.get(vmName);
                  
                   if (me != null)
                   {
  @@ -435,7 +435,7 @@
               this.manager = vmm;
           }
   
  -        public void setFromLibrary( boolean b )
  +        public void setFromLibrary(boolean b)
           {
               fromLibrary = b;
           }
  @@ -455,14 +455,14 @@
               return sourcetemplate;
           }
   
  -        VelocimacroProxy createVelocimacro( String namespace )
  +        VelocimacroProxy createVelocimacro(String namespace)
           {
               VelocimacroProxy vp = new VelocimacroProxy();
  -            vp.setName( this.macroname );
  -            vp.setArgArray(  this.argarray ); 
  -            vp.setMacrobody( this.macrobody );
  -            vp.setNodeTree( this.nodeTree);
  -            vp.setNamespace( namespace );
  +            vp.setName(this.macroname);
  +            vp.setArgArray(this.argarray);
  +            vp.setMacrobody(this.macrobody);
  +            vp.setNodeTree(this.nodeTree);
  +            vp.setNamespace(namespace);
               return vp;
           }
   
  @@ -473,16 +473,16 @@
                */
               
               if( nodeTree == null)
  -                parseTree( ica );
  +                parseTree(ica);
           }
   
  -        void parseTree( InternalContextAdapter ica)
  +        void parseTree(InternalContextAdapter ica)
           {
               try 
               {
  -                BufferedReader br = new BufferedReader( new StringReader( macrobody ) );
  +                BufferedReader br = new BufferedReader(new StringReader(macrobody));
    
  -                nodeTree = rsvc.parse( br, "VM:" + macroname );
  +                nodeTree = rsvc.parse(br, "VM:" + macroname, true);
                   nodeTree.init(ica,null);
               } 
               catch ( Exception e ) 
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>