freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [34/36] incubator-freemarker git commit: FREEMARKER-55: javadocs and cleanups
Date Wed, 13 Sep 2017 09:49:35 GMT
FREEMARKER-55: javadocs and cleanups


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/ef9ba120
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/ef9ba120
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/ef9ba120

Branch: refs/heads/3
Commit: ef9ba120ebdc85d87567c1fb4200f3d752e89ab6
Parents: bd56432
Author: Woonsan Ko <woonsan@apache.org>
Authored: Tue Sep 12 21:53:45 2017 -0400
Committer: Woonsan Ko <woonsan@apache.org>
Committed: Tue Sep 12 21:53:45 2017 -0400

----------------------------------------------------------------------
 .../AbstractSpringTemplateCallableModel.java    | 49 +++++++++--------
 .../AbstractSpringTemplateDirectiveModel.java   | 33 +++++++++---
 .../AbstractSpringTemplateFunctionModel.java    | 32 ++++++++---
 .../spring/model/BindErrorsDirective.java       | 24 +++------
 .../freemarker/spring/model/EvalFunction.java   | 16 ++++--
 .../spring/model/MessageFunction.java           | 23 ++++----
 .../spring/model/NestedPathDirective.java       |  4 +-
 .../SpringFormTemplateCallableHashModel.java    | 56 --------------------
 .../model/SpringTemplateCallableHashModel.java  | 13 ++++-
 .../spring/model/TransformFunction.java         | 21 ++++----
 .../freemarker/spring/model/UrlFunction.java    |  2 +-
 .../spring/web/view/FreeMarkerView.java         |  3 --
 12 files changed, 124 insertions(+), 152 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateCallableModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateCallableModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateCallableModel.java
index 384a47b..641fbdb 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateCallableModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateCallableModel.java
@@ -28,8 +28,6 @@ import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper;
 import org.apache.freemarker.core.model.TemplateCallableModel;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateStringModel;
-import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
-import org.apache.freemarker.core.util.CallableUtils;
 import org.springframework.web.servlet.support.BindStatus;
 import org.springframework.web.servlet.support.RequestContext;
 
@@ -41,15 +39,28 @@ public abstract class AbstractSpringTemplateCallableModel implements TemplateCal
     private final HttpServletRequest request;
     private final HttpServletResponse response;
 
+    /**
+     * Constructs with servlet request and response.
+     * @param request servlet request
+     * @param response servlet response
+     */
     public AbstractSpringTemplateCallableModel(HttpServletRequest request, HttpServletResponse
response) {
         this.request = request;
         this.response = response;
     }
 
+    /**
+     * Return servlet request.
+     * @return servlet request
+     */
     protected final HttpServletRequest getRequest() {
         return request;
     }
 
+    /**
+     * Return servlet response.
+     * @return servlet response
+     */
     protected final HttpServletResponse getResponse() {
         return response;
     }
@@ -68,34 +79,22 @@ public abstract class AbstractSpringTemplateCallableModel implements TemplateCal
      * @param ignoreNestedPath flag whether or not to ignore the nested path
      * @return {@link TemplateModel} wrapping a {@link BindStatus} with no {@code htmlEscape}
option from {@link RequestContext}
      * by the {@code path}
-     * @throws TemplateException 
+     * @throws TemplateException if template exception occurs
      */
-    protected final TemplateModel getBindStatusTemplateModel(Environment env, ObjectWrapperAndUnwrapper
objectWrapperAndUnwrapper,
-            RequestContext requestContext, String path, boolean ignoreNestedPath) throws
TemplateException {
+    protected final TemplateModel getBindStatusTemplateModel(Environment env,
+            ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper, RequestContext requestContext,
String path,
+            boolean ignoreNestedPath) throws TemplateException {
         final String resolvedPath = (ignoreNestedPath) ? path : resolveNestedPath(env, objectWrapperAndUnwrapper,
path);
         BindStatus status = requestContext.getBindStatus(resolvedPath, false);
-        return wrapObject(objectWrapperAndUnwrapper, status);
-    }
-
-    protected final Object unwrapObject(ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper,
TemplateModel model) throws TemplateException {
-        return (model != null) ? objectWrapperAndUnwrapper.unwrap(model) : null;
+        return (status != null) ? objectWrapperAndUnwrapper.wrap(status) : null;
     }
 
-    protected final TemplateModel wrapObject(ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper,
Object object) throws TemplateException {
-        if (object != null) {
-            if (!(objectWrapperAndUnwrapper instanceof DefaultObjectWrapper)) {
-                CallableUtils.newGenericExecuteException("objectWrapperAndUnwrapper is not
a DefaultObjectWrapper.",
-                        this, isFunction());
-            }
-
-            return ((DefaultObjectWrapper) objectWrapperAndUnwrapper).wrap(object);
-        }
-
-        return null;
-    }
-
-    protected abstract boolean isFunction();
-
+    /**
+     * Return the internal TemplateHashModel wrapper for templating in Spring Framework applications.
+     * @param env environment
+     * @return the internal TemplateHashModel wrapper for templating in Spring Framework
applications
+     * @throws TemplateException if template exception occurs
+     */
     protected SpringTemplateCallableHashModel getSpringTemplateCallableHashModel(final Environment
env)
             throws TemplateException {
         return (SpringTemplateCallableHashModel) env.getVariable(SpringTemplateCallableHashModel.NAME);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateDirectiveModel.java
index df6a2bc..0ce34d0 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateDirectiveModel.java
@@ -42,10 +42,22 @@ import org.springframework.web.servlet.view.AbstractTemplateView;
 public abstract class AbstractSpringTemplateDirectiveModel extends AbstractSpringTemplateCallableModel
         implements TemplateDirectiveModel {
 
+    /**
+     * Construct directive with servlet request and response.
+     * @param request servlet request
+     * @param response servlet response
+     */
     public AbstractSpringTemplateDirectiveModel(HttpServletRequest request, HttpServletResponse
response) {
         super(request, response);
     }
 
+    /**
+     * Execute this directive.
+     * <P>
+     * This method establishes Spring's <code>RequestContext</code> and invokes
{@link #executeInternal(TemplateModel[], CallPlace, Writer, Environment, ObjectWrapperAndUnwrapper,
RequestContext)}
+     * which must be implemented by derived directive classes.
+     * </P>
+     */
     @Override
     public final void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment
env)
             throws TemplateException, IOException {
@@ -53,15 +65,14 @@ public abstract class AbstractSpringTemplateDirectiveModel extends AbstractSprin
 
         if (!(objectWrapper instanceof ObjectWrapperAndUnwrapper)) {
             CallableUtils.newGenericExecuteException(
-                    "The ObjectWrapper of environment isn't an instance of ObjectWrapperAndUnwrapper.",
this,
-                    isFunction());
+                    "The ObjectWrapper of environment isn't an instance of ObjectWrapperAndUnwrapper.",
this, false);
         }
 
         TemplateModel rcModel = env.getVariable(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);
 
         if (rcModel == null) {
             CallableUtils.newGenericExecuteException(
-                    AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE + " not found.",
this, isFunction());
+                    AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE + " not found.",
this, false);
         }
 
         RequestContext requestContext = (RequestContext) ((ObjectWrapperAndUnwrapper) objectWrapper).unwrap(rcModel);
@@ -69,11 +80,17 @@ public abstract class AbstractSpringTemplateDirectiveModel extends AbstractSprin
         executeInternal(args, callPlace, out, env, (ObjectWrapperAndUnwrapper) objectWrapper,
requestContext);
     }
 
-    @Override
-    protected final boolean isFunction() {
-        return false;
-    }
-
+    /**
+     * Interal execution method that is supposed to be implemented by derived directive classes.
+     * @param args argument models
+     * @param callPlace the place where this is being called
+     * @param out output writer
+     * @param env template execution environment
+     * @param objectWrapperAndUnwrapper ObjectWrapperAndUnwrapper
+     * @param requestContext Spring RequestContext
+     * @throws TemplateException if template exception occurs
+     * @throws IOException if IO exception occurs
+     */
     protected abstract void executeInternal(TemplateModel[] args, CallPlace callPlace, Writer
out, Environment env,
             ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper, RequestContext requestContext)
                     throws TemplateException, IOException;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateFunctionModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateFunctionModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateFunctionModel.java
index 7851ad8..137837c 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateFunctionModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/AbstractSpringTemplateFunctionModel.java
@@ -39,25 +39,36 @@ import org.springframework.web.servlet.view.AbstractTemplateView;
 public abstract class AbstractSpringTemplateFunctionModel extends AbstractSpringTemplateCallableModel
         implements TemplateFunctionModel {
 
+    /**
+     * Construct function with servlet request and response.
+     * @param request servlet request
+     * @param response servlet response
+     */
     public AbstractSpringTemplateFunctionModel(HttpServletRequest request, HttpServletResponse
response) {
         super(request, response);
     }
 
+    /**
+     * Execute this function.
+     * <P>
+     * This method establishes Spring's <code>RequestContext</code> and invokes
{@link #executeInternal(TemplateModel[], CallPlace, Environment, ObjectWrapperAndUnwrapper,
RequestContext)}
+     * which must be implemented by derived function classes.
+     * </P>
+     */
     @Override
     public TemplateModel execute(TemplateModel[] args, CallPlace callPlace, Environment env)
throws TemplateException {
         final ObjectWrapper objectWrapper = env.getObjectWrapper();
 
         if (!(objectWrapper instanceof ObjectWrapperAndUnwrapper)) {
             CallableUtils.newGenericExecuteException(
-                    "The ObjectWrapper of environment isn't an instance of ObjectWrapperAndUnwrapper.",
this,
-                    isFunction());
+                    "The ObjectWrapper of environment isn't an instance of ObjectWrapperAndUnwrapper.",
this, true);
         }
 
         TemplateModel rcModel = env.getVariable(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);
 
         if (rcModel == null) {
             CallableUtils.newGenericExecuteException(
-                    AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE + " not found.",
this, isFunction());
+                    AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE + " not found.",
this, true);
         }
 
         RequestContext requestContext = (RequestContext) ((ObjectWrapperAndUnwrapper) objectWrapper).unwrap(rcModel);
@@ -65,11 +76,16 @@ public abstract class AbstractSpringTemplateFunctionModel extends AbstractSpring
         return executeInternal(args, callPlace, env, (ObjectWrapperAndUnwrapper) objectWrapper,
requestContext);
     }
 
-    @Override
-    protected final boolean isFunction() {
-        return true;
-    }
-
+    /**
+     * Interal execution method that is supposed to be implemented by derived directive classes.
+     * @param args argument models
+     * @param callPlace the place where this is being called
+     * @param env template execution environment
+     * @param objectWrapperAndUnwrapper ObjectWrapperAndUnwrapper
+     * @param requestContext Spring RequestContext
+     * @return function execution result template model
+     * @throws TemplateException if template exception occurs
+     */
     protected abstract TemplateModel executeInternal(TemplateModel[] args, CallPlace callPlace,
Environment env,
             ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper, RequestContext requestContext)
                     throws TemplateException;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/BindErrorsDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/BindErrorsDirective.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/BindErrorsDirective.java
index 6d0c954..d775cd1 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/BindErrorsDirective.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/BindErrorsDirective.java
@@ -31,7 +31,6 @@ import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.model.ArgumentArrayLayout;
 import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper;
 import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.util.CallableUtils;
 import org.springframework.validation.Errors;
 import org.springframework.web.servlet.support.RequestContext;
@@ -72,13 +71,7 @@ public class BindErrorsDirective extends AbstractSpringTemplateDirectiveModel
{
 
     private static final int NAME_PARAM_IDX = 0;
 
-    private static final ArgumentArrayLayout ARGS_LAYOUT =
-            ArgumentArrayLayout.create(
-                    1,
-                    false,
-                    null,
-                    false
-                    );
+    private static final ArgumentArrayLayout ARGS_LAYOUT = ArgumentArrayLayout.create(1,
false, null, false);
 
     public BindErrorsDirective(HttpServletRequest request, HttpServletResponse response)
{
         super(request, response);
@@ -90,7 +83,8 @@ public class BindErrorsDirective extends AbstractSpringTemplateDirectiveModel
{
                     throws TemplateException, IOException {
         final String name = CallableUtils.getStringArgument(args, NAME_PARAM_IDX, this);
 
-        final TemplateModel bindErrorsModel = getBindErrorsTemplateModel(env, objectWrapperAndUnwrapper,
requestContext, name);
+        final TemplateModel bindErrorsModel = getBindErrorsTemplateModel(env, objectWrapperAndUnwrapper,
requestContext,
+                name);
 
         if (bindErrorsModel != null) {
             final TemplateModel[] nestedContentArgs = new TemplateModel[] { bindErrorsModel
};
@@ -108,17 +102,13 @@ public class BindErrorsDirective extends AbstractSpringTemplateDirectiveModel
{
         return ARGS_LAYOUT;
     }
 
-    private final TemplateModel getBindErrorsTemplateModel(Environment env, ObjectWrapperAndUnwrapper
objectWrapperAndUnwrapper,
-            RequestContext requestContext, String name) throws TemplateException {
+    private final TemplateModel getBindErrorsTemplateModel(Environment env,
+            ObjectWrapperAndUnwrapper objectWrapperAndUnwrapper, RequestContext requestContext,
String name)
+                    throws TemplateException {
         final Errors errors = requestContext.getErrors(name, false);
 
         if (errors != null && errors.hasErrors()) {
-            if (!(objectWrapperAndUnwrapper instanceof DefaultObjectWrapper)) {
-                CallableUtils.newGenericExecuteException("objectWrapperAndUnwrapper is not
a DefaultObjectWrapper.",
-                        this, isFunction());
-            }
-
-            return wrapObject(objectWrapperAndUnwrapper, errors);
+            return objectWrapperAndUnwrapper.wrap(errors);
         }
 
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/EvalFunction.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/EvalFunction.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/EvalFunction.java
index f155df1..52cd62b 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/EvalFunction.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/EvalFunction.java
@@ -103,15 +103,16 @@ public class EvalFunction extends AbstractSpringTemplateFunctionModel
{
         TemplateModel evaluationContextModel = springTemplateModel.get(EVALUATION_CONTEXT_VAR_NAME);
 
         if (evaluationContextModel != null) {
-            evaluationContext = (EvaluationContext) unwrapObject(objectWrapperAndUnwrapper,
evaluationContextModel);
+            evaluationContext = (EvaluationContext) objectWrapperAndUnwrapper.unwrap(evaluationContextModel);
         } else {
             evaluationContext = createEvaluationContext(env, objectWrapperAndUnwrapper, requestContext);
-            evaluationContextModel = wrapObject(objectWrapperAndUnwrapper, evaluationContext);
+            evaluationContextModel = objectWrapperAndUnwrapper.wrap(evaluationContext);
             springTemplateModel.setEvaluationContextModel(evaluationContextModel);
         }
 
         final Object result = expression.getValue(evaluationContext);
-        return wrapObject(objectWrapperAndUnwrapper, result);
+
+        return (result != null) ? objectWrapperAndUnwrapper.wrap(result) : null;
     }
 
     @Override
@@ -170,8 +171,13 @@ public class EvalFunction extends AbstractSpringTemplateFunctionModel
{
         public TypedValue read(EvaluationContext context, Object target, String name) throws
AccessException {
             try {
                 TemplateModel model = env.getVariable(name);
-                Object value = unwrapObject(objectWrapperAndUnwrapper, model);
-                return new TypedValue(value);
+
+                if (model != null) {
+                    Object value = objectWrapperAndUnwrapper.unwrap(model);
+                    return new TypedValue(value);
+                } else {
+                    return null;
+                }
             } catch (TemplateException e) {
                 throw new AccessException("Can't get environment variable by name, '" + name
+ "'.", e);
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/MessageFunction.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/MessageFunction.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/MessageFunction.java
index e64aba5..8b98652 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/MessageFunction.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/MessageFunction.java
@@ -84,13 +84,8 @@ public class MessageFunction extends AbstractSpringTemplateFunctionModel
{
 
     private static final String MESSAGE_RESOLVABLE_PARAM_NAME = "message";
 
-    private static final ArgumentArrayLayout ARGS_LAYOUT =
-            ArgumentArrayLayout.create(
-                    1,
-                    true,
-                    StringToIndexMap.of(MESSAGE_RESOLVABLE_PARAM_NAME, MESSAGE_RESOLVABLE_PARAM_IDX),
-                    false
-                    );
+    private static final ArgumentArrayLayout ARGS_LAYOUT = ArgumentArrayLayout.create(1,
true,
+            StringToIndexMap.of(MESSAGE_RESOLVABLE_PARAM_NAME, MESSAGE_RESOLVABLE_PARAM_IDX),
false);
 
     public MessageFunction(HttpServletRequest request, HttpServletResponse response) {
         super(request, response);
@@ -108,10 +103,10 @@ public class MessageFunction extends AbstractSpringTemplateFunctionModel
{
 
         String message = null;
 
-        final TemplateModel messageResolvableModel = CallableUtils.getOptionalArgument(args,
MESSAGE_RESOLVABLE_PARAM_IDX,
-                TemplateModel.class, this);
-        final MessageSourceResolvable messageResolvable = (MessageSourceResolvable) unwrapObject(
-                objectWrapperAndUnwrapper, messageResolvableModel);
+        final TemplateModel messageResolvableModel = CallableUtils.getOptionalArgument(args,
+                MESSAGE_RESOLVABLE_PARAM_IDX, TemplateModel.class, this);
+        final MessageSourceResolvable messageResolvable = (messageResolvableModel != null)
+                ? (MessageSourceResolvable) objectWrapperAndUnwrapper.unwrap(messageResolvableModel)
: null;
 
         if (messageResolvable != null) {
             message = messageSource.getMessage(messageResolvable, requestContext.getLocale());
@@ -126,9 +121,9 @@ public class MessageFunction extends AbstractSpringTemplateFunctionModel
{
                 if (!messageArgsModel.isEmptyCollection()) {
                     msgArgumentList = new ArrayList<>();
                     TemplateModel msgArgModel;
-                    for (TemplateModelIterator tit = messageArgsModel.iterator(); tit.hasNext();
) {
+                    for (TemplateModelIterator tit = messageArgsModel.iterator(); tit.hasNext();)
{
                         msgArgModel = tit.next();
-                        msgArgumentList.add(unwrapObject(objectWrapperAndUnwrapper, msgArgModel));
+                        msgArgumentList.add(objectWrapperAndUnwrapper.unwrap(msgArgModel));
                     }
                 }
 
@@ -141,7 +136,7 @@ public class MessageFunction extends AbstractSpringTemplateFunctionModel
{
             }
         }
 
-        return wrapObject(objectWrapperAndUnwrapper, message);
+        return (message != null) ? objectWrapperAndUnwrapper.wrap(message) : null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/NestedPathDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/NestedPathDirective.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/NestedPathDirective.java
index 9bd51ef..a743c3f 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/NestedPathDirective.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/NestedPathDirective.java
@@ -84,8 +84,8 @@ public class NestedPathDirective extends AbstractSpringTemplateDirectiveModel
{
         final TemplateStringModel prevNestedPathModel = springTemplateModel.getNestedPathModel();
         final String prevNestedPath = (prevNestedPathModel != null) ? prevNestedPathModel.getAsString()
: null;
         final String newNestedPath = (prevNestedPath != null) ? prevNestedPath + path : path;
-        final TemplateStringModel newNestedPathModel = (TemplateStringModel) wrapObject(objectWrapperAndUnwrapper,
-                newNestedPath);
+        final TemplateStringModel newNestedPathModel = (TemplateStringModel) objectWrapperAndUnwrapper
+                .wrap(newNestedPath);
 
         try {
             springTemplateModel.setNestedPathModel(newNestedPathModel);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringFormTemplateCallableHashModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringFormTemplateCallableHashModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringFormTemplateCallableHashModel.java
deleted file mode 100644
index 4ff3552..0000000
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringFormTemplateCallableHashModel.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-package org.apache.freemarker.spring.model;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-
-/**
- * TemplateHashModel wrapper for templates using Spring Form directives and functions.
- */
-public final class SpringFormTemplateCallableHashModel implements TemplateHashModel, Serializable
{
-
-    private static final long serialVersionUID = 1L;
-
-    public static final String NAME = "form";
-
-    private Map<String, AbstractSpringTemplateCallableModel> callablesMap = new HashMap<>();
-
-    public SpringFormTemplateCallableHashModel(final HttpServletRequest request, final HttpServletResponse
response) {
-    }
-
-    public TemplateModel get(String key) throws TemplateException {
-        return callablesMap.get(key);
-    }
-
-    @Override
-    public boolean isEmptyHash() throws TemplateException {
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringTemplateCallableHashModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringTemplateCallableHashModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringTemplateCallableHashModel.java
index 26ae060..4e42923 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringTemplateCallableHashModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/SpringTemplateCallableHashModel.java
@@ -32,16 +32,27 @@ import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateStringModel;
 
 /**
- * TemplateHashModel wrapper for templates using Spring directives and functions.
+ * TemplateHashModel wrapper for templates using Spring directives, functions and internal
models.
  */
 public final class SpringTemplateCallableHashModel implements TemplateHashModel, Serializable
{
 
     private static final long serialVersionUID = 1L;
 
+    /**
+     * Spring namespace model name.
+     */
     public static final String NAME = "spring";
 
+    /**
+     * Name of the internal nested path template model, which is equivalent to the <code>nestedPath</code>
pageContext attribute
+     * in Spring Framework JSP tag libraries.
+     */
+    // NOTE: The model name, "nestedPathModel", must be different from the "nestedPath" directive
model's name.
     public static final String NESTED_PATH_MODEL = "nestedPathModel";
 
+    /**
+     * Name of the internal evaluation context template model used by <code>EvalFunction</code>
to cache <code>EvaluationContext</code>.
+     */
     public static final String EVALUATION_CONTEXT_MODEL = "evaluationContextModel";
 
     private Map<String, TemplateModel> modelsMap = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/TransformFunction.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/TransformFunction.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/TransformFunction.java
index d6c381e..9d40650 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/TransformFunction.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/TransformFunction.java
@@ -40,14 +40,9 @@ import org.springframework.web.servlet.support.RequestContext;
  * Some valid example(s):
  * </P>
  * <PRE>
- * </PRE>
- * <P>
- * Some valid example(s):
- * </P>
- * <PRE>
- *   &lt;@spring.bind "user"; status&gt;
- *     ${spring.transform(status.editor, user.birthDate)}
- *   &lt;/@spring.bind&gt;
+ * &lt;@spring.bind "user.birthDate"; status&gt;
+ *   &lt;div id="userBirthDate"&gt;${spring.transform(status.editor, status.actualValue)}&lt;/div&gt;
+ * &lt;/@spring.bind&gt;
  * </PRE>
  * <P>
  * <EM>Note:</EM> Unlike Spring Framework's <code>&lt;spring:bind /&gt;</code>
JSP Tag Library, this directive
@@ -74,10 +69,12 @@ public class TransformFunction extends AbstractSpringTemplateFunctionModel
{
                     throws TemplateException {
         final TemplateModel editorModel = CallableUtils.getOptionalArgument(args, PROPERTY_EDITOR_PARAM_IDX,
                 TemplateModel.class, this);
-        final PropertyEditor editor = (PropertyEditor) unwrapObject(objectWrapperAndUnwrapper,
editorModel);
+        final PropertyEditor editor = (editorModel != null)
+                ? (PropertyEditor) objectWrapperAndUnwrapper.unwrap(editorModel) : null;
 
-        final TemplateModel valueModel = CallableUtils.getOptionalArgument(args, VALUE_PARAM_IDX,
TemplateModel.class, this);
-        final Object value = unwrapObject(objectWrapperAndUnwrapper, valueModel);
+        final TemplateModel valueModel = CallableUtils.getOptionalArgument(args, VALUE_PARAM_IDX,
TemplateModel.class,
+                this);
+        final Object value = (valueModel != null) ? objectWrapperAndUnwrapper.unwrap(valueModel)
: null;
 
         String valueAsString = null;
 
@@ -90,7 +87,7 @@ public class TransformFunction extends AbstractSpringTemplateFunctionModel
{
             }
         }
 
-        return wrapObject(objectWrapperAndUnwrapper, valueAsString);
+        return (valueAsString != null) ? objectWrapperAndUnwrapper.wrap(valueAsString) :
null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/UrlFunction.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/UrlFunction.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/UrlFunction.java
index 2220800..ae70a45 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/UrlFunction.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/UrlFunction.java
@@ -166,7 +166,7 @@ public class UrlFunction extends AbstractSpringTemplateFunctionModel {
             urlString = processor.processUrl(getRequest(), urlString);
         }
 
-        return wrapObject(objectWrapperAndUnwrapper, urlString);
+        return objectWrapperAndUnwrapper.wrap(urlString);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ef9ba120/freemarker-spring/src/main/java/org/apache/freemarker/spring/web/view/FreeMarkerView.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/web/view/FreeMarkerView.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/web/view/FreeMarkerView.java
index 604cc3d..c8fcbd2 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/web/view/FreeMarkerView.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/web/view/FreeMarkerView.java
@@ -35,7 +35,6 @@ import org.apache.freemarker.servlet.HttpSessionHashModel;
 import org.apache.freemarker.servlet.IncludePage;
 import org.apache.freemarker.servlet.ServletContextHashModel;
 import org.apache.freemarker.servlet.jsp.TaglibFactory;
-import org.apache.freemarker.spring.model.SpringFormTemplateCallableHashModel;
 import org.apache.freemarker.spring.model.SpringTemplateCallableHashModel;
 
 /**
@@ -141,8 +140,6 @@ public class FreeMarkerView extends AbstractFreeMarkerView {
 
         model.putUnlistedModel(SpringTemplateCallableHashModel.NAME,
                 new SpringTemplateCallableHashModel(request, response));
-        model.putUnlistedModel(SpringFormTemplateCallableHashModel.NAME,
-                new SpringFormTemplateCallableHashModel(request, response));
 
         model.putAll(map);
 


Mime
View raw message