incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cframp...@apache.org
Subject svn commit: r1343781 [4/17] - in /incubator/flex/trunk/modules: ./ thirdparty/velocity/ thirdparty/velocity/build/ thirdparty/velocity/build/lib/ thirdparty/velocity/build/xsl/ thirdparty/velocity/src/java/org/apache/velocity/anakia/ thirdparty/velocit...
Date Tue, 29 May 2012 15:35:15 GMT
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java Tue May 29 15:35:01 2012
@@ -0,0 +1,91 @@
+package org.apache.velocity.context;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.velocity.util.introspection.IntrospectionCacheData;
+
+import org.apache.velocity.runtime.resource.Resource;
+
+/**
+ *  interface to encapsulate the 'stuff' for internal operation of velocity.  
+ *  We use the context as a thread-safe storage : we take advantage of the
+ *  fact that it's a visitor  of sorts  to all nodes (that matter) of the 
+ *  AST during init() and render().
+ *
+ *  Currently, it carries the template name for namespace
+ *  support, as well as node-local context data introspection caching.
+ *
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
+ *  @version $Id: InternalHousekeepingContext.java,v 1.6.12.1 2004/03/03 23:22:54 geirm Exp $
+ */
+interface InternalHousekeepingContext
+{
+    /**
+     *  set the current template name on top of stack
+     *
+     *  @param s current template name
+     */
+    void pushCurrentTemplateName( String s );
+
+    /**
+     *  remove the current template name from stack
+     */
+    void popCurrentTemplateName();
+    
+    /**
+     *  get the current template name
+     *
+     *  @return String current template name
+     */
+    String getCurrentTemplateName();
+
+    /**
+     *  Returns the template name stack in form of an array.
+     *
+     *  @return Object[] with the template name stack contents.
+     */
+    Object[] getTemplateNameStack();
+
+    /**
+     *  returns an IntrospectionCache Data (@see IntrospectionCacheData)
+     *  object if exists for the key
+     *
+     *  @param key  key to find in cache
+     *  @return cache object
+     */
+    IntrospectionCacheData icacheGet( Object key );
+    
+    /**
+     *  places an IntrospectionCache Data (@see IntrospectionCacheData)
+     *  element in the cache for specified key
+     *
+     *  @param key  key 
+     *  @param o  IntrospectionCacheData object to place in cache
+     */
+    void icachePut( Object key, IntrospectionCacheData o );
+
+    /**
+     *  temporary fix to enable #include() to figure out
+     *  current encoding.
+     *
+     */
+    Resource getCurrentResource();
+    void setCurrentResource( Resource r );
+    
+    
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalWrapperContext.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalWrapperContext.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalWrapperContext.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalWrapperContext.java Tue May 29 15:35:01 2012
@@ -0,0 +1,33 @@
+package org.apache.velocity.context;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  interface for internal context wrapping functionality
+ *  
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @version $Id: InternalWrapperContext.java,v 1.2.14.1 2004/03/03 23:22:54 geirm Exp $ 
+ */
+public interface InternalWrapperContext
+{
+    /** returns the wrapped user context */
+    public Context getInternalUserContext();
+
+    /** returns the base full context impl */
+    public InternalContextAdapter getBaseContext();
+    
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalWrapperContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/VMContext.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/VMContext.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/VMContext.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/VMContext.java Tue May 29 15:35:01 2012
@@ -0,0 +1,293 @@
+package org.apache.velocity.context;
+
+/*
+ * Copyright 2000,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.directive.VMProxyArg;
+import org.apache.velocity.util.introspection.IntrospectionCacheData;
+import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.app.event.EventCartridge;
+
+/**
+ *  This is a special, internal-use-only context implementation to be
+ *  used for the new Velocimacro implementation.
+ *
+ *  The main distinguishing feature is the management of the VMProxyArg objects
+ *  in the put() and get() methods.
+ *
+ *  Further, this context also supports the 'VM local context' mode, where
+ *  any get() or put() of references that aren't args to the VM are considered
+ *  local to the vm, protecting the global context.
+ *  
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @version $Id: VMContext.java,v 1.9.10.1 2004/03/03 23:22:54 geirm Exp $ 
+ */
+public class VMContext implements InternalContextAdapter
+{
+    /** container for our VMProxy Objects */
+    HashMap vmproxyhash = new HashMap();
+
+    /** container for any local or constant VMProxy items */
+    HashMap localcontext = new HashMap();
+
+    /** the base context store.  This is the 'global' context */
+    InternalContextAdapter innerContext = null;
+
+    /** context that we are wrapping */
+    InternalContextAdapter wrappedContext = null;
+
+    /** support for local context scope feature, where all references are local */
+    private  boolean localcontextscope = false;
+
+     /**
+     *  CTOR, wraps an ICA
+     */
+    public VMContext( InternalContextAdapter  inner, RuntimeServices rsvc )
+    {
+        localcontextscope = rsvc.getBoolean( RuntimeConstants.VM_CONTEXT_LOCALSCOPE, false );
+
+        wrappedContext = inner;
+        innerContext = inner.getBaseContext();
+    }
+
+    /**
+     *  return the inner / user context
+     */
+    public Context getInternalUserContext()
+    {
+        return innerContext.getInternalUserContext();
+    }
+
+    public InternalContextAdapter getBaseContext()
+    {
+        return innerContext.getBaseContext();
+    }
+
+    /**
+     *  Used to put VMProxyArgs into this context.  It separates
+     *  the VMProxyArgs into constant and non-constant types
+     *  pulling out the value of the constant types so they can
+     *  be modified w/o damaging the VMProxyArg, and leaving the
+     *  dynamic ones, as they modify context rather than their own
+     *  state
+     *  @param  vmpa VMProxyArg to add 
+     */
+    public void addVMProxyArg(  VMProxyArg vmpa )
+    {
+        /*
+         *  ask if it's a constant : if so, get the value and put into the
+         *  local context, otherwise, put the vmpa in our vmproxyhash
+         */
+
+        String key = vmpa.getContextReference();
+
+        if ( vmpa.isConstant() )
+        {
+            localcontext.put( key, vmpa.getObject( wrappedContext ) );
+        }
+        else
+        {
+            vmproxyhash.put( key, vmpa );
+        }
+    }
+
+    /**
+     *  Impl of the Context.put() method. 
+     *
+     *  @param key name of item to set
+     *  @param value object to set to key
+     *  @return old stored object
+     */
+    public Object put(String key, Object value)
+    {
+        /*
+         *  first see if this is a vmpa
+         */
+
+        VMProxyArg vmpa = (VMProxyArg) vmproxyhash.get( key );
+
+        if( vmpa != null)
+        {
+            return vmpa.setObject( wrappedContext, value );
+        }
+        else
+        {
+            if(localcontextscope)
+            {
+                /*
+                 *  if we have localcontextscope mode, then just 
+                 *  put in the local context
+                 */
+
+                return localcontext.put( key, value );
+            }
+            else
+            {
+                /*
+                 *  ok, how about the local context?
+                 */
+  
+                if (localcontext.containsKey( key ))
+                {
+                    return localcontext.put( key, value);
+                }
+                else
+                {
+                    /*
+                     * otherwise, let them push it into the 'global' context
+                     */
+
+                    return innerContext.put( key, value );   
+                }
+            }
+        }
+    }
+
+    /**
+     *  Impl of the Context.gut() method. 
+     *
+     *  @param key name of item to get
+     *  @return  stored object or null
+     */
+    public Object get( String key )
+    {
+        /*
+         * first, see if it's a VMPA
+         */
+        
+        Object o = null;
+        
+        VMProxyArg vmpa = (VMProxyArg) vmproxyhash.get( key );
+        
+        if( vmpa != null )
+        {
+            o = vmpa.getObject( wrappedContext );
+        }
+        else
+        {
+            if(localcontextscope)
+            {
+                /*
+                 * if we have localcontextscope mode, then just 
+                 * put in the local context
+                 */
+
+                o =  localcontext.get( key );
+            }
+            else
+            {
+                /*
+                 *  try the local context
+                 */
+            
+                o = localcontext.get( key );
+                
+                if ( o == null)
+                {
+                    /*
+                     * last chance
+                     */
+
+                    o = innerContext.get( key );
+                }
+            }
+        }
+       
+        return o;
+    }
+ 
+    /**
+     *  not yet impl
+     */
+    public boolean containsKey(Object key)
+    {
+        return false;
+    }
+  
+    /**
+     *  impl badly
+     */
+    public Object[] getKeys()
+    {
+        return vmproxyhash.keySet().toArray();
+    }
+
+    /**
+     *  impl badly
+     */
+    public Object remove(Object key)
+    {
+        return vmproxyhash.remove( key );
+    }
+
+    public void pushCurrentTemplateName( String s )
+    {
+        innerContext.pushCurrentTemplateName( s );
+    }
+
+    public void popCurrentTemplateName()
+    {
+        innerContext.popCurrentTemplateName();
+    }
+   
+    public String getCurrentTemplateName()
+    {
+        return innerContext.getCurrentTemplateName();
+    }
+
+    public Object[] getTemplateNameStack()
+    {
+        return innerContext.getTemplateNameStack();
+    }
+
+    public IntrospectionCacheData icacheGet( Object key )
+    {
+        return innerContext.icacheGet( key );
+    }
+   
+    public void icachePut( Object key, IntrospectionCacheData o )
+    {
+        innerContext.icachePut( key, o );
+    }
+
+    public EventCartridge attachEventCartridge( EventCartridge ec )
+    {
+        return innerContext.attachEventCartridge( ec );
+    }
+
+    public EventCartridge getEventCartridge()
+    {
+        return innerContext.getEventCartridge();
+    }
+
+
+    public void setCurrentResource( Resource r )
+    {
+        innerContext.setCurrentResource( r );
+    }
+
+    public Resource getCurrentResource()
+    {
+        return innerContext.getCurrentResource();
+    }
+}
+
+
+

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/VMContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/convert/WebMacro.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/convert/WebMacro.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/convert/WebMacro.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/convert/WebMacro.java Tue May 29 15:35:01 2012
@@ -0,0 +1,296 @@
+package org.apache.velocity.convert;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.oro.text.perl.Perl5Util;
+import org.apache.velocity.util.StringUtils;
+import org.apache.tools.ant.DirectoryScanner;
+
+/**
+ * This class will convert a WebMacro template to
+ * a Velocity template. Uses the ORO Regexp package to do the 
+ * rewrites. Note, it isn't 100% perfect, but will definitely get
+ * you about 99.99% of the way to a converted system. Please
+ * see the website documentation for more information on how to use
+ * this class.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @version $Id: WebMacro.java,v 1.20.8.1 2004/03/03 23:22:54 geirm Exp $ 
+ */
+public class WebMacro
+{
+    protected static final String VM_EXT = ".vm";
+    protected static final String WM_EXT = ".wm";
+
+    /**
+     * The regexes to use for line by line substition. The regexes
+     * come in pairs. The first is the string to match, the second is
+     * the substitution to make.
+     */
+    protected static String[] perLineREs =
+    {
+        // Make #if directive match the Velocity directive style.
+        "#if\\s*[(]\\s*(.*\\S)\\s*[)]\\s*(#begin|{)[ \\t]?",
+        "#if( $1 )",
+
+        // Remove the WM #end #else #begin usage.
+        "[ \\t]?(#end|})[ \\t]*\n(\\s*)#else\\s*(#begin|{)[ \\t]?(\\w)",
+        "$2#else#**#$4", // avoid touching followup word with embedded comment
+        "[ \\t]?(#end|})[ \\t]*\n(\\s*)#else\\s*(#begin|{)[ \\t]?",
+        "$2#else",
+        "(#end|})(\\s*#else)\\s*(#begin|{)[ \\t]?",
+        "$1\n$2",
+
+        // Convert WM style #foreach to Velocity directive style.
+        "#foreach\\s+(\\$\\w+)\\s+in\\s+(\\$[^\\s#]+)\\s*(#begin|{)[ \\t]?",
+        "#foreach( $1 in $2 )",
+
+        // Convert WM style #set to Velocity directive style.
+        "#set\\s+(\\$[^\\s=]+)\\s*=\\s*([\\S \\t]+)",
+        "#set( $1 = $2 )",
+        "(##[# \\t\\w]*)\\)", // fix comments included at end of line
+        ")$1",
+
+        // Convert WM style #parse to Velocity directive style.
+        "#parse\\s+([^\\s#]+)[ \\t]?",
+        "#parse( $1 )",
+
+        // Convert WM style #include to Velocity directive style.
+        "#include\\s+([^\\s#]+)[ \\t]?",
+        "#include( $1 )",
+
+        // Convert WM formal reference to VTL syntax.
+        "\\$\\(([^\\)]+)\\)",
+        "${$1}",
+        "\\${([^}\\(]+)\\(([^}]+)}\\)", // fix encapsulated brakets: {(})
+        "${$1($2)}",
+
+        // Velocity currently does not permit leading underscore.
+        "\\$_",
+        "$l_",
+        "\\${(_[^}]+)}", // within a formal reference
+        "${l$1}",
+
+        // Eat semi-colons in (converted) VTL #set directives.
+        "(#set\\s*\\([^;]+);(\\s*\\))",
+        "$1$2",
+
+        // Convert explicitly terminated WM statements to VTL syntax.
+        "(^|[^\\\\])\\$(\\w[^=\n;'\"]*);",
+        "$1${$2}",
+
+        // Change extensions when seen.
+        "\\.wm",
+        ".vm"
+    };
+    
+    /**
+     * Iterate through the set of find/replace regexes
+     * that will convert a given WM template to a VM template
+     */
+    public void convert(String target)
+    {
+        File file = new File(target);
+        
+        if (!file.exists())
+        {
+            System.err.println
+                ("The specified template or directory does not exist");
+            System.exit(1);
+        }
+        
+        if (file.isDirectory())
+        {
+            String basedir = file.getAbsolutePath();
+            String newBasedir = basedir + VM_EXT;
+
+            DirectoryScanner ds = new DirectoryScanner();
+            ds.setBasedir(basedir);
+            ds.addDefaultExcludes();
+            ds.scan();
+            String[] files = ds.getIncludedFiles();
+            
+            for (int i = 0; i < files.length; i++)
+            {
+                writeTemplate(files[i], basedir, newBasedir);
+            }
+        }
+        else
+        {
+            writeTemplate(file.getAbsolutePath(), "", "");
+        }
+    }
+
+    /**
+     * Write out the converted template to the given named file
+     * and base directory.
+     */
+    private boolean writeTemplate(String file, String basedir,
+                                  String newBasedir)
+    {
+        if (file.indexOf(WM_EXT) < 0)
+        {
+            return false;
+        }
+    
+        System.out.println("Converting " + file + "...");
+        
+        String template;
+        String templateDir;
+        String newTemplate;
+        File outputDirectory;
+        
+        if (basedir.length() == 0)
+        {
+            template = file;
+            templateDir = "";
+            newTemplate = convertName(file);
+        }            
+        else
+        {
+            template = basedir + File.separator + file;
+            templateDir = newBasedir + extractPath(file);
+
+            outputDirectory = new File(templateDir);
+                
+            if (! outputDirectory.exists())
+            {
+                outputDirectory.mkdirs();
+            }
+                
+            newTemplate = newBasedir + File.separator + convertName(file);
+        }            
+        
+        String convertedTemplate = convertTemplate(template);
+                    
+        try
+        {
+            FileWriter fw = new FileWriter(newTemplate);
+            fw.write(convertedTemplate);
+            fw.close();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    
+        return true;
+    }
+
+    /**
+     * Gets the path segment of the full path to a file (i.e. one
+     * which originally included the file name).
+     */
+    private final String extractPath(String file)
+    {
+        int lastSepPos = file.lastIndexOf(File.separator);
+        return (lastSepPos == -1 ? "" :
+                File.separator + file.substring(0, lastSepPos));
+    }
+
+    /**
+     * Simple extension conversion of .wm to .vm
+     */
+    private String convertName(String name)
+    {
+        if (name.indexOf(WM_EXT) > 0)
+        {
+            return name.substring(0, name.indexOf(WM_EXT)) + VM_EXT;
+        }
+        else
+        {
+            return name;
+        }
+    }
+
+    /**
+     * How to use this little puppy :-)
+     */
+    private static final void usage()
+    {
+        System.err.println("Usage: convert-wm <template.wm | directory>");
+        System.exit(1);
+    }
+
+    /**
+     * Apply find/replace regexes to our WM template
+     */
+    public String convertTemplate(String template)
+    {
+        String contents = StringUtils.fileContentsToString(template);
+
+        // Overcome Velocity 0.71 limitation.
+        // HELP: Is this still necessary?
+        if (!contents.endsWith("\n"))
+        {
+            contents += "\n";
+        }
+
+        // Convert most markup.
+        Perl5Util perl = new Perl5Util();
+        for (int i = 0; i < perLineREs.length; i += 2)
+        {
+            contents = perl.substitute(makeSubstRE(i), contents);
+        }
+
+        // Convert closing curlies.
+        if (perl.match("m/javascript/i", contents))
+        {
+            // ASSUMPTION: JavaScript is indented, WM is not.
+            contents = perl.substitute("s/\n}/\n#end/g", contents);
+        }
+        else
+        {
+            contents = perl.substitute("s/(\n\\s*)}/$1#end/g", contents);
+            contents = perl.substitute("s/#end\\s*\n\\s*#else/#else/g",
+                                       contents);
+        }
+
+        return contents;
+    }
+
+    /**
+     * Makes a Perl 5 regular expression for use by ORO.
+     */
+    private final String makeSubstRE(int i)
+    {
+        return ("s/" + perLineREs[i] + '/' + perLineREs[i + 1] + "/g");
+    }
+
+    /**
+     * Main hook for the conversion process.
+     */
+    public static void main(String[] args)
+    {
+        if (args.length > 0)
+        {
+            for (int x=0; x < args.length; x++)
+            {
+                WebMacro converter = new WebMacro();
+                converter.convert(args[x]);
+            }
+        }
+        else
+        {
+            usage();
+        }
+    }
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/convert/WebMacro.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/MethodInvocationException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/MethodInvocationException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/MethodInvocationException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/MethodInvocationException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,93 @@
+package org.apache.velocity.exception;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  Application-level exception thrown when a reference method is 
+ *  invoked and an exception is thrown.
+ *  <br>
+ *  When this exception is thrown, a best effort will be made to have
+ *  useful information in the exception's message.  For complete 
+ *  information, consult the runtime log.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: MethodInvocationException.java,v 1.2.14.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public class MethodInvocationException extends VelocityException
+{
+    private String methodName = "";
+    private String referenceName = "";
+    private Throwable wrapped = null;
+
+    /**
+     *  CTOR - wraps the passed in exception for
+     *  examination later
+     *
+     *  @param message 
+     *  @param e Throwable that we are wrapping
+     *  @param methodName name of method that threw the exception
+     */
+    public MethodInvocationException( String message, Throwable e, String methodName )
+    {
+        super(message);
+        this.wrapped = e;
+        this.methodName = methodName;
+    }       
+
+    /**
+     *  Returns the name of the method that threw the
+     *  exception
+     *
+     *  @return String name of method
+     */
+    public String getMethodName()
+    {
+        return methodName;
+    }
+
+    /**
+     *  returns the wrapped Throwable that caused this
+     *  MethodInvocationException to be thrown
+     *  
+     *  @return Throwable thrown by method invocation
+     */
+    public Throwable getWrappedThrowable()
+    {
+        return wrapped;
+    }
+
+    /**
+     *  Sets the reference name that threw this exception
+     *
+     *  @param reference name of reference
+     */
+    public void setReferenceName( String ref )
+    {
+        referenceName = ref;
+    }
+
+    /**
+     *  Retrieves the name of the reference that caused the 
+     *  exception
+     *
+     *  @return name of reference
+     */
+    public String getReferenceName()
+    {
+        return referenceName;
+    }
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/MethodInvocationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ParseErrorException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ParseErrorException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ParseErrorException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ParseErrorException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,36 @@
+package org.apache.velocity.exception;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  Application-level exception thrown when a resource of any type
+ *  has a syntax or other error which prevents it from being parsed.
+ *  <br>
+ *  When this resource is thrown, a best effort will be made to have
+ *  useful information in the exception's message.  For complete 
+ *  information, consult the runtime log.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ParseErrorException.java,v 1.2.14.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public class ParseErrorException extends VelocityException
+{
+    public ParseErrorException(String exceptionMessage )
+    {
+        super(exceptionMessage);
+    }       
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ParseErrorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ResourceNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ResourceNotFoundException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ResourceNotFoundException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ResourceNotFoundException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,37 @@
+package org.apache.velocity.exception;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  Application-level exception thrown when a resource of any type
+ *  isn't found by the Velocity engine.
+ *  <br>
+ *  When this exception is thrown, a best effort will be made to have
+ *  useful information in the exception's message.  For complete 
+ *  information, consult the runtime log.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @version $Id: ResourceNotFoundException.java,v 1.3.8.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public class ResourceNotFoundException extends VelocityException
+{
+    public ResourceNotFoundException(String exceptionMessage)
+    {
+        super(exceptionMessage);
+    }
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/ResourceNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/VelocityException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/VelocityException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/VelocityException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/VelocityException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,32 @@
+package org.apache.velocity.exception;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  Base class for Velocity exceptions thrown to the 
+ *  application layer.
+ *
+ * @author <a href="mailto:kdowney@amberarcher.com">Kyle F. Downey</a>
+ * @version $Id: VelocityException.java,v 1.2.14.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public class VelocityException extends Exception
+{
+    public VelocityException(String exceptionMessage )
+    {
+        super(exceptionMessage);
+    }       
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/exception/VelocityException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/io/VelocityWriter.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/io/VelocityWriter.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/io/VelocityWriter.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/io/VelocityWriter.java Tue May 29 15:35:01 2012
@@ -0,0 +1,332 @@
+package org.apache.velocity.io;
+
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Implementation of a fast Writer. It was originally taken from JspWriter
+ * and modified to have less syncronization going on.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author Anil K. Vijendran
+ * @version $Id: VelocityWriter.java,v 1.8.4.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public final class VelocityWriter extends Writer
+{
+    /**
+     * constant indicating that the Writer is not buffering output
+     */
+    public static final int	NO_BUFFER = 0;
+
+    /**
+     * constant indicating that the Writer is buffered and is using the 
+     * implementation default buffer size
+     */
+    public static final int	DEFAULT_BUFFER = -1;
+
+    /**
+     * constant indicating that the Writer is buffered and is unbounded; 
+     * this is used in BodyContent
+     */
+    public static final int	UNBOUNDED_BUFFER = -2;
+
+    protected int     bufferSize;
+    protected boolean autoFlush;
+
+    private Writer writer;
+    
+    private char cb[];
+    private int nextChar;
+
+    private static int defaultCharBufferSize = 8 * 1024;
+
+    private boolean flushed = false;
+
+    /**
+     * Create a buffered character-output stream that uses a default-sized
+     * output buffer.
+     *
+     * @param  response  A Servlet Response
+     */
+    public VelocityWriter(Writer writer)
+    {
+        this(writer, defaultCharBufferSize, true);
+    }
+
+    /**
+     * private constructor.
+     */
+    private VelocityWriter(int bufferSize, boolean autoFlush)
+    {
+        this.bufferSize = bufferSize;
+        this.autoFlush  = autoFlush;
+    }
+
+    /**
+     * This method returns the size of the buffer used by the JspWriter.
+     *
+     * @return the size of the buffer in bytes, or 0 is unbuffered.
+     */
+    public int getBufferSize() { return bufferSize; }
+
+    /**
+     * This method indicates whether the JspWriter is autoFlushing.
+     *
+     * @return if this JspWriter is auto flushing or throwing IOExceptions on 
+     *         buffer overflow conditions
+     */
+    public boolean isAutoFlush() { return autoFlush; }
+
+    /**
+     * Create a new buffered character-output stream that uses an output
+     * buffer of the given size.
+     *
+     * @param  response A Servlet Response
+     * @param  sz   	Output-buffer size, a positive integer
+     *
+     * @exception  IllegalArgumentException  If sz is <= 0
+     */
+    public VelocityWriter(Writer writer, int sz, boolean autoFlush)
+    {
+        this(sz, autoFlush);
+        if (sz < 0)
+            throw new IllegalArgumentException("Buffer size <= 0");
+        this.writer = writer;
+        cb = sz == 0 ? null : new char[sz];
+        nextChar = 0;
+    }
+
+    private final void init( Writer writer, int sz, boolean autoFlush )
+    {
+        this.writer= writer;
+        if( sz > 0 && ( cb == null || sz > cb.length ) )
+            cb=new char[sz];
+        nextChar = 0;
+        this.autoFlush=autoFlush;
+        this.bufferSize=sz;
+    }
+
+    /**
+     * Flush the output buffer to the underlying character stream, without
+     * flushing the stream itself.  This method is non-private only so that it
+     * may be invoked by PrintStream.
+     */
+    private final void flushBuffer() throws IOException
+    {
+        if (bufferSize == 0)
+            return;
+        flushed = true;
+        if (nextChar == 0)
+            return;
+        writer.write(cb, 0, nextChar);
+        nextChar = 0;
+    }
+
+    /**
+     * Discard the output buffer.
+     */
+    public final void clear()
+    {
+        nextChar = 0;
+    }
+
+    private final void bufferOverflow() throws IOException
+    {
+        throw new IOException("overflow");
+    }
+
+    /**
+     * Flush the stream.
+     *
+     */
+    public final void flush()  throws IOException
+    {
+        flushBuffer();
+        if (writer != null)
+        {
+            writer.flush();
+        }
+    }
+
+    /**
+     * Close the stream.
+     *
+     */
+    public final void close() throws IOException {
+        if (writer == null)
+            return;
+        flush();
+    }
+
+    /**
+     * @return the number of bytes unused in the buffer
+     */
+    public final int getRemaining()
+    {
+        return bufferSize - nextChar;
+    }
+
+    /**
+     * Write a single character.
+     *
+     */
+    public final void write(int c) throws IOException
+    {
+        if (bufferSize == 0)
+        {
+            writer.write(c);
+        }
+        else
+        {
+            if (nextChar >= bufferSize)
+                if (autoFlush)
+                    flushBuffer();
+                else
+                    bufferOverflow();
+            cb[nextChar++] = (char) c;
+        }
+    }
+
+    /**
+     * Our own little min method, to avoid loading
+     * <code>java.lang.Math</code> if we've run out of file
+     * descriptors and we're trying to print a stack trace.
+     */
+    private final int min(int a, int b)
+    {
+	    return (a < b ? a : b);
+    }
+
+    /**
+     * Write a portion of an array of characters.
+     *
+     * <p> Ordinarily this method stores characters from the given array into
+     * this stream's buffer, flushing the buffer to the underlying stream as
+     * needed.  If the requested length is at least as large as the buffer,
+     * however, then this method will flush the buffer and write the characters
+     * directly to the underlying stream.  Thus redundant
+     * <code>DiscardableBufferedWriter</code>s will not copy data unnecessarily.
+     *
+     * @param  cbuf  A character array
+     * @param  off   Offset from which to start reading characters
+     * @param  len   Number of characters to write
+     *
+     */
+    public final void write(char cbuf[], int off, int len) 
+        throws IOException 
+    {
+        if (bufferSize == 0)
+        {
+            writer.write(cbuf, off, len);
+            return;
+        }
+
+        if (len == 0)
+        {
+            return;
+        } 
+
+        if (len >= bufferSize)
+        {
+            /* If the request length exceeds the size of the output buffer,
+            flush the buffer and then write the data directly.  In this
+            way buffered streams will cascade harmlessly. */
+            if (autoFlush)
+                flushBuffer();
+            else
+                bufferOverflow();
+                writer.write(cbuf, off, len);
+            return;
+        }
+
+        int b = off, t = off + len;
+        while (b < t)
+        {
+            int d = min(bufferSize - nextChar, t - b);
+            System.arraycopy(cbuf, b, cb, nextChar, d);
+            b += d;
+            nextChar += d;
+            if (nextChar >= bufferSize) 
+                if (autoFlush)
+                    flushBuffer();
+                else
+                    bufferOverflow();
+        }
+    }
+
+    /**
+     * Write an array of characters.  This method cannot be inherited from the
+     * Writer class because it must suppress I/O exceptions.
+     */
+    public final void write(char buf[]) throws IOException
+    {
+    	write(buf, 0, buf.length);
+    }
+
+    /**
+     * Write a portion of a String.
+     *
+     * @param  s     String to be written
+     * @param  off   Offset from which to start reading characters
+     * @param  len   Number of characters to be written
+     *
+     */
+    public final void write(String s, int off, int len) throws IOException
+    {
+        if (bufferSize == 0)
+        {
+            writer.write(s, off, len);
+            return;
+        }
+        int b = off, t = off + len;
+        while (b < t)
+        {
+            int d = min(bufferSize - nextChar, t - b);
+            s.getChars(b, b + d, cb, nextChar);
+            b += d;
+            nextChar += d;
+            if (nextChar >= bufferSize) 
+                if (autoFlush)
+                    flushBuffer();
+                else
+                    bufferOverflow();
+        }
+    }
+
+    /**
+     * Write a string.  This method cannot be inherited from the Writer class
+     * because it must suppress I/O exceptions.
+     */
+    public final void write(String s) throws IOException
+    {
+    	write(s, 0, s.length());
+    }
+
+    /**
+     * resets this class so that it can be reused
+     *
+     */
+    public final void recycle( Writer writer)
+    {
+        this.writer = writer;
+        flushed = false;
+        clear();
+    }
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/io/VelocityWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/RuntimeLogger.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/RuntimeLogger.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/RuntimeLogger.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/RuntimeLogger.java Tue May 29 15:35:01 2012
@@ -0,0 +1,54 @@
+package org.apache.velocity.runtime;
+
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Interface for internal runtime logging services that are needed by the
+ *
+ * @author <a href="mailto:geirm@apache.org">Geir Magusson Jr.</a>
+ * @version $Id: RuntimeLogger.java,v 1.1.4.1 2004/03/03 23:22:55 geirm Exp $
+ */
+public interface RuntimeLogger
+{
+    /**
+     * Log a warning message.
+     *
+     * @param Object message to log
+     */
+    public void warn(Object message);
+
+    /**
+     * Log an info message.
+     *
+     * @param Object message to log
+     */
+    public  void info(Object message);
+
+    /**
+     * Log an error message.
+     *
+     * @param Object message to log
+     */
+    public void error(Object message);
+
+    /**
+     * Log a debug message.
+     *
+     * @param Object message to log
+     */
+    public void debug(Object message);
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/RuntimeLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/compiler/Compiler.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/compiler/Compiler.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/compiler/Compiler.java Tue May 29 15:35:01 2012
@@ -0,0 +1,146 @@
+package org.apache.velocity.runtime.compiler;
+
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Constants;
+
+/**
+ * The start of a velocity template compiler. Incomplete.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @version $Id: Compiler.java,v 1.6.8.1 2004/03/03 23:22:55 geirm Exp $
+ */
+public class Compiler implements InstructionConstants
+{
+    public static void main(String[] args)
+    {
+        String template = args[0].substring(0, args[0].indexOf("."));
+        ClassGen cg =
+                new ClassGen(template, "java.lang.Object", "<generated>",
+                Constants.ACC_PUBLIC | Constants.ACC_SUPER, null);
+        
+        ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
+        InstructionList il = new InstructionList();
+        MethodGen mg = new MethodGen(Constants.ACC_STATIC |
+                Constants.ACC_PUBLIC, // access flags
+                Type.VOID, // return type
+                new Type[]{ // argument types
+                new ArrayType(Type.STRING, 1)},
+                new String[]{ "argv" }, // arg names
+                "main", template, // method, class
+                il, cp);
+
+        //Add often needed constants to constant pool.
+
+        int br_index = cp.addClass("java.io.BufferedReader");
+        int ir_index = cp.addClass("java.io.InputStreamReader");
+        int system_out = cp.addFieldref("java.lang.System", "out", // System.out
+                "Ljava/io/PrintStream;");
+        int system_in = cp.addFieldref("java.lang.System", "in", // System.in
+                "Ljava/io/InputStream;");
+
+        // Create BufferedReader object and store it in local variable `in'.
+
+        il.append(new NEW(br_index));
+        il.append(DUP);
+        il.append(new NEW(ir_index));
+        il.append(DUP);
+        il.append(new GETSTATIC(system_in));
+
+        // Call constructors, i.e. BufferedReader(InputStreamReader())
+
+        il.append( new INVOKESPECIAL(
+                cp.addMethodref("java.io.InputStreamReader", "<init>",
+                "(Ljava/io/InputStream;)V")));
+        il.append( new INVOKESPECIAL(
+                cp.addMethodref("java.io.BufferedReader", "<init>", "(Ljava/io/Reader;)V")));
+        
+        // Create local variable `in'
+
+        LocalVariableGen lg = mg.addLocalVariable("in",
+                new ObjectType("java.io.BufferedReader"), null, null);
+        int in = lg.getIndex();
+        lg.setStart(il.append(new ASTORE(in))); // `i' valid from here
+
+        // Create local variable `name'
+
+        lg = mg.addLocalVariable("name", Type.STRING, null, null);
+        int name = lg.getIndex();
+        il.append(ACONST_NULL);
+        lg.setStart(il.append(new ASTORE(name))); // `name' valid from here
+
+        InstructionHandle try_start = il.append(new GETSTATIC(system_out));
+        il.append(new PUSH(cp, "I will be a template compiler!"));
+        il.append( new INVOKEVIRTUAL(
+                cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V")));
+        
+        // Upon normal execution we jump behind exception handler,
+        // the target address is not known yet.
+
+        GOTO g = new GOTO(null);
+        InstructionHandle try_end = il.append(g);
+
+        InstructionHandle handler = il.append(RETURN);
+        mg.addExceptionHandler(try_start, try_end, handler,
+                new ObjectType("java.io.IOException"));
+
+        // Normal code continues, now we can set the branch target of the GOTO.
+
+        InstructionHandle ih = il.append(new GETSTATIC(system_out));
+        g.setTarget(ih);
+
+        // String concatenation compiles to StringBuffer operations.
+        
+        il.append(new NEW(cp.addClass("java.lang.StringBuffer")));
+        il.append(DUP);
+        il.append(new PUSH(cp, " "));
+        il.append( new INVOKESPECIAL(
+                cp.addMethodref("java.lang.StringBuffer", "<init>", "(Ljava/lang/String;)V")));
+        
+        il.append(new ALOAD(name));
+
+        // One can also abstract from using the ugly signature syntax by using
+        // the getMethodSignature() method. For example:
+
+        String sig = Type.getMethodSignature(Type.STRINGBUFFER,
+                new Type[]{ Type.STRING });
+        il.append( new INVOKEVIRTUAL(
+                cp.addMethodref("java.lang.StringBuffer", "append", sig)));
+
+        il.append( new INVOKEVIRTUAL(
+                cp.addMethodref("java.lang.StringBuffer", "toString", "()Ljava/lang/String;")));
+
+        il.append(RETURN);
+        
+        mg.setMaxStack(5); // Needed stack size
+        cg.addMethod(mg.getMethod());
+
+        // Add public <init> method, i.e. empty constructor
+        cg.addEmptyConstructor(Constants.ACC_PUBLIC);
+
+        // Get JavaClass object and dump it to file.
+        try
+        {
+            cg.getJavaClass().dump(template + ".class");
+        }
+        catch (java.io.IOException e)
+        {
+            System.err.println(e);
+        }
+    }
+}

Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/compiler/Compiler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message