aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java/org/apache/velocity/util
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2019-03-03 11:21:42 +0000
committerClaude Brisson <cbrisson@apache.org>2019-03-03 11:21:42 +0000
commit9468c7cc024a114ba3efb96e4d9dcdc57df4608f (patch)
treea2ca22c32740d578df545f4a05f4525c0c25828e /velocity-engine-core/src/main/java/org/apache/velocity/util
parentbf26e3298dccad99fe971b56a714fca4c09ef42f (diff)
downloadapache-velocity-engine-9468c7cc024a114ba3efb96e4d9dcdc57df4608f.tar.gz
[engine] Indentation fix
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1854694 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache/velocity/util')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java196
1 files changed, 96 insertions, 100 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
index 3da7d228..d33bd978 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
@@ -156,119 +156,115 @@ public class ClassUtils {
}
- /**
- * Lookup a VelMethod object given the method signature that is specified in
- * the passed in parameters. This method first searches the cache, if not found in
- * the cache then uses reflections to inspect Object o, for the given method.
- * @param methodName Name of method
- * @param params Array of objects that are parameters to the method
- * @param paramClasses Array of Classes corresponding to the types in params.
- * @param o Object to introspect for the given method.
- * @param context Context from which the method cache is acquired
- * @param node ASTNode, used for error reporting.
- * @param strictRef If no method is found, throw an exception, never return null in this case
- * @return VelMethod object if the object is found, null if not matching method is found
- */
- public static VelMethod getMethod(String methodName, Object[] params,
+ /**
+ * Lookup a VelMethod object given the method signature that is specified in
+ * the passed in parameters. This method first searches the cache, if not found in
+ * the cache then uses reflections to inspect Object o, for the given method.
+ * @param methodName Name of method
+ * @param params Array of objects that are parameters to the method
+ * @param paramClasses Array of Classes corresponding to the types in params.
+ * @param o Object to introspect for the given method.
+ * @param context Context from which the method cache is acquired
+ * @param node ASTNode, used for error reporting.
+ * @param strictRef If no method is found, throw an exception, never return null in this case
+ * @return VelMethod object if the object is found, null if not matching method is found
+ */
+ public static VelMethod getMethod(String methodName, Object[] params,
Class[] paramClasses, Object o, InternalContextAdapter context,
SimpleNode node, boolean strictRef)
- {
- VelMethod method = null;
- try
{
- /*
- * check the cache
- */
- MethodCacheKey mck = new MethodCacheKey(methodName, paramClasses);
- IntrospectionCacheData icd = context.icacheGet(mck);
- Class clazz = o instanceof Class ? (Class)o : o.getClass();
+ VelMethod method = null;
+ try
+ {
+ /*
+ * check the cache
+ */
+ MethodCacheKey mck = new MethodCacheKey(methodName, paramClasses);
+ IntrospectionCacheData icd = context.icacheGet(mck);
+ Class clazz = o instanceof Class ? (Class)o : o.getClass();
- /*
- * like ASTIdentifier, if we have cache information, and the Class of
- * Object o is the same as that in the cache, we are safe.
- */
- if (icd != null && (o != null && icd.contextData == clazz))
- {
+ /*
+ * like ASTIdentifier, if we have cache information, and the Class of
+ * Object o is the same as that in the cache, we are safe.
+ */
+ if (icd != null && (o != null && icd.contextData == clazz))
+ {
+ /*
+ * get the method from the cache
+ */
+ method = (VelMethod) icd.thingy;
+ }
+ else
+ {
+ /*
+ * otherwise, do the introspection, and then cache it
+ */
+ method = node.getRuntimeServices().getUberspect().getMethod(o, methodName, params,
+ new Info(node.getTemplateName(), node.getLine(), node.getColumn()));
- /*
- * get the method from the cache
- */
- method = (VelMethod) icd.thingy;
- }
- else
- {
- /*
- * otherwise, do the introspection, and then cache it
- */
- method = node.getRuntimeServices().getUberspect().getMethod(o, methodName, params,
- new Info(node.getTemplateName(), node.getLine(), node.getColumn()));
+ if ((method != null) && (o != null))
+ {
+ icd = new IntrospectionCacheData();
+ icd.contextData = clazz;
+ icd.thingy = method;
+ context.icachePut(mck, icd);
+ }
+ }
- if ((method != null) && (o != null))
+ /*
+ * if we still haven't gotten the method, either we are calling a method
+ * that doesn't exist (which is fine...) or I screwed it up.
+ */
+ if (method == null)
+ {
+ if (strictRef)
+ {
+ // Create a parameter list for the exception error message
+ StringBuilder plist = new StringBuilder();
+ for (int i = 0; i < params.length; i++)
+ {
+ Class param = paramClasses[i];
+ plist.append(param == null ? "null" : param.getName());
+ if (i < params.length - 1)
+ plist.append(", ");
+ }
+ throw new MethodInvocationException("Object '"
+ + o.getClass().getName() + "' does not contain method "
+ + methodName + "(" + plist + ")", null, methodName, node
+ .getTemplateName(), node.getLine(), node.getColumn());
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ catch (MethodInvocationException mie)
{
- icd = new IntrospectionCacheData();
- icd.contextData = clazz;
- icd.thingy = method;
-
- context.icachePut(mck, icd);
+ /*
+ * this can come from the doIntrospection(), as the arg values are
+ * evaluated to find the right method signature. We just want to propagate
+ * it here, not do anything fancy
+ */
+ throw mie;
}
- }
-
- /*
- * if we still haven't gotten the method, either we are calling a method
- * that doesn't exist (which is fine...) or I screwed it up.
- */
- if (method == null)
- {
- if (strictRef)
+ catch (RuntimeException e)
{
- // Create a parameter list for the exception error message
- StringBuilder plist = new StringBuilder();
- for (int i = 0; i < params.length; i++)
- {
- Class param = paramClasses[i];
- plist.append(param == null ? "null" : param.getName());
- if (i < params.length - 1)
- plist.append(", ");
- }
- throw new MethodInvocationException("Object '"
- + o.getClass().getName() + "' does not contain method "
- + methodName + "(" + plist + ")", null, methodName, node
- .getTemplateName(), node.getLine(), node.getColumn());
+ /**
+ * pass through application level runtime exceptions
+ */
+ throw e;
}
- else
+ catch (Exception e)
{
- return null;
+ /*
+ * can come from the doIntropection() also, from Introspector
+ */
+ String msg = "ASTMethod.execute() : exception from introspection";
+ throw new VelocityException(msg, e);
}
- }
-
- }
- catch (MethodInvocationException mie)
- {
- /*
- * this can come from the doIntrospection(), as the arg values are
- * evaluated to find the right method signature. We just want to propagate
- * it here, not do anything fancy
- */
- throw mie;
- }
- catch (RuntimeException e)
- {
- /**
- * pass through application level runtime exceptions
- */
- throw e;
+ return method;
}
- catch (Exception e)
- {
- /*
- * can come from the doIntropection() also, from Introspector
- */
- String msg = "ASTMethod.execute() : exception from introspection";
- throw new VelocityException(msg, e);
- }
-
- return method;
- }
}