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 [9/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/runtime/parser/node/ASTNENode.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNENode.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNENode.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNENode.java Tue May 29 15:35:01 2012
@@ -0,0 +1,96 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.context.InternalContextAdapter;
+import org.apache.velocity.runtime.parser.Parser;
+
+import org.apache.velocity.exception.MethodInvocationException;
+
+public class ASTNENode extends SimpleNode
+{
+    public ASTNENode(int id)
+    {
+        super(id);
+    }
+
+    public ASTNENode(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+
+    public boolean evaluate(  InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        Object left = jjtGetChild(0).value( context );
+        Object right = jjtGetChild(1).value( context );
+
+        /*
+         *  null check
+         */
+
+        if ( left == null || right == null)
+        {
+            rsvc.error( ( left == null ? "Left" : "Right" ) + " side ("
+                           + jjtGetChild( (left == null? 0 : 1) ).literal()
+                           + ") of '!=' operation has null value."
+                           + " Operation not possible. "
+                           + context.getCurrentTemplateName() + " [line " + getLine() 
+                           + ", column " + getColumn() + "]");
+            return false;
+
+        }
+
+
+        /*
+         *  check to see if they are the same class.  I don't think this is slower
+         *  as I don't think that getClass() results in object creation, and we can
+         *  extend == to handle all classes
+         */
+
+        if (left.getClass().equals( right.getClass() ) )
+        {
+            return !(left.equals( right ));
+        }
+        else
+        {
+            rsvc.error("Error in evaluation of != expression."
+                          + " Both arguments must be of the same Class."
+                          + " Currently left = " + left.getClass() + ", right = " 
+                          + right.getClass() + ". "
+                          + context.getCurrentTemplateName() + " [line " + getLine() 
+                          + ", column " + getColumn() + "] (ASTEQNode)");
+            
+            return false;
+        }
+    }
+
+    public Object value(InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        boolean val = evaluate(context);
+
+        return val ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java Tue May 29 15:35:01 2012
@@ -0,0 +1,56 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.context.InternalContextAdapter;
+import org.apache.velocity.runtime.parser.*;
+
+import org.apache.velocity.exception.MethodInvocationException;
+
+public class ASTNotNode extends SimpleNode
+{
+    public ASTNotNode(int id)
+    {
+        super(id);
+    }
+
+    public ASTNotNode(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+
+    public boolean evaluate( InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        if (jjtGetChild(0).evaluate(context))
+            return false;
+        else
+            return true;
+    }
+
+    public Object value( InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        return (jjtGetChild(0).evaluate( context ) ? Boolean.FALSE : Boolean.TRUE) ;
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTObjectArray.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTObjectArray.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTObjectArray.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTObjectArray.java Tue May 29 15:35:01 2012
@@ -0,0 +1,59 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.util.ArrayList;
+
+import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.runtime.parser.Parser;
+
+import org.apache.velocity.exception.MethodInvocationException;
+
+public class ASTObjectArray extends SimpleNode
+{
+    public ASTObjectArray(int id)
+    {
+        super(id);
+    }
+
+    public ASTObjectArray(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+
+    public Object value( InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        int size = jjtGetNumChildren();
+
+        ArrayList objectArray = new ArrayList();
+
+        for (int i = 0; i < size; i++)
+        {
+            objectArray.add(  jjtGetChild(i).value(context) );
+        }            
+        
+        return objectArray;
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java Tue May 29 15:35:01 2012
@@ -0,0 +1,96 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.runtime.parser.Parser;
+import org.apache.velocity.context.InternalContextAdapter;
+
+import org.apache.velocity.exception.MethodInvocationException;
+
+/**
+ * Please look at the Parser.jjt file which is
+ * what controls the generation of this class.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ASTOrNode.java,v 1.6.8.1 2004/03/03 23:22:59 geirm Exp $ 
+*/
+public class ASTOrNode extends SimpleNode
+{
+    public ASTOrNode(int id)
+    {
+        super(id);
+    }
+
+    public ASTOrNode(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+
+    /**
+     *  Returns the value of the expression.
+     *  Since the value of the expression is simply the boolean
+     *  result of evaluate(), lets return that.
+     */
+    public Object value(InternalContextAdapter context )
+        throws MethodInvocationException
+    {
+        return new Boolean( evaluate( context ) );
+    }
+
+    /**
+     *  the logical or :
+     *    the rule :
+     *      left || null -> left
+     *      null || right -> right
+     *      null || null -> false
+     *      left || right ->  left || right
+     */
+    public boolean evaluate( InternalContextAdapter context)
+        throws MethodInvocationException
+    {
+        Node left = jjtGetChild(0);
+        Node right = jjtGetChild(1);
+
+        /*
+         *  if the left is not null and true, then true
+         */
+        
+        if (left != null && left.evaluate( context ) )
+            return true;
+
+        /*
+         *  same for right
+         */
+
+        if ( right != null && right.evaluate( context ) )
+            return true;
+
+        return false;
+    }
+}
+
+
+
+
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTParameters.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTParameters.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTParameters.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTParameters.java Tue May 29 15:35:01 2012
@@ -0,0 +1,38 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.runtime.parser.Parser;
+
+public class ASTParameters extends SimpleNode
+{
+    public ASTParameters(int id)
+    {
+        super(id);
+    }
+
+    public ASTParameters(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTTrue.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTTrue.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTTrue.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTTrue.java Tue May 29 15:35:01 2012
@@ -0,0 +1,51 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.context.InternalContextAdapter;
+import org.apache.velocity.runtime.parser.Parser;
+
+public class ASTTrue extends SimpleNode
+{
+    private static Boolean value = Boolean.TRUE;
+
+    public ASTTrue(int id)
+    {
+        super(id);
+    }
+
+    public ASTTrue(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+
+    public boolean evaluate(InternalContextAdapter context)
+    {
+        return true;
+    }        
+
+    public Object value(InternalContextAdapter context)
+    {
+        return value;
+    }        
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTVariable.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTVariable.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTVariable.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTVariable.java Tue May 29 15:35:01 2012
@@ -0,0 +1,38 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.runtime.parser.Parser;
+
+public class ASTVariable extends SimpleNode
+{
+    public ASTVariable(int id)
+    {
+        super(id);
+    }
+
+    public ASTVariable(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTprocess.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTprocess.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTprocess.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ASTprocess.java Tue May 29 15:35:01 2012
@@ -0,0 +1,38 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.velocity.runtime.parser.Parser;
+
+public class ASTprocess extends SimpleNode
+{
+    public ASTprocess(int id)
+    {
+        super(id);
+    }
+
+    public ASTprocess(Parser p, int id)
+    {
+        super(p, id);
+    }
+
+    /** Accept the visitor. **/
+    public Object jjtAccept(ParserVisitor visitor, Object data)
+    {
+        return visitor.visit(this, data);
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/AbstractExecutor.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/AbstractExecutor.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/AbstractExecutor.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/AbstractExecutor.java Tue May 29 15:35:01 2012
@@ -0,0 +1,62 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.velocity.runtime.RuntimeLogger;
+
+/**
+ * Abstract class that is used to execute an arbitrary
+ * method that is in introspected. This is the superclass
+ * for the GetExecutor and PropertyExecutor.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
+ * @version $Id: AbstractExecutor.java,v 1.12.4.1 2004/03/03 23:22:59 geirm Exp $
+ */
+public abstract class AbstractExecutor
+{
+    protected RuntimeLogger rlog = null;
+    
+    /**
+     * Method to be executed.
+     */
+    protected Method method = null;
+    
+    /**
+     * Execute method against context.
+     */
+     public abstract Object execute(Object o)
+         throws IllegalAccessException, InvocationTargetException;
+
+    /**
+     * Tell whether the executor is alive by looking
+     * at the value of the method.
+     */
+    public boolean isAlive()
+    {
+        return (method != null);
+    }
+
+    public Method getMethod()
+    {
+        return method;
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java Tue May 29 15:35:01 2012
@@ -0,0 +1,85 @@
+package org.apache.velocity.runtime.parser.node;
+/*
+ * 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.velocity.util.introspection.Introspector;
+
+import org.apache.velocity.runtime.RuntimeLogger;
+
+/**
+ *  Handles discovery and valuation of a
+ *  boolean object property, of the
+ *  form public boolean is<property> when executed.
+ *
+ *  We do this separately as to preserve the current
+ *  quasi-broken semantics of get<as is property>
+ *  get< flip 1st char> get("property") and now followed
+ *  by is<Property>
+ *
+ *  @author <a href="geirm@apache.org">Geir Magnusson Jr.</a>
+ *  @version $Id: BooleanPropertyExecutor.java,v 1.3.4.1 2004/03/03 23:22:59 geirm Exp $
+ */
+public class BooleanPropertyExecutor extends PropertyExecutor
+{
+    public BooleanPropertyExecutor(RuntimeLogger rlog, Introspector is, Class clazz, String property)
+    {
+        super(rlog, is, clazz, property);
+    }
+
+    protected void discover(Class clazz, String property)
+    {
+        try
+        {
+            char c;
+            StringBuffer sb;
+
+            Object[] params = {  };
+
+            /*
+             *  now look for a boolean isFoo
+             */
+
+            sb = new StringBuffer("is");
+            sb.append(property);
+
+            c = sb.charAt(2);
+
+            if (Character.isLowerCase(c))
+            {
+                sb.setCharAt(2, Character.toUpperCase(c));
+            }
+
+            methodUsed = sb.toString();
+            method = introspector.getMethod(clazz, methodUsed, params);
+
+            if (method != null)
+            {
+                /*
+                 *  now, this has to return a boolean
+                 */
+
+                if (method.getReturnType() == Boolean.TYPE)
+                    return;
+
+                method = null;
+            }
+        }
+        catch(Exception e)
+        {
+            rlog.error("PROGRAMMER ERROR : BooleanPropertyExector() : " + e);
+        }
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java Tue May 29 15:35:01 2012
@@ -0,0 +1,109 @@
+package org.apache.velocity.runtime.parser.node;
+/*
+ * 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.velocity.context.InternalContextAdapter;
+import org.apache.velocity.util.introspection.Introspector;
+
+import java.lang.reflect.InvocationTargetException;
+import org.apache.velocity.exception.MethodInvocationException;
+
+import org.apache.velocity.runtime.RuntimeLogger;
+
+
+/**
+ * Executor that simply tries to execute a get(key)
+ * operation. This will try to find a get(key) method
+ * for any type of object, not just objects that
+ * implement the Map interface as was previously
+ * the case.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @version $Id: GetExecutor.java,v 1.8.4.1 2004/03/03 23:22:59 geirm Exp $
+ */
+public class GetExecutor extends AbstractExecutor
+{
+    /**
+     * Container to hold the 'key' part of 
+     * get(key).
+     */
+    private Object[] args = new Object[1];
+    
+    /**
+     * Default constructor.
+     */
+    public GetExecutor(RuntimeLogger r, Introspector ispect, Class c, String key)
+        throws Exception
+    {
+        rlog = r;
+        args[0] = key;
+        method = ispect.getMethod(c, "get", args);
+    }
+
+    /**
+     * Execute method against context.
+     */
+    public Object execute(Object o)
+        throws IllegalAccessException, InvocationTargetException
+    {
+        if (method == null)
+            return null;
+
+        return method.invoke(o, args);
+    }
+
+    /**
+     * Execute method against context.
+     */
+    public Object OLDexecute(Object o, InternalContextAdapter context)
+        throws IllegalAccessException, MethodInvocationException
+    {
+        if (method == null)
+            return null;
+     
+        try 
+        {
+            return method.invoke(o, args);  
+        }
+        catch(InvocationTargetException ite)
+        {
+            /*
+             *  the method we invoked threw an exception.
+             *  package and pass it up
+             */
+
+            throw  new MethodInvocationException( 
+                "Invocation of method 'get(\"" + args[0] + "\")'" 
+                + " in  " + o.getClass() 
+                + " threw exception " 
+                + ite.getTargetException().getClass(), 
+                ite.getTargetException(), "get");
+        }
+        catch(IllegalArgumentException iae)
+        {
+            return null;
+        }
+    }
+}
+
+
+
+
+
+
+
+
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java Tue May 29 15:35:01 2012
@@ -0,0 +1,190 @@
+package org.apache.velocity.runtime.parser.node;
+/*
+ * 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.velocity.context.Context;
+import org.apache.velocity.runtime.parser.*;
+
+/**
+ * Utilities for dealing with the AST node structure.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: NodeUtils.java,v 1.16.4.1 2004/03/03 23:22:59 geirm Exp $
+ */
+public class NodeUtils
+{
+    /**
+     * Collect all the <SPECIAL_TOKEN>s that
+     * are carried along with a token. Special
+     * tokens do not participate in parsing but
+     * can still trigger certain lexical actions.
+     * In some cases you may want to retrieve these
+     * special tokens, this is simply a way to
+     * extract them.
+     */
+    public static String specialText(Token t)
+    {
+        String specialText = "";
+        
+        if (t.specialToken == null || t.specialToken.image.startsWith("##") )
+            return specialText;
+            
+        Token tmp_t = t.specialToken;
+
+        while (tmp_t.specialToken != null)
+        {
+            tmp_t = tmp_t.specialToken;
+        }
+
+        while (tmp_t != null)
+        {
+            String st = tmp_t.image;
+
+            StringBuffer sb = new StringBuffer();
+
+            for(int i = 0; i < st.length(); i++)
+            {
+                char c = st.charAt(i);
+
+                if ( c == '#' || c == '$' )
+                {
+                    sb.append( c );
+                }
+
+                /*
+                 *  more dreaded MORE hack :)
+                 * 
+                 *  looking for ("\\")*"$" sequences
+                 */
+
+                if ( c == '\\')
+                {
+                    boolean ok = true;
+                    boolean term = false;
+
+                    int j = i;
+                    for( ok = true; ok && j < st.length(); j++)
+                    {
+                        char cc = st.charAt( j );
+                 
+                        if (cc == '\\')
+                        {
+                            /*
+                             *  if we see a \, keep going
+                             */
+                            continue;
+                        }
+                        else if( cc == '$' )
+                        {
+                            /*
+                             *  a $ ends it correctly
+                             */
+                            term = true;
+                            ok = false;
+                        }
+                        else
+                        {
+                            /*
+                             *  nah...
+                             */
+                            ok = false;
+                        }
+                    }
+
+                    if (term)
+                    {
+                        String foo =  st.substring( i, j );
+                        sb.append( foo );
+                        i = j;
+                    }
+                }
+            }
+            
+            specialText += sb.toString();
+
+            tmp_t = tmp_t.next;
+        }            
+
+        return specialText;
+    }
+    
+    /**
+     *  complete node literal
+     *
+     */
+    public static String tokenLiteral( Token t )
+    {
+        return specialText( t ) + t.image;
+    }
+    
+    /**
+     * Utility method to interpolate context variables
+     * into string literals. So that the following will
+     * work:
+     *
+     * #set $name = "candy"
+     * $image.getURI("${name}.jpg")
+     *
+     * And the string literal argument will
+     * be transformed into "candy.jpg" before
+     * the method is executed.
+     */
+    public static String interpolate(String argStr, Context vars)
+    {
+        StringBuffer argBuf = new StringBuffer();
+
+        for (int cIdx = 0 ; cIdx < argStr.length();)
+        {
+            char ch = argStr.charAt(cIdx);
+
+            switch (ch)
+            {
+                case '$':
+                    StringBuffer nameBuf = new StringBuffer();
+                    for (++cIdx ; cIdx < argStr.length(); ++cIdx)
+                    {
+                        ch = argStr.charAt(cIdx);
+                        if (ch == '_' || ch == '-' 
+                            || Character.isLetterOrDigit(ch))
+                            nameBuf.append(ch);
+                        else if (ch == '{' || ch == '}')
+                            continue;  
+                        else
+                            break;
+                    }
+
+                    if (nameBuf.length() > 0)
+                    {
+                        Object value = vars.get(nameBuf.toString());
+
+                        if (value == null)
+                            argBuf.append("$").append(nameBuf.toString());
+                        else
+                            argBuf.append(value.toString());
+                    }
+                    break;
+
+                default:
+                    argBuf.append(ch);
+                    ++cIdx;
+                    break;
+            }
+        }
+
+        return argBuf.toString();
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java Tue May 29 15:35:01 2012
@@ -0,0 +1,56 @@
+package org.apache.velocity.runtime.parser.node;
+
+/*
+ * 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.
+ */
+
+public interface ParserVisitor
+{
+  public Object visit(SimpleNode node, Object data);
+  public Object visit(ASTprocess node, Object data);
+  public Object visit(ASTComment node, Object data);
+  public Object visit(ASTNumberLiteral node, Object data);
+  public Object visit(ASTStringLiteral node, Object data);
+  public Object visit(ASTIdentifier node, Object data);
+  public Object visit(ASTWord node, Object data);
+  public Object visit(ASTDirective node, Object data);
+  public Object visit(ASTBlock node, Object data);
+  public Object visit(ASTObjectArray node, Object data);
+  public Object visit(ASTMethod node, Object data);
+  public Object visit(ASTReference node, Object data);
+  public Object visit(ASTTrue node, Object data);
+  public Object visit(ASTFalse node, Object data);
+  public Object visit(ASTText node, Object data);
+  public Object visit(ASTIfStatement node, Object data);
+  public Object visit(ASTElseStatement node, Object data);
+  public Object visit(ASTElseIfStatement node, Object data);
+  public Object visit(ASTSetDirective node, Object data);
+  public Object visit(ASTExpression node, Object data);
+  public Object visit(ASTAssignment node, Object data);
+  public Object visit(ASTOrNode node, Object data);
+  public Object visit(ASTAndNode node, Object data);
+  public Object visit(ASTEQNode node, Object data);
+  public Object visit(ASTNENode node, Object data);
+  public Object visit(ASTLTNode node, Object data);
+  public Object visit(ASTGTNode node, Object data);
+  public Object visit(ASTLENode node, Object data);
+  public Object visit(ASTGENode node, Object data);
+  public Object visit(ASTAddNode node, Object data);
+  public Object visit(ASTSubtractNode node, Object data);
+  public Object visit(ASTMulNode node, Object data);
+  public Object visit(ASTDivNode node, Object data);
+  public Object visit(ASTModNode node, Object data);
+  public Object visit(ASTNotNode node, Object data);
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java Tue May 29 15:35:01 2012
@@ -0,0 +1,115 @@
+package org.apache.velocity.runtime.parser.node;
+/*
+ * Copyright 2000-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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.velocity.util.introspection.Introspector;
+
+import org.apache.velocity.runtime.RuntimeLogger;
+
+/**
+ * Returned the value of object property when executed.
+ */
+public class PropertyExecutor extends AbstractExecutor
+{
+    protected Introspector introspector = null;
+
+    protected String methodUsed = null;
+
+    public PropertyExecutor(RuntimeLogger r, Introspector ispctr,
+                            Class clazz, String property)
+    {
+        rlog = r;
+        introspector = ispctr;
+
+        discover(clazz, property);
+    }
+
+    protected void discover(Class clazz, String property)
+    {
+        /*
+         *  this is gross and linear, but it keeps it straightforward.
+         */
+
+        try
+        {
+            char c;
+            StringBuffer sb;
+
+            Object[] params = {  };
+
+            /*
+             *  start with get<property>
+             *  this leaves the property name 
+             *  as is...
+             */
+            sb = new StringBuffer("get");
+            sb.append(property);
+
+            methodUsed = sb.toString();
+
+            method = introspector.getMethod(clazz, methodUsed, params);
+             
+            if (method != null)
+                return;
+        
+            /*
+             *  now the convenience, flip the 1st character
+             */
+         
+            sb = new StringBuffer("get");
+            sb.append(property);
+
+            c = sb.charAt(3);
+
+            if (Character.isLowerCase(c))
+            {
+                sb.setCharAt(3, Character.toUpperCase(c));
+            }
+            else
+            {
+                sb.setCharAt(3, Character.toLowerCase(c));
+            }
+
+            methodUsed = sb.toString();
+            method = introspector.getMethod(clazz, methodUsed, params);
+
+            if (method != null)
+                return; 
+            
+        }
+        catch(Exception e)
+        {
+            rlog.error("PROGRAMMER ERROR : PropertyExector() : " + e );
+        }
+    }
+
+
+    /**
+     * Execute method against context.
+     */
+    public Object execute(Object o)
+        throws IllegalAccessException,  InvocationTargetException
+    {
+        if (method == null)
+            return null;
+
+        return method.invoke(o, null);
+    }
+}
+
+

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java Tue May 29 15:35:01 2012
@@ -0,0 +1,97 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.StringWriter;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+/**
+ * This class represent a general text resource that may have been
+ * retrieved from any number of possible sources.
+ *
+ * Also of interest is Velocity's {@link org.apache.velocity.Template}
+ * <code>Resource</code>.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ContentResource.java,v 1.10.4.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public class ContentResource extends Resource
+{
+    /** Default empty constructor */
+    public ContentResource()
+    {
+    }
+    
+    /**
+     * Pull in static content and store it.
+     *
+     * @exception ResourceNotFoundException Resource could not be
+     * found.
+     */
+    public boolean process()
+        throws ResourceNotFoundException
+    {
+        BufferedReader reader = null;
+
+        try
+        {
+            StringWriter sw = new StringWriter();
+            
+            reader = new BufferedReader(
+                new InputStreamReader(resourceLoader.getResourceStream(name),
+                                      encoding));
+            
+            char buf[] = new char[1024];
+            int len = 0;
+            
+            while ( ( len = reader.read( buf, 0, 1024 )) != -1)
+                sw.write( buf, 0, len );
+        
+            setData(sw.toString());
+           
+            return true;
+        }
+        catch ( ResourceNotFoundException e )
+        {
+            // Tell the ContentManager to continue to look through any
+            // remaining configured ResourceLoaders.
+            throw e;
+        }
+        catch ( Exception e ) 
+        {
+            rsvc.error("Cannot process content resource : " + e.toString() );
+            return false;
+        }
+        finally
+        {
+            if (reader != null)
+            {
+                try
+                {
+                    reader.close();
+                }
+                catch (Exception ignored)
+                {
+                }
+            }
+        }
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/Resource.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/Resource.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/Resource.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/Resource.java Tue May 29 15:35:01 2012
@@ -0,0 +1,248 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+import org.apache.velocity.runtime.resource.loader.ResourceLoader;
+
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.ParseErrorException;
+
+/**
+ * This class represent a general text resource that
+ * may have been retrieved from any number of possible
+ * sources.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: Resource.java,v 1.12.4.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public abstract class Resource
+{
+    protected RuntimeServices rsvc = null;
+
+    /**
+     * The template loader that initially loaded the input
+     * stream for this template, and knows how to check the
+     * source of the input stream for modification.
+     */
+    protected ResourceLoader resourceLoader;
+
+    /**
+     * The number of milliseconds in a minute, used to calculate the
+     * check interval.
+     */
+    protected static final long MILLIS_PER_SECOND =  1000;
+
+    /**
+     * How often the file modification time is checked (in seconds).
+     */
+    protected long modificationCheckInterval = 0;
+
+    /**
+     * The file modification time (in milliseconds) for the cached template.
+     */
+    protected long lastModified = 0;
+
+    /**
+     * The next time the file modification time will be checked (in 
+     * milliseconds).
+     */
+    protected long nextCheck = 0;
+
+    /**
+     *  Name of the resource
+     */
+    protected String name;
+
+    /**
+     *  Character encoding of this resource
+     */
+    protected String encoding = RuntimeConstants.ENCODING_DEFAULT;
+
+    /** 
+     *  Resource might require ancillary storage of some kind 
+     */
+    protected Object data = null;
+
+    /** 
+     *  Default constructor 
+     */
+    public Resource()
+    {
+    }
+
+    public void setRuntimeServices( RuntimeServices rs )
+    {
+        rsvc = rs;
+    }
+
+    /**
+     * Perform any subsequent processing that might need
+     * to be done by a resource. In the case of a template
+     * the actual parsing of the input stream needs to be
+     * performed.
+     *
+     * @return Whether the resource could be processed successfully.
+     * For a {@link org.apache.velocity.Template} or {@link
+     * org.apache.velocity.runtime.resource.ContentResource}, this
+     * indicates whether the resource could be read.
+     * @exception ResourceNotFoundException Similar in semantics as
+     * returning <code>false</code>.
+     */
+    public abstract boolean process() 
+        throws ResourceNotFoundException, ParseErrorException, Exception;
+
+    public boolean isSourceModified()
+    {
+        return resourceLoader.isSourceModified(this);
+    }
+
+    /**
+     * Set the modification check interval.
+     * @param interval The interval (in seconds).
+     */
+    public void setModificationCheckInterval(long modificationCheckInterval)
+    {
+        this.modificationCheckInterval = modificationCheckInterval;
+    }
+    
+    /**
+     * Is it time to check to see if the resource
+     * source has been updated?
+     */
+    public boolean requiresChecking()
+    {
+        /*
+         *  short circuit this if modificationCheckInterval == 0
+         *  as this means "don't check"
+         */
+        
+        if (modificationCheckInterval <= 0 )
+        {
+           return false;
+        }
+
+        /*
+         *  see if we need to check now
+         */
+
+        return ( System.currentTimeMillis() >= nextCheck );
+    }
+
+    /**
+     * 'Touch' this template and thereby resetting
+     * the nextCheck field.
+     */
+    public void touch()
+    {
+        nextCheck = System.currentTimeMillis() + ( MILLIS_PER_SECOND *  modificationCheckInterval);
+    }
+    
+    /**
+     * Set the name of this resource, for example
+     * test.vm.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }        
+
+    /**
+     * Get the name of this template.
+     */
+    public String getName()
+    {
+        return name;
+    }        
+
+    /**
+     *  set the encoding of this resource
+     *  for example, "ISO-8859-1"
+     */
+    public void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    /**
+     *  get the encoding of this resource
+     *  for example, "ISO-8859-1"
+     */
+    public String getEncoding()
+    {
+        return encoding;
+    }
+
+
+    /**
+     * Return the lastModifed time of this
+     * template.
+     */
+    public long getLastModified()
+    {
+        return lastModified;
+    }        
+    
+    /**
+     * Set the last modified time for this
+     * template.
+     */
+    public void setLastModified(long lastModified)
+    {
+        this.lastModified = lastModified;
+    }        
+
+    /**
+     * Return the template loader that pulled
+     * in the template stream
+     */
+    public ResourceLoader getResourceLoader()
+    {
+        return resourceLoader;
+    }
+    
+    /**
+     * Set the template loader for this template. Set
+     * when the Runtime determines where this template
+     * came from the list of possible sources.
+     */
+    public void setResourceLoader(ResourceLoader resourceLoader)
+    {
+        this.resourceLoader = resourceLoader;
+    }        
+
+    /** 
+     * Set arbitrary data object that might be used
+     * by the resource.
+     */
+    public void setData(Object data)
+    {
+        this.data = data;
+    }
+    
+    /**
+     * Get arbitrary data object that might be used
+     * by the resource.
+     */
+    public Object getData()
+    {
+        return data;
+    }        
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCache.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCache.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCache.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCache.java Tue May 29 15:35:01 2012
@@ -0,0 +1,69 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.util.Iterator;
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Interface that defines the shape of a pluggable resource cache
+ *  for the included ResourceManager
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ResourceCache.java,v 1.1.8.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public interface ResourceCache
+{
+    /**
+     *  initializes the ResourceCache.  Will be 
+     *  called before any utilization
+     *
+     *  @param rs RuntimeServices to use for logging, etc
+     */
+    public void initialize( RuntimeServices rs );
+    
+    /**
+     *  retrieves a Resource from the
+     *  cache
+     *
+     *  @param resourceKey key for Resource to be retrieved
+     *  @return Resource specified or null if not found
+     */
+    public Resource get( Object resourceKey );
+    
+    /**
+     *  stores a Resource in the cache
+     *
+     *  @param resourceKey key to associate with the Resource
+     *  @param resource Resource to be stored
+     *  @return existing Resource stored under this key, or null if none
+     */
+    public Resource put( Object resourceKey, Resource resource );
+ 
+    /**
+     *  removes a Resource from the cache
+     *
+     *  @param resourceKey resource to be removed
+     *  @param Resource stored under key
+     */
+    public Resource remove( Object resourceKey );
+    
+    /**
+     *  returns an Iterator of Keys in the cache
+     */
+     public Iterator enumerateKeys();
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java Tue May 29 15:35:01 2012
@@ -0,0 +1,71 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.util.Hashtable;
+import java.util.Map;
+import java.util.Iterator;
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Default implementation of the resource cache for the default
+ * ResourceManager.
+ *
+ * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @version $Id: ResourceCacheImpl.java,v 1.2.8.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public class ResourceCacheImpl implements ResourceCache
+{
+    /**
+     * Cache storage, assumed to be thread-safe.
+     */
+    protected Map cache = new Hashtable();
+
+    /**
+     * Runtime services, generally initialized by the
+     * <code>initialize()</code> method.
+     */
+    protected RuntimeServices rsvc = null;
+    
+    public void initialize( RuntimeServices rs )
+    {
+        rsvc = rs;
+        
+        rsvc.info("ResourceCache : initialized. (" + this.getClass() + ")");
+    }
+    
+    public Resource get( Object key )
+    {
+        return (Resource) cache.get( key );
+    }
+    
+    public Resource put( Object key, Resource value )
+    {
+        return (Resource) cache.put( key, value );
+    }
+    
+    public Resource remove( Object key )
+    {
+        return (Resource) cache.remove( key );
+    }
+    
+    public Iterator enumerateKeys()
+    {
+        return cache.keySet().iterator();
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceFactory.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceFactory.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceFactory.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceFactory.java Tue May 29 15:35:01 2012
@@ -0,0 +1,48 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.Template;
+
+/**
+ * Class responsible for instantiating <code>Resource</code> objects,
+ * given name and type.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ResourceFactory.java,v 1.5.8.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public class ResourceFactory
+{
+    public static Resource getResource(String resourceName, int resourceType)
+    {
+        Resource resource = null;
+        
+        switch (resourceType)
+        {
+            case ResourceManager.RESOURCE_TEMPLATE:
+                resource = new Template();
+                break;
+            
+            case ResourceManager.RESOURCE_CONTENT:
+                resource = new ContentResource();
+                break;
+        }
+    
+        return resource;
+    }
+}

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

Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java Tue May 29 15:35:01 2012
@@ -0,0 +1,81 @@
+package org.apache.velocity.runtime.resource;
+
+/*
+ * 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.velocity.runtime.RuntimeServices;
+
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.ParseErrorException;
+
+/**
+ * Class to manage the text resource for the Velocity
+ * Runtime.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ResourceManager.java,v 1.34.4.1 2004/03/03 23:23:01 geirm Exp $
+ */
+public interface ResourceManager
+{
+    /**
+     * A template resources.
+     */
+    public static final int RESOURCE_TEMPLATE = 1;
+    
+    /**
+     * A static content resource.
+     */
+    public static final int RESOURCE_CONTENT = 2;
+
+    /**
+     * Initialize the ResourceManager.
+     */
+    public void initialize( RuntimeServices rs ) throws Exception;
+
+    /**
+     * Gets the named resource.  Returned class type corresponds to specified type
+     * (i.e. <code>Template</code> to <code>RESOURCE_TEMPLATE</code>).
+     *
+     * @param resourceName The name of the resource to retrieve.
+     * @param resourceType The type of resource (<code>RESOURCE_TEMPLATE</code>,
+     *                     <code>RESOURCE_CONTENT</code>, etc.).
+     * @param encoding  The character encoding to use.
+     * @return Resource with the template parsed and ready.
+     * @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 a problem in parse
+     */
+    public Resource getResource(String resourceName, int resourceType, String encoding )
+        throws ResourceNotFoundException, ParseErrorException, Exception;
+
+    /**
+     *  Determines is a template exists, and returns name of the loader that 
+     *  provides it.  This is a slightly less hokey way to support
+     *  the Velocity.templateExists() utility method, which was broken
+     *  when per-template encoding was introduced.  We can revisit this.
+     *
+     *  @param resourceName Name of template or content resource
+     *  @return class name of loader than can provide it
+     */
+    public String getLoaderNameForResource(String resourceName );
+     
+}
+
+

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