You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/05/29 17:35:15 UTC

svn commit: r1343781 [3/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...

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/FieldMethodizer.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/FieldMethodizer.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/FieldMethodizer.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/FieldMethodizer.java Tue May 29 15:35:01 2012
@@ -0,0 +1,172 @@
+package org.apache.velocity.app;
+
+/*
+ * 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.lang.Class;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+
+/**
+ *  <p>
+ *  This is a small utility class allow easy access to static fields in a class,
+ *  such as string constants.  Velocity will not introspect for class
+ *  fields (and won't in the future :), but writing setter/getter methods to do 
+ *  this really is a pain,  so use this if you really have
+ *  to access fields.
+ *  
+ *  <p>
+ *  The idea it so enable access to the fields just like you would in Java.  
+ *  For example, in Java, you would access a static field like
+ *  <blockquote><pre>
+ *  MyClass.STRING_CONSTANT
+ *  </pre></blockquote>
+ *  and that is the same thing we are trying to allow here.
+ *
+ *  <p>
+ *  So to use in your Java code, do something like this :
+ *  <blockquote><pre>
+ *   context.put("runtime", new FieldMethodizer( "org.apache.velocity.runtime.Runtime" ));
+ *  </pre></blockquote>
+ *  and then in your template, you can access any of your static fields in this way :
+ *  <blockquote><pre>  
+ *   $runtime.RUNTIME_LOG_WARN_STACKTRACE
+ *  </pre></blockquote>
+ *
+ *  <p>
+ *  Right now, this class only methodizes <code>public static</code> fields.  It seems
+ *  that anything else is too dangerous.  This class is for convenience accessing
+ *  'constants'.  If you have fields that aren't <code>static</code> it may be better
+ *  to handle them by explicitly placing them into the context.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: FieldMethodizer.java,v 1.3.14.1 2004/03/03 23:22:53 geirm Exp $ 
+ */
+public class FieldMethodizer
+{
+    /** Hold the field objects by field name */
+    private HashMap fieldHash = new HashMap();
+
+    /** Hold the class objects by field name */
+    private HashMap classHash = new HashMap();
+
+    /**
+     * Allow object to be initialized without any data. You would use
+     * addObject() to add data later.
+     */
+    public FieldMethodizer()
+    {
+    }
+
+    /**
+     *  Constructor that takes as it's arg the name of the class
+     *  to methodize.
+     *
+     *  @param s Name of class to methodize.
+     */
+    public FieldMethodizer( String s )
+    {
+        try
+        {
+            addObject(s);
+        }
+        catch( Exception e )
+        {
+            System.out.println( e );
+        }
+    }
+
+  /**
+     *  Constructor that takes as it's arg a living
+     *  object to methodize.  Note that it will still
+     *  only methodized the public static fields of
+     *  the class.
+     *
+     *  @param s Name of class to methodize.
+     */
+    public FieldMethodizer( Object o )
+    {
+        try
+        {
+            addObject(o);
+        }
+        catch( Exception e )
+        {
+            System.out.println( e );
+        }
+    }
+    
+    /**
+     * Add the Name of the class to methodize
+     */
+    public void addObject ( String s )
+        throws Exception
+    {
+        inspect(Class.forName(s));
+    }
+    
+    /**
+     * Add an Object to methodize
+     */
+    public void addObject ( Object o )
+        throws Exception
+    {
+        inspect(o.getClass());
+    }
+
+    /**
+     *  Accessor method to get the fields by name.
+     *
+     *  @param fieldName Name of static field to retrieve
+     *
+     *  @return The value of the given field.
+     */
+    public Object get( String fieldName )
+    {
+        try 
+        {
+            Field f = (Field) fieldHash.get( fieldName );
+            if (f != null)
+                return f.get( (Class) classHash.get(fieldName) );
+        }
+        catch( Exception e )
+        {
+        }
+        return null;
+    }
+
+    /**
+     *  Method that retrieves all public static fields
+     *  in the class we are methodizing.
+     */
+    private void inspect(Class clas)
+    {
+        Field[] fields = clas.getFields();
+        for( int i = 0; i < fields.length; i++)
+        {
+            /*
+             *  only if public and static
+             */
+            int mod = fields[i].getModifiers();
+            if ( Modifier.isStatic(mod) && Modifier.isPublic(mod) )
+            {
+                fieldHash.put(fields[i].getName(), fields[i]);
+                classHash.put(fields[i].getName(), clas);
+            }
+        }
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/Velocity.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/Velocity.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/Velocity.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/Velocity.java Tue May 29 15:35:01 2012
@@ -0,0 +1,586 @@
+package org.apache.velocity.app;
+
+/*
+ * 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.Writer;
+import java.util.Properties;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.velocity.context.Context;
+import org.apache.velocity.Template;
+import org.apache.velocity.context.InternalContextAdapterImpl;
+import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.parser.node.SimpleNode;
+import org.apache.velocity.runtime.configuration.Configuration;
+
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.MethodInvocationException;
+
+import org.apache.velocity.runtime.parser.ParseException;
+
+import org.apache.commons.collections.ExtendedProperties;
+
+/**
+ * This class provides  services to the application
+ * developer, such as :
+ * <ul>
+ * <li> Simple Velocity Runtime engine initialization methods.
+ * <li> Functions to apply the template engine to streams and strings
+ *      to allow embedding and dynamic template generation.
+ * <li> Methods to access Velocimacros directly.
+ * </ul>
+ *
+ * <br><br>
+ * While the most common way to use Velocity is via templates, as
+ * Velocity is a general-purpose template engine, there are other
+ * uses that Velocity is well suited for, such as processing dynamically
+ * created templates, or processing content streams.
+ *
+ * <br><br>
+ * The methods herein were developed to allow easy access to the Velocity
+ * facilities without direct spelunking of the internals.  If there is
+ * something you feel is necessary to add here, please, send a patch.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @version $Id: Velocity.java,v 1.30.4.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public class Velocity implements RuntimeConstants
+{
+    /**
+     *  initialize the Velocity runtime engine, using the default
+     *  properties of the Velocity distribution
+     */
+    public static void init()
+        throws Exception
+    {
+        RuntimeSingleton.init();
+    }
+
+    /**
+     *  initialize the Velocity runtime engine, using default properties
+     *  plus the properties in the properties file passed in as the arg
+     *
+     *  @param propsFilename file containing properties to use to initialize
+     *         the Velocity runtime
+     */
+    public static void init( String propsFilename )
+        throws Exception
+    {
+        RuntimeSingleton.init(propsFilename);
+    }
+
+    /**
+     *  initialize the Velocity runtime engine, using default properties
+     *  plus the properties in the passed in java.util.Properties object
+     *
+     *  @param p  Proprties object containing initialization properties
+     *
+     */
+    public static void init( Properties p )
+        throws Exception
+    {
+        RuntimeSingleton.init( p );
+    }
+
+    /**
+     * Set a Velocity Runtime property.
+     *
+     * @param String key
+     * @param Object value
+     */
+    public static void setProperty(String key, Object value)
+    {
+        RuntimeSingleton.setProperty(key,value);
+    }
+
+    /**
+     * Add a Velocity Runtime property.
+     *
+     * @param String key
+     * @param Object value
+     */
+    public static void addProperty(String key, Object value)
+    {
+        RuntimeSingleton.addProperty(key,value);
+    }
+
+    /**
+     * Clear a Velocity Runtime property.
+     *
+     * @param key of property to clear
+     */
+    public static void clearProperty(String key)
+    {
+        RuntimeSingleton.clearProperty(key);
+    }
+
+    /**
+     * Set an entire configuration at once. This is
+     * useful in cases where the parent application uses
+     * the Configuration class and the velocity configuration
+     * is a subset of the parent application's configuration.
+     *
+     * @param Configuration configuration
+     *
+     * @deprecated Use
+     *  {@link #setExtendedProperties( ExtendedProperties  ) }
+     */
+    public static void setConfiguration(Configuration configuration)
+    {
+        /*
+         *  Yuk. We added a little helper to Configuration to
+         *  help with deprecation.  The Configuration class
+         *  contains a 'shadow' ExtendedProperties
+         */
+
+        ExtendedProperties ep = configuration.getExtendedProperties();
+
+        RuntimeSingleton.setConfiguration( ep );
+    }
+
+    /**
+     * Set an entire configuration at once. This is
+     * useful in cases where the parent application uses
+     * the ExtendedProperties class and the velocity configuration
+     * is a subset of the parent application's configuration.
+     *
+     * @param ExtendedProperties configuration
+     *
+     */
+    public static void setExtendedProperties( ExtendedProperties configuration)
+    {
+        RuntimeSingleton.setConfiguration( configuration );
+    }
+
+    /**
+     *  Get a Velocity Runtime property.
+     *
+     *  @param key property to retrieve
+     *  @return property value or null if the property
+     *        not currently set
+     */
+    public static Object getProperty( String key )
+    {
+        return RuntimeSingleton.getProperty( key );
+    }
+
+    /**
+     *  renders the input string using the context into the output writer.
+     *  To be used when a template is dynamically constructed, or want to use
+     *  Velocity as a token replacer.
+     *
+     *  @param context context to use in rendering input string
+     *  @param out  Writer in which to render the output
+     *  @param logTag  string to be used as the template name for log
+     *                 messages in case of error
+     *  @param instring input string containing the VTL to be rendered
+     *
+     *  @return true if successful, false otherwise.  If false, see
+     *             Velocity runtime log
+     */
+    public static  boolean evaluate( Context context,  Writer out,
+                                     String logTag, String instring )
+        throws ParseErrorException, MethodInvocationException,
+        	ResourceNotFoundException, IOException
+    {
+        return evaluate( context, out, logTag, new BufferedReader( new StringReader( instring )) );
+    }
+
+    /**
+     *  Renders the input stream using the context into the output writer.
+     *  To be used when a template is dynamically constructed, or want to
+     *  use Velocity as a token replacer.
+     *
+     *  @param context context to use in rendering input string
+     *  @param out  Writer in which to render the output
+     *  @param logTag  string to be used as the template name for log messages
+     *                 in case of error
+     *  @param instream input stream containing the VTL to be rendered
+     *
+     *  @return true if successful, false otherwise.  If false, see
+     *               Velocity runtime log
+     *  @deprecated Use
+     *  {@link #evaluate( Context context, Writer writer,
+     *      String logTag, Reader reader ) }
+     */
+    public static boolean evaluate( Context context, Writer writer,
+                                    String logTag, InputStream instream )
+        throws ParseErrorException, MethodInvocationException,
+        	ResourceNotFoundException, IOException
+    {
+        /*
+         *  first, parse - convert ParseException if thrown
+         */
+
+        BufferedReader br  = null;
+        String encoding = null;
+
+        try
+        {
+            encoding = RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT);
+            br = new BufferedReader(  new InputStreamReader( instream, encoding));
+        }
+        catch( UnsupportedEncodingException  uce )
+        {
+            String msg = "Unsupported input encoding : " + encoding
+                + " for template " + logTag;
+            throw new ParseErrorException( msg );
+        }
+
+        return evaluate( context, writer, logTag, br );
+    }
+
+    /**
+     *  Renders the input reader using the context into the output writer.
+     *  To be used when a template is dynamically constructed, or want to
+     *  use Velocity as a token replacer.
+     *
+     *  @param context context to use in rendering input string
+     *  @param out  Writer in which to render the output
+     *  @param logTag  string to be used as the template name for log messages
+     *                 in case of error
+     *  @param reader Reader containing the VTL to be rendered
+     *
+     *  @return true if successful, false otherwise.  If false, see
+     *               Velocity runtime log
+     *
+     *  @since Velocity v1.1
+     */
+    public static boolean evaluate( Context context, Writer writer,
+                                    String logTag, Reader reader )
+        throws ParseErrorException, MethodInvocationException,
+        	ResourceNotFoundException,IOException
+    {
+        SimpleNode nodeTree = null;
+
+        try
+        {
+            nodeTree = RuntimeSingleton.parse( reader, logTag );
+        }
+        catch ( ParseException pex )
+        {
+            throw  new ParseErrorException( pex.getMessage() );
+        }
+
+        /*
+         * now we want to init and render
+         */
+
+        if (nodeTree != null)
+        {
+            InternalContextAdapterImpl ica =
+                new InternalContextAdapterImpl( context );
+
+            ica.pushCurrentTemplateName( logTag );
+
+            try
+            {
+                try
+                {
+                    nodeTree.init( ica, RuntimeSingleton.getRuntimeServices() );
+                }
+                catch( Exception e )
+                {
+                    RuntimeSingleton.error("Velocity.evaluate() : init exception for tag = "
+                                  + logTag + " : " + e );
+                }
+
+                /*
+                 *  now render, and let any exceptions fly
+                 */
+
+                nodeTree.render( ica, writer );
+            }
+            finally
+            {
+                ica.popCurrentTemplateName();
+            }
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     *  Invokes a currently registered Velocimacro with the parms provided
+     *  and places the rendered stream into the writer.
+     *
+     *  Note : currently only accepts args to the VM if they are in the context.
+     *
+     *  @param vmName name of Velocimacro to call
+     *  @param logTag string to be used for template name in case of error
+     *  @param params[] args used to invoke Velocimacro. In context key format :
+     *                  eg  "foo","bar" (rather than "$foo","$bar")
+     *  @param context Context object containing data/objects used for rendering.
+     *  @param writer  Writer for output stream
+     *  @return true if Velocimacro exists and successfully invoked, false otherwise.
+     */
+    public static  boolean invokeVelocimacro( String vmName, String logTag,
+                                              String params[], Context context,
+                                              Writer writer )
+    {
+        /*
+         *  check parms
+         */
+
+        if ( vmName == null ||  params == null ||  context == null
+             || writer == null || logTag == null)
+        {
+            RuntimeSingleton.error( "Velocity.invokeVelocimacro() : invalid parameter");
+            return false;
+        }
+
+        /*
+         * does the VM exist?
+         */
+
+        if (!RuntimeSingleton.isVelocimacro( vmName, logTag ))
+        {
+            RuntimeSingleton.error( "Velocity.invokeVelocimacro() : VM '"+ vmName
+                           + "' not registered.");
+            return false;
+        }
+
+        /*
+         *  now just create the VM call, and use evaluate
+         */
+
+        StringBuffer construct = new StringBuffer("#");
+
+        construct.append( vmName );
+        construct.append( "(" );
+
+        for( int i = 0; i < params.length; i++)
+        {
+            construct.append( " $" );
+            construct.append( params[i] );
+        }
+
+        construct.append(" )");
+
+        try
+        {
+            boolean retval = evaluate(  context,  writer,
+                                         logTag, construct.toString() );
+
+            return retval;
+        }
+        catch( Exception  e )
+        {
+            RuntimeSingleton.error( "Velocity.invokeVelocimacro() : error " + e );
+        }
+
+        return false;
+    }
+
+    /**
+     *  merges a template and puts the rendered stream into the writer
+     *
+     *  @param templateName name of template to be used in merge
+     *  @param context  filled context to be used in merge
+     *  @param  writer  writer to write template into
+     *
+     *  @return true if successful, false otherwise.  Errors
+     *           logged to velocity log.
+     *  @deprecated Use
+     *  {@link #mergeTemplate( String templateName, String encoding,
+     *                Context context, Writer writer )}
+     */
+    public static boolean mergeTemplate( String templateName,
+                                         Context context, Writer writer )
+        throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
+    {
+        return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
+                               context, writer );
+    }
+
+    /**
+     *  merges a template and puts the rendered stream into the writer
+     *
+     *  @param templateName name of template to be used in merge
+     *  @param encoding encoding used in template
+     *  @param context  filled context to be used in merge
+     *  @param  writer  writer to write template into
+     *
+     *  @return true if successful, false otherwise.  Errors
+     *           logged to velocity log
+     *
+     *  @since Velocity v1.1
+     */
+    public static boolean mergeTemplate( String templateName, String encoding,
+                                      Context context, Writer writer )
+        throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
+    {
+        Template template = RuntimeSingleton.getTemplate(templateName, encoding);
+
+        if ( template == null )
+        {
+            RuntimeSingleton.error("Velocity.parseTemplate() failed loading template '"
+                          + templateName + "'" );
+            return false;
+        }
+        else
+        {
+            template.merge(context, writer);
+            return true;
+         }
+    }
+
+    /**
+     *  Returns a <code>Template</code> from the Velocity
+     *  resource management system.
+     *
+     * @param name The file name of the desired template.
+     * @return     The template.
+     * @throws ResourceNotFoundException if template not found
+     *          from any available source.
+     * @throws ParseErrorException if template cannot be parsed due
+     *          to syntax (or other) error.
+     * @throws Exception if an error occurs in template initialization
+     */
+    public static Template getTemplate(String name)
+        throws ResourceNotFoundException, ParseErrorException, Exception
+    {
+        return RuntimeSingleton.getTemplate( name );
+    }
+
+    /**
+     *  Returns a <code>Template</code> from the Velocity
+     *  resource management system.
+     *
+     * @param name The file name of the desired template.
+     * @param encoding The character encoding to use for the template.
+     * @return     The template.
+     * @throws ResourceNotFoundException if template not found
+     *          from any available source.
+     * @throws ParseErrorException if template cannot be parsed due
+     *          to syntax (or other) error.
+     * @throws Exception if an error occurs in template initialization
+     *
+     *  @since Velocity v1.1
+     */
+    public static Template getTemplate(String name, String encoding)
+        throws ResourceNotFoundException, ParseErrorException, Exception
+    {
+        return RuntimeSingleton.getTemplate( name, encoding );
+    }
+
+    /**
+     * <p>Determines whether a resource is accessable via the
+     * currently configured resource loaders.  {@link
+     * org.apache.velocity.runtime.resource.Resource} is the generic
+     * description of templates, static content, etc.</p>
+     *
+     * <p>Note that the current implementation will <b>not</b> change
+     * the state of the system in any real way - so this cannot be
+     * used to pre-load the resource cache, as the previous
+     * implementation did as a side-effect.</p>
+     *
+     * @param resourceName The name of the resource to search for.
+     * @return Whether the resource was located.
+     */
+    public static boolean resourceExists(String resourceName)
+    {
+        return (RuntimeSingleton.getLoaderNameForResource(resourceName) != null);
+    }
+
+    /**
+     * Log a warning message.
+     *
+     * @param Object message to log
+     */
+    public static void warn(Object message)
+    {
+        RuntimeSingleton.warn( message );
+    }
+
+    /**
+     * Log an info message.
+     *
+     * @param Object message to log
+     */
+    public static void info(Object message)
+    {
+        RuntimeSingleton.info( message );
+    }
+
+    /**
+     * Log an error message.
+     *
+     * @param Object message to log
+     */
+    public static void error(Object message)
+    {
+        RuntimeSingleton.error( message );
+    }
+
+    /**
+     * Log a debug message.
+     *
+     * @param Object message to log
+     */
+    public static void debug(Object message)
+    {
+        RuntimeSingleton.debug( message );
+    }
+
+    /**
+     *  <p>
+     *  Set the an ApplicationAttribue, which is an Object
+     *  set by the application which is accessable from
+     *  any component of the system that gets a RuntimeServices.
+     *  This allows communication between the application
+     *  environment and custom pluggable components of the
+     *  Velocity engine, such as loaders and loggers.
+     *  </p>
+     *
+     *  <p>
+     *  Note that there is no enfocement or rules for the key
+     *  used - it is up to the application developer.  However, to
+     *  help make the intermixing of components possible, using
+     *  the target Class name (e.g.  com.foo.bar ) as the key
+     *   might help avoid collision.
+     *  </p>
+     *
+     *  @param key object 'name' under which the object is stored
+     *  @param value object to store under this key
+     */
+     public static void setApplicationAttribute( Object key, Object value )
+     {
+        RuntimeSingleton.getRuntimeInstance().setApplicationAttribute( key, value);
+     }
+
+    /**
+     * @see #resourceExists(String)
+     * @deprecated Use resourceExists(String) instead.
+     */
+    public static boolean templateExists(String resourceName)
+    {
+        return resourceExists(resourceName);
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventCartridge.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventCartridge.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventCartridge.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventCartridge.java Tue May 29 15:35:01 2012
@@ -0,0 +1,207 @@
+package org.apache.velocity.app.event;
+
+/*
+ * 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.context.InternalEventContext;
+import org.apache.velocity.context.Context;
+
+/**
+ *  'Package' of event handlers...
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:j_a_fernandez@yahoo.com">Jose Alberto Fernandez</a>
+ * @version $Id: EventCartridge.java,v 1.3.4.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public class EventCartridge implements ReferenceInsertionEventHandler,
+                                       NullSetEventHandler,
+                                       MethodExceptionEventHandler
+{
+    private ReferenceInsertionEventHandler rieh = null;
+    private NullSetEventHandler nseh = null;
+    private MethodExceptionEventHandler meeh = null;
+
+    /**
+     *  Adds an event handler(s) to the Cartridge.  This method
+     *  will find all possible event handler interfaces supported
+     *  by the passed in object.
+     *
+     *  @param ev object impementing a valid EventHandler-derived interface
+     *  @return true if a supported interface, false otherwise or if null
+     */
+    public boolean addEventHandler( EventHandler ev )
+    {
+        if (ev == null)
+        {
+            return false;
+        }
+        
+        boolean found = false;
+
+        if ( ev instanceof ReferenceInsertionEventHandler)
+        {
+            rieh = (ReferenceInsertionEventHandler) ev;
+            found = true;
+        }
+       
+        if ( ev instanceof NullSetEventHandler )
+        {
+            nseh = (NullSetEventHandler) ev;
+            found = true;
+        }
+
+        if ( ev instanceof MethodExceptionEventHandler )
+        {
+            meeh = (MethodExceptionEventHandler) ev;
+            found = true;
+        }
+ 
+        return found;
+    }
+    
+    /**
+     *  Removes an event handler(s) from the Cartridge.  This method
+     *  will find all possible event handler interfaces supported
+     *  by the passed in object and remove them.
+     *
+     *  @param ev object impementing a valid EventHandler-derived interface
+     *  @return true if a supported interface, false otherwise or if null
+     */
+    public boolean removeEventHandler(EventHandler ev)
+    {
+        if ( ev == null )
+        {
+            return false;
+        }
+
+        boolean found = false;
+        
+        if (ev == rieh) 
+        {
+            rieh = null;
+            found = true;
+        }
+	
+        if (ev == nseh) 
+        {
+            nseh = null;
+            found = true;
+        }
+
+        if (ev == meeh) 
+        {
+            meeh = null;
+            found = true;
+        }
+
+        return found;
+    }
+
+    /**
+     *  Implementation of ReferenceInsertionEventHandler method
+     *  <code>referenceInsert()</code>.
+     *
+     *  Called during Velocity merge before a reference value will
+     *  be inserted into the output stream.
+     *
+     *  @param reference reference from template about to be inserted
+     *  @param value  value about to be inserted (after toString() )
+     *  @return Object on which toString() should be called for output.
+     */
+    public Object referenceInsert( String reference, Object value  )
+    {
+        if (rieh == null)
+        {
+            return value;
+        }
+
+        return rieh.referenceInsert( reference, value );
+    }
+
+    /**
+     *  Implementation of NullSetEventHandler method
+     *  <code>shouldLogOnNullSet()</code>.
+     *
+     *  Called during Velocity merge to determine if when
+     *  a #set() results in a null assignment, a warning
+     *  is logged.
+     *
+     *  @param reference reference from template about to be inserted
+     *  @return true if to be logged, false otherwise
+     */
+    public boolean shouldLogOnNullSet( String lhs, String rhs )
+    {
+        if ( nseh == null)
+        {
+            return true;
+        }
+
+        return nseh.shouldLogOnNullSet( lhs, rhs );
+    }
+    
+    /**
+     *  Implementation of MethodExceptionEventHandler  method
+     *  <code>methodException()</code>.
+     *
+     *  Called during Velocity merge if a reference is null
+     *
+     *  @param claz  Class that is causing the exception
+     *  @param method method called that causes the exception
+     *  @param e Exception thrown by the method
+     *  @return Object to return as method result
+     *  @throws exception to be wrapped and propogated to app  
+     */
+    public Object methodException( Class claz, String method, Exception e )
+        throws Exception
+    {
+        /*
+         *  if we don't have a handler, just throw what we were handed
+         */
+        if (meeh == null)
+        {
+            throw e;
+        }
+
+        /*
+         *  otherwise, call it..
+         */
+        return meeh.methodException( claz, method, e );
+    }
+    
+    /**
+     *  Attached the EventCartridge to the context
+     *
+     *  Final because not something one should mess with lightly :)
+     *
+     *  @param context context to attach to
+     *  @return true if successful, false otherwise
+     */
+    public final boolean attachToContext( Context context )
+    {
+        if (  context instanceof InternalEventContext )
+        {         
+            InternalEventContext iec = (InternalEventContext) context;
+
+            iec.attachEventCartridge( this );
+
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventHandler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventHandler.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventHandler.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/EventHandler.java Tue May 29 15:35:01 2012
@@ -0,0 +1,28 @@
+package org.apache.velocity.app.event;
+
+/*
+ * 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 interface for all event handlers
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: EventHandler.java,v 1.2.4.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public interface  EventHandler
+{
+
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java Tue May 29 15:35:01 2012
@@ -0,0 +1,32 @@
+package org.apache.velocity.app.event;
+/*
+ * 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.
+ */
+
+/**
+ *  Called when a method throws an exception.  This gives the
+ *  application a chance to deal with it and either
+ *  return something nice, or throw.
+ *
+ *  Please return what you want rendered into the output stream.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: MethodExceptionEventHandler.java,v 1.1.12.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public interface MethodExceptionEventHandler extends EventHandler
+{
+    public Object methodException( Class claz, String method, Exception e )
+         throws Exception;
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/NullSetEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/NullSetEventHandler.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/NullSetEventHandler.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/NullSetEventHandler.java Tue May 29 15:35:01 2012
@@ -0,0 +1,37 @@
+package org.apache.velocity.app.event;
+
+/*
+ * 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.
+ */
+
+/**
+ *  Event handler : lets an app approve / veto
+ *  writing a log message when RHS of #set() is null.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: NullSetEventHandler.java,v 1.2.12.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public interface NullSetEventHandler extends EventHandler
+{
+    /**
+     *  Called when the RHS of a #set() is null, which will result
+     *  in a null LHS.
+     *
+     *  @param lhs  reference literal of left-hand-side of set statement
+     *  @param rhs  reference literal of right-hand-side of set statement
+     *  @return true if log message should be written, false otherwise
+     */
+    public boolean shouldLogOnNullSet( String lhs, String rhs );
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java Tue May 29 15:35:01 2012
@@ -0,0 +1,40 @@
+package org.apache.velocity.app.event;
+/*
+ * 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.
+ */
+
+/**
+ *  Reference 'Stream insertion' event handler.  Called with object
+ *  that will be inserted into stream via value.toString().
+ *
+ *  Please return an Object that will toString() nicely :)
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ReferenceInsertionEventHandler.java,v 1.2.8.1 2004/03/03 23:22:53 geirm Exp $
+ */
+public interface  ReferenceInsertionEventHandler extends EventHandler
+{
+    /**
+     * A call-back which is executed during Velocity merge before a
+     * reference value is inserted into the output stream.
+     *
+     * @param reference Reference from template about to be inserted.
+     * @param value Value about to be inserted (after its
+     * <code>toString()</code> method is called).
+     * @return Object on which <code>toString()</code> should be
+     * called for output.
+     */
+    public Object referenceInsert( String reference, Object value  );
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java Tue May 29 15:35:01 2012
@@ -0,0 +1,456 @@
+package org.apache.velocity.app.tools;
+
+/*
+ * Copyright (c) 2001 The Java Apache Project.  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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the Java Apache
+ *    Project for use in the Apache JServ servlet engine project
+ *    <http://java.apache.org/>."
+ *
+ * 4. The names "Apache JServ", "Apache JServ Servlet Engine", "Turbine",
+ *    "Apache Turbine", "Turbine Project", "Apache Turbine Project" and
+ *    "Java Apache Project" must not be used to endorse or promote products
+ *    derived from this software without prior written permission.
+ *
+ * 5. Products derived from this software may not be called "Apache JServ"
+ *    nor may "Apache" nor "Apache JServ" appear in their names without
+ *    prior written permission of the Java Apache Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the Java Apache
+ *    Project for use in the Apache JServ servlet engine project
+ *    <http://java.apache.org/>."
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "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 JAVA APACHE PROJECT 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 Java Apache Group. For more information
+ * on the Java Apache Project and the Apache JServ Servlet Engine project,
+ * please see <http://java.apache.org/>.
+ *
+ */
+
+// Java Core Classes
+import java.util.*;
+import java.text.*;
+import java.lang.reflect.Array;
+
+// Veclocity classes
+import org.apache.velocity.context.*;
+
+/**
+ * Formatting tool for inserting into the Velocity WebContext.  Can
+ * format dates or lists of objects.
+ *
+ * <p>Here's an example of some uses:
+ *
+ * <code><pre>
+ * $formatter.formatShortDate($object.Date)
+ * $formatter.formatLongDate($db.getRecord(232).getDate())
+ * $formatter.formatArray($array)
+ * $formatter.limitLen(30, $object.Description)
+ * </pre></code>
+ * 
+ * @author <a href="sean@somacity.com">Sean Legassick</a>
+ * @author <a href="dlr@collab.net">Daniel Rall</a>
+ * @version $Id: VelocityFormatter.java,v 1.9 2003/05/04 17:06:11 geirm Exp $
+ */
+public class VelocityFormatter
+{
+    Context context = null;
+    NumberFormat nf = NumberFormat.getInstance();
+
+    /**
+     * Constructor needs a backpointer to the context.
+     *
+     * @param context A Context.
+     */
+    public VelocityFormatter(Context context)
+    {
+        this.context = context;
+    }
+
+    /**
+     * Formats a date in <code>DateFormat.SHORT</code> style.
+     *
+     * @param date The date to format.
+     * @return The formatted date as text.
+     */
+    public String formatShortDate(Date date)
+    {
+        return DateFormat.getDateInstance(DateFormat.SHORT).format(date);
+    }
+
+    /**
+     * Formats a date in <code>DateFormat.LONG</code> style.
+     *
+     * @param date The date to format.
+     * @return The formatted date as text.
+     */
+    public String formatLongDate(Date date)
+    {
+        return DateFormat.getDateInstance(DateFormat.LONG).format(date);
+    }
+
+    /**
+     * Formats a date/time in 'short' style.
+     *
+     * @param date The date to format.
+     * @return The formatted date as text.
+     */
+    public String formatShortDateTime(Date date)
+    {
+        return DateFormat
+            .getDateTimeInstance(DateFormat.SHORT,
+                                 DateFormat.SHORT).format(date);
+    }
+
+    /**
+     * Formats a date/time in 'long' style.
+     *
+     * @param date The date to format.
+     * @return The formatted date as text.
+     */
+    public String formatLongDateTime(Date date)
+    {
+        return DateFormat.getDateTimeInstance(
+                DateFormat.LONG, DateFormat.LONG).format(date);
+    }
+
+    /**
+     * Formats an array into the form "A, B and C".
+     *
+     * @param array An Object.
+     * @return A String.
+     */
+    public String formatArray(Object array)
+    {
+        return formatArray(array, ", ", " and ");
+    }
+
+    /**
+     * Formats an array into the form
+     * "A&lt;delim&gt;B&lt;delim&gt;C".
+     *
+     * @param array An Object.
+     * @param delim A String.
+     * @return A String.
+     */
+    public String formatArray(Object array,
+                              String delim)
+    {
+        return formatArray(array, delim, delim);
+    }
+
+    /**
+     * Formats an array into the form
+     * "A&lt;delim&gt;B&lt;finaldelim&gt;C".
+     *
+     * @param array An Object.
+     * @param delim A String.
+     * @param finalDelim A String.
+     * @return A String.
+     */
+    public String formatArray(Object array,
+                              String delim,
+                              String finaldelim)
+    {
+        StringBuffer sb = new StringBuffer();
+        int arrayLen = Array.getLength(array);
+        for (int i = 0; i < arrayLen; i++)
+        {
+            // Use the Array.get method as this will automatically
+            // wrap primitive types in a suitable Object-derived
+            // wrapper if necessary.
+            sb.append(Array.get(array, i).toString());
+            if (i  < arrayLen - 2)
+            {
+                sb.append(delim);
+            }
+            else if (i < arrayLen - 1)
+            {
+                sb.append(finaldelim);
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Formats a vector into the form "A, B and C".
+     *
+     * @param list The list of elements to format.
+     * @return A String.
+     */
+    public String formatVector(List list)
+    {
+        return formatVector(list, ", ", " and ");
+    }
+
+    /**
+     * Formats a vector into the form "A&lt;delim&gt;B&lt;delim&gt;C".
+     *
+     * @param list The list of elements to format.
+     * @param delim A String.
+     * @return A String.
+     */
+    public String formatVector(List list,
+                               String delim)
+    {
+        return formatVector(list, delim, delim);
+    }
+
+    /**
+     * Formats a list into the form
+     * "Adelim&gt;B&lt;finaldelim&gt;C".
+     *
+     * @param list The list of elements to format.
+     * @param delim A String.
+     * @param finalDelim A String.
+     * @return A String.
+     */
+    public String formatVector(List list,
+                               String delim,
+                               String finaldelim)
+    {
+        StringBuffer sb = new StringBuffer();
+        int size = list.size();
+        for (int i = 0; i < size; i++)
+        {
+            sb.append(list.get(i));
+            if (i < size - 2)
+            {
+                sb.append(delim);
+            }
+            else if (i < size - 1)
+            {
+                sb.append(finaldelim);
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Limits 'string' to 'maxlen' characters.  If the string gets
+     * curtailed, "..." is appended to it.
+     *
+     * @param maxlen An int with the maximum length.
+     * @param string A String.
+     * @return A String.
+     */
+    public String limitLen(int maxlen,
+                           String string)
+    {
+        return limitLen(maxlen, string, "...");
+    }
+
+    /**
+     * Limits 'string' to 'maxlen' character.  If the string gets
+     * curtailed, 'suffix' is appended to it.
+     *
+     * @param maxlen An int with the maximum length.
+     * @param string A String.
+     * @param suffix A String.
+     * @return A String.
+     */
+    public String limitLen(int maxlen,
+                           String string,
+                           String suffix)
+    {
+        String ret = string;
+        if (string.length() > maxlen)
+        {
+            ret = string.substring(0, maxlen - suffix.length()) + suffix;
+        }
+        return ret;
+    }
+
+    /**
+     * Class that returns alternating values in a template.  It stores
+     * a list of alternate Strings, whenever alternate() is called it
+     * switches to the next in the list.  The current alternate is
+     * retrieved through toString() - i.e. just by referencing the
+     * object in a Velocity template.  For an example of usage see the
+     * makeAlternator() method below.
+     */
+    public class VelocityAlternator
+    {
+        protected String[] alternates = null;
+        protected int current = 0;
+
+        /**
+         * Constructor takes an array of Strings.
+         *
+         * @param alternates A String[].
+         */
+        public VelocityAlternator(String[] alternates)
+        {
+            this.alternates = alternates;
+        }
+
+        /**
+         * Alternates to the next in the list.
+         *
+         * @return The current alternate in the sequence.
+         */
+        public String alternate()
+        {
+            current++;
+            current %= alternates.length;
+            return "";
+        }
+
+        /**
+         * Returns the current alternate.
+         *
+         * @return A String.
+         */
+        public String toString()
+        {
+            return alternates[current];
+        }
+    }
+
+    /**
+     * As VelocityAlternator, but calls <code>alternate()</code>
+     * automatically on rendering in a template.
+     */
+    public class VelocityAutoAlternator extends VelocityAlternator
+    {
+        /**
+         * Constructor takes an array of Strings.
+         *
+         * @param alternates A String[].
+         */
+        public VelocityAutoAlternator(String[] alternates)
+        {
+            super(alternates);
+        }
+
+        /**
+         * Returns the current alternate, and automatically alternates
+         * to the next alternate in its sequence (trigged upon
+         * rendering).
+         *
+         * @return The current alternate in the sequence.
+         */
+        public final String toString()
+        {
+            String s = alternates[current];
+            alternate();
+            return s;
+        }
+    }
+
+    /**
+     * Makes an alternator object that alternates between two values.
+     *
+     * <p>Example usage in a Velocity template:
+     *
+     * <code><pre>
+     * &lt;table&gt;
+     * $formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0")
+     * #foreach $item in $items
+     * #begin
+     * &lt;tr&gt;&lt;td bgcolor="$rowcolor"&gt;$item.Name&lt;/td&gt;&lt;/tr&gt;
+     * $rowcolor.alternate()
+     * #end
+     * &lt;/table&gt;
+     * </pre></code>
+     *
+     * @param name The name for the alternator int the context.
+     * @param alt1 The first alternate.
+     * @param alt2 The second alternate.
+     * @return The newly created instance.
+     */
+    public String makeAlternator(String name,
+                                 String alt1,
+                                 String alt2)
+    {
+        String[] alternates = { alt1, alt2 };
+        context.put(name, new VelocityAlternator(alternates));
+        return "";
+    }
+
+    /**
+     * Makes an alternator object that alternates between three
+     * values.
+     *
+     * @see #makeAlternator(String name, String alt1, String alt2)
+     */
+    public String makeAlternator(String name,
+                                 String alt1,
+                                 String alt2,
+                                 String alt3)
+    {
+        String[] alternates = { alt1, alt2, alt3 };
+        context.put(name, new VelocityAlternator(alternates));
+        return "";
+    }
+
+    /**
+     * Makes an alternator object that alternates between four values.
+     *
+     * @see #makeAlternator(String name, String alt1, String alt2)
+     */
+    public String makeAlternator(String name, String alt1, String alt2,
+                                 String alt3, String alt4)
+    {
+        String[] alternates = { alt1, alt2, alt3, alt4 };
+        context.put(name, new VelocityAlternator(alternates));
+        return "";
+    }
+
+    /**
+     * Makes an alternator object that alternates between two values
+     * automatically.
+     *
+     * @see #makeAlternator(String name, String alt1, String alt2)
+     */
+    public String makeAutoAlternator(String name, String alt1, String alt2)
+    {
+        String[] alternates = { alt1, alt2 };
+        context.put(name, new VelocityAutoAlternator(alternates));
+        return "";
+    }
+
+    /**
+     * Returns a default value if the object passed is null.
+     */
+    public Object isNull(Object o, Object dflt)
+    {
+        if ( o == null )
+        {
+            return dflt;
+        }
+        else
+        {
+            return o;
+        }
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/AbstractContext.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/AbstractContext.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/AbstractContext.java Tue May 29 15:35:01 2012
@@ -0,0 +1,267 @@
+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 java.io.Serializable;
+
+import org.apache.velocity.context.Context;
+import org.apache.velocity.context.InternalContextBase;
+
+/**
+ *  This class is the abstract base class for all conventional 
+ *  Velocity Context  implementations.  Simply extend this class 
+ *  and implement the abstract routines that access your preferred 
+ *  storage method.
+ *
+ *  Takes care of context chaining.
+ *
+ *  Also handles / enforces policy on null keys and values :
+ *
+ *  <ul>
+ *  <li> Null keys and values are accepted and basically dropped.
+ *  <li> If you place an object into the context with a null key, it
+ *        will be ignored and logged.
+ *  <li> If you try to place a null into the context with any key, it
+ *        will be dropped and logged.
+ *  </ul>
+ *
+ *  The default implementation of this for application use is 
+ *  org.apache.velocity.VelocityContext.
+ *
+ *  All thanks to Fedor for the chaining idea.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:fedor.karpelevitch@home.com">Fedor Karpelevitch</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @version $Id: AbstractContext.java,v 1.8.8.1 2004/03/03 23:22:54 geirm Exp $
+ */
+
+public abstract class AbstractContext extends InternalContextBase 
+    implements Context, Serializable
+{
+    /**
+     *  the chained Context if any
+     */
+    private   Context  innerContext = null;
+  
+    /** 
+     *  Implement to return a value from the context storage. 
+     *  <br><br>
+     *  The implementation of this method is required for proper
+     *  operation of a Context implementation in general
+     *  Velocity use.
+     *  
+     *  @param key key whose associated value is to be returned
+     *  @return object stored in the context
+     */
+    public abstract Object internalGet( String key );
+
+    /** 
+     *  Implement to put a value into the context storage.
+     *  <br><br>
+     *  The implementation of this method is required for 
+     *  proper operation of a Context implementation in
+     *  general Velocity use.
+     *
+     *  @param key key with which to associate the value
+     *  @param value value to be associated with the key
+     *  @return previously stored value if exists, or null
+     */
+    public abstract Object internalPut( String key, Object value );
+
+    /** 
+     *  Implement to determine if a key is in the storage.
+     *  <br><br>
+     *  Currently, this method is not used internally by 
+     *  the Velocity core. 
+     *
+     *   @param key key to test for existance 
+     *   @return true if found, false if not
+     */
+    public abstract boolean internalContainsKey(Object key);
+
+    /** 
+     *  Implement to return an object array of key 
+     *  strings from your storage.
+     *  <br><br>
+     *  Currently, this method is not used internally by
+     *  the Velocity core.
+     *
+     *  @return array of keys
+     */
+    public abstract Object[] internalGetKeys();
+
+    /** 
+     *  I mplement to remove an item from your storage.
+     *  <br><br>
+     *  Currently, this method is not used internally by
+     *  the Velocity core.
+     *
+     *  @param key key to remove
+     *  @return object removed if exists, else null
+     */
+    public abstract Object internalRemove(Object key);
+
+    /**
+     *  default CTOR
+     */
+    public AbstractContext()
+    {
+    }        
+
+    /**
+     *  Chaining constructor accepts a Context argument.
+     *  It will relay get() operations into this Context
+     *  in the even the 'local' get() returns null.
+     *  
+     *  @param inner context to be chained
+     */
+    public AbstractContext( Context inner )
+    {
+        innerContext = inner;
+
+        /*
+         *  now, do a 'forward pull' of event cartridge so
+         *  it's accessable, bringing to the top level.
+         */
+
+        if (innerContext instanceof InternalEventContext )
+        {
+            attachEventCartridge( ( (InternalEventContext) innerContext).getEventCartridge() );
+        }
+    }
+
+    /**
+     * Adds a name/value pair to the context. 
+     * 
+     * @param key   The name to key the provided value with.
+     * @param value The corresponding value.
+     * @return Object that was replaced in the the Context if
+     *         applicable or null if not.
+     */
+    public Object put(String key, Object value)
+    {
+        /*
+         * don't even continue if key or value is null
+         */
+
+        if (key == null)
+        {
+            return null;
+        }
+        else if (value == null)
+        {
+            return null;
+        }
+        
+        return internalPut(key, value);
+    }
+
+    /**
+     *  Gets the value corresponding to the provided key from the context.
+     *
+     *  Supports the chaining context mechanism.  If the 'local' context
+     *  doesn't have the value, we try to get it from the chained context.
+     *
+     *  @param key The name of the desired value.
+     *  @return    The value corresponding to the provided key or null if
+     *             the key param is null.
+     */
+    public Object get(String key)
+    {
+        /*
+         *  punt if key is null
+         */
+
+        if (key == null)
+        {
+            return null;
+        }
+
+        /*
+         *  get the object for this key.  If null, and we are chaining another Context
+         *  call the get() on it.
+         */
+
+        Object o = internalGet( key );
+
+        if (o == null && innerContext != null)
+        {
+            o = innerContext.get( key );
+        }
+            
+        return o;
+    }        
+
+    /**
+     *  Indicates whether the specified key is in the context.  Provided for 
+     *  debugging purposes.
+     *
+     * @param key The key to look for.
+     * @return true if the key is in the context, false if not.
+     */
+    public boolean containsKey(Object key)
+    {
+        if (key == null)
+        {
+            return false;
+        }
+
+        return internalContainsKey(key);
+    }        
+
+    /**
+     *  Get all the keys for the values in the context
+     *  @return Object[] of keys in the Context. Does not return
+     *          keys in chained context.
+     */
+    public Object[] getKeys()
+    {
+        return internalGetKeys();
+    }
+
+    /**
+     * Removes the value associated with the specified key from the context.
+     *
+     * @param key The name of the value to remove.
+     * @return    The value that the key was mapped to, or <code>null</code> 
+     *            if unmapped.
+     */
+    public Object remove(Object key)
+    {
+        if (key == null)
+        {
+            return null;
+        }
+
+        return internalRemove(key);
+    }   
+
+    /**
+     *  returns innerContext if one is chained
+     *
+     *  @return Context if chained, <code>null</code> if not
+     */
+    public Context getChainedContext()
+    {
+        return innerContext;
+    }
+
+}
+
+
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/Context.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/Context.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/Context.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/Context.java Tue May 29 15:35:01 2012
@@ -0,0 +1,74 @@
+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 describing the application data context.  This set of
+ *  routines is used by the application to set and remove 'named' data
+ *  object to pass them to the template engine to use when rendering
+ *  a template.
+ *
+ *  This is the same set of methods supported by the original Context
+ *  class
+ *
+ *  @see org.apache.velocity.context.AbstractContext
+ *  @see org.apache.velocity.VelocityContext
+ *
+ *  @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @version $Id: Context.java,v 1.5.4.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public interface Context
+{
+    /**
+     * Adds a name/value pair to the context.
+     *
+     * @param key   The name to key the provided value with.
+     * @param value The corresponding value.
+     */
+    Object put(String key, Object value);
+
+    /**
+     * Gets the value corresponding to the provided key from the context.
+     *
+     * @param key The name of the desired value.
+     * @return    The value corresponding to the provided key.
+     */
+    Object get(String key);
+ 
+    /**
+     * Indicates whether the specified key is in the context.
+     *
+     * @param key The key to look for.
+     * @return    Whether the key is in the context.
+     */
+    boolean containsKey(Object key);
+
+    /**
+     * Get all the keys for the values in the context
+     */
+    Object[] getKeys();
+
+    /**
+     * Removes the value associated with the specified key from the context.
+     *
+     * @param key The name of the value to remove.
+     * @return    The value that the key was mapped to, or <code>null</code> 
+     *            if unmapped.
+     */
+    Object remove(Object key);
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapter.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapter.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapter.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapter.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 to bring all necessary internal and user contexts together.
+ *  this is what the AST expects to deal with.  If anything new comes
+ *  along, add it here.
+ *
+ *  I will rename soon :)
+ *
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @version $Id: InternalContextAdapter.java,v 1.5.4.1 2004/03/03 23:22:54 geirm Exp $
+ */
+
+public interface InternalContextAdapter 
+    extends InternalHousekeepingContext, Context, InternalWrapperContext, InternalEventContext
+{
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java Tue May 29 15:35:01 2012
@@ -0,0 +1,226 @@
+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.app.event.EventCartridge;
+
+import org.apache.velocity.runtime.resource.Resource;
+
+/**
+ *  This adapter class is the container for all context types for internal
+ *  use.  The AST now uses this class rather than the app-level Context
+ *  interface to allow flexibility in the future.
+ *
+ *  Currently, we have two context interfaces which must be supported :
+ *  <ul>
+ *  <li> Context : used for application/template data access
+ *  <li> InternalHousekeepingContext : used for internal housekeeping and caching
+ *  <li> InternalWrapperContext : used for getting root cache context and other
+ *       such.
+ *  <li> InternalEventContext : for event handling.
+ *  </ul>
+ *
+ *  This class implements the two interfaces to ensure that all methods are 
+ *  supported.  When adding to the interfaces, or adding more context 
+ *  functionality, the interface is the primary definition, so alter that first
+ *  and then all classes as necessary.  As of this writing, this would be 
+ *  the only class affected by changes to InternalContext
+ *
+ *  This class ensures that an InternalContextBase is available for internal
+ *  use.  If an application constructs their own Context-implementing
+ *  object w/o subclassing AbstractContext, it may be that support for
+ *  InternalContext is not available.  Therefore, InternalContextAdapter will
+ *  create an InternalContextBase if necessary for this support.  Note that 
+ *  if this is necessary, internal information such as node-cache data will be
+ *  lost from use to use of the context.  This may or may not be important,
+ *  depending upon application.
+ * 
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: InternalContextAdapterImpl.java,v 1.8.12.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public final class InternalContextAdapterImpl implements InternalContextAdapter
+{
+    /**  
+     *  the user data Context that we are wrapping 
+     */
+    Context context = null;
+    
+    /** 
+     *  the ICB we are wrapping.  We may need to make one
+     *  if the user data context implementation doesn't
+     *  support one.  The default AbstractContext-derived
+     *  VelocityContext does, and it's recommended that 
+     *  people derive new contexts from AbstractContext
+     *  rather than piecing things together
+     */
+    InternalHousekeepingContext icb = null;
+
+    /**
+     *  The InternalEventContext that we are wrapping.  If
+     *  the context passed to us doesn't support it, no
+     *  biggie.  We don't make it for them - since its a 
+     *  user context thing, nothing gained by making one
+     *  for them now
+     */
+    InternalEventContext iec = null;
+
+    /**
+     *  CTOR takes a Context and wraps it, delegating all 'data' calls 
+     *  to it.
+     * 
+     *  For support of internal contexts, it will create an InternalContextBase
+     *  if need be.
+     */
+    public InternalContextAdapterImpl( Context c )
+    {
+        context = c;
+
+        if ( !( c instanceof InternalHousekeepingContext ))
+        {
+            icb = new InternalContextBase();
+        }
+        else
+        {
+            icb = (InternalHousekeepingContext) context;
+        }
+
+        if ( c instanceof InternalEventContext)
+        {
+            iec = ( InternalEventContext) context;
+        }
+    }
+
+    /* --- InternalHousekeepingContext interface methods --- */
+
+    public void pushCurrentTemplateName( String s )
+    {
+        icb.pushCurrentTemplateName( s );
+    }
+
+    public void popCurrentTemplateName()
+    {
+        icb.popCurrentTemplateName();
+    }
+  
+    public String getCurrentTemplateName()
+    {
+        return icb.getCurrentTemplateName();
+    }
+
+    public Object[] getTemplateNameStack()
+    {
+        return icb.getTemplateNameStack();
+    }
+
+    public IntrospectionCacheData icacheGet( Object key )
+    {
+        return icb.icacheGet( key );
+    }
+    
+    public void icachePut( Object key, IntrospectionCacheData o )
+    {
+        icb.icachePut( key, o );
+    }
+
+   public void setCurrentResource( Resource r )
+    {
+        icb.setCurrentResource(r);
+    }
+
+    public Resource getCurrentResource()
+    {
+        return icb.getCurrentResource();
+    }
+
+
+    /* ---  Context interface methods --- */
+
+    public Object put(String key, Object value)
+    {
+        return context.put( key , value );
+    }
+
+    public Object get(String key)
+    {
+        return context.get( key );
+    }
+
+    public boolean containsKey(Object key)
+    {
+        return context.containsKey( key );
+    }
+
+    public Object[] getKeys()
+    {
+        return context.getKeys();
+    }
+
+    public Object remove(Object key)
+    {
+        return context.remove( key );
+    }
+
+
+    /* ---- InternalWrapperContext --- */
+
+    /**
+     *  returns the user data context that
+     *  we are wrapping
+     */
+    public Context getInternalUserContext()
+    {
+        return context;
+    }
+
+    /**
+     *  Returns the base context that we are 
+     *  wrapping. Here, its this, but for other thing
+     *  like VM related context contortions, it can
+     *  be something else
+     */
+    public InternalContextAdapter getBaseContext()
+    {
+        return this;
+    }
+
+    /* -----  InternalEventContext ---- */
+
+    public EventCartridge attachEventCartridge( EventCartridge ec )
+    {
+        if (iec != null)
+        {
+            return iec.attachEventCartridge( ec );
+        }
+
+        return null;
+    }
+
+    public EventCartridge getEventCartridge()
+    {
+        if ( iec != null)
+        {
+            return iec.getEventCartridge( );
+        }
+
+        return null;
+    }
+}
+
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextBase.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextBase.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextBase.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalContextBase.java Tue May 29 15:35:01 2012
@@ -0,0 +1,157 @@
+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 java.util.HashMap;
+import java.util.Stack;
+import java.io.Serializable;
+
+import org.apache.velocity.util.introspection.IntrospectionCacheData;
+
+import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.runtime.resource.Resource;
+
+/**
+ *  class 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.
+ *
+ *  Note that this is not a public class.  It is for package access only to
+ *  keep application code from accessing the internals, as AbstractContext
+ *  is derived from this.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: InternalContextBase.java,v 1.8.12.1 2004/03/03 23:22:54 geirm Exp $
+ */
+class InternalContextBase implements InternalHousekeepingContext, InternalEventContext,  Serializable
+{
+    /**
+     *  cache for node/context specific introspection information
+     */
+    private HashMap introspectionCache = new HashMap(33);
+    
+    /**
+     *  Template name stack. The stack top contains the current template name.
+     */
+    private Stack templateNameStack = new Stack();
+
+    /**
+     *  EventCartridge we are to carry.  Set by application
+     */
+    private EventCartridge eventCartridge = null;
+
+    /**
+     *  Current resource - used for carrying encoding and other
+     *  information down into the rendering process
+     */
+    private Resource currentResource = null;
+
+    /**
+     *  set the current template name on top of stack
+     *
+     *  @param s current template name
+     */
+    public void pushCurrentTemplateName( String s )
+    {
+        templateNameStack.push(s);
+        return;
+    }
+
+    /**
+     *  remove the current template name from stack
+     */
+    public void popCurrentTemplateName()
+    {
+        templateNameStack.pop();
+        return;
+    }
+     
+    /**
+     *  get the current template name
+     *
+     *  @return String current template name
+     */
+    public String getCurrentTemplateName()
+    {
+        if ( templateNameStack.empty() )
+            return "<undef>";
+        else
+            return (String) templateNameStack.peek();
+    }
+
+    /**
+     *  get the current template name stack
+     *
+     *  @return Object[] with the template name stack contents.
+     */
+    public Object[] getTemplateNameStack()
+    {
+        return templateNameStack.toArray();
+    }
+
+    /**
+     *  returns an IntrospectionCache Data (@see IntrospectionCacheData)
+     *  object if exists for the key
+     *
+     *  @param key  key to find in cache
+     *  @return cache object
+     */
+    public IntrospectionCacheData icacheGet( Object key )
+    {
+        return ( IntrospectionCacheData ) introspectionCache.get( 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
+     */
+    public void icachePut( Object key, IntrospectionCacheData o )
+    {
+        introspectionCache.put( key, o );
+    }
+
+    public void setCurrentResource( Resource r )
+    {
+        currentResource = r;
+    }
+
+    public Resource getCurrentResource()
+    {
+        return currentResource;
+    }
+
+    public EventCartridge attachEventCartridge( EventCartridge ec )
+    {
+        EventCartridge temp = eventCartridge;
+
+        eventCartridge = ec;
+        
+        return temp;
+    }
+
+    public EventCartridge getEventCartridge()
+    {
+        return eventCartridge;
+    }
+}
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalEventContext.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalEventContext.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalEventContext.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/context/InternalEventContext.java Tue May 29 15:35:01 2012
@@ -0,0 +1,35 @@
+
+
+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.app.event.EventCartridge;
+
+/**
+ *  Interface for event support.  Note that this is a public internal
+ *  interface, as it is something that will be accessed from outside 
+ *  of the .context package.
+ *
+ *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ *  @version $Id: InternalEventContext.java,v 1.2.12.1 2004/03/03 23:22:54 geirm Exp $
+ */
+public interface InternalEventContext
+{
+    public EventCartridge attachEventCartridge( EventCartridge ec);
+    public EventCartridge getEventCartridge();
+}

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