summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2009-02-17 04:10:17 (EST)
committer sefftinge2009-02-17 04:10:17 (EST)
commitaa91aa99c2323362b8800d839a5409e512304f44 (patch)
treeeec2ea1abc44b2820afd5c4006b982db13cc8bee
parent463983c2ef64e62bfc83f6cff2e67e50b84fbfa6 (diff)
downloadorg.eclipse.xpand-aa91aa99c2323362b8800d839a5409e512304f44.zip
org.eclipse.xpand-aa91aa99c2323362b8800d839a5409e512304f44.tar.gz
org.eclipse.xpand-aa91aa99c2323362b8800d839a5409e512304f44.tar.bz2
added evluate method to allow specifcation of parameters as a list
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
index 522fbc4..6454bbd 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
@@ -11,7 +11,10 @@
package org.eclipse.xpand2;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.internal.xpand2.model.XpandDefinition;
@@ -39,11 +42,17 @@ public class XpandFacade {
}
public void evaluate(final String definitionName, final Object targetObject, Object... params) {
- params = params == null ? new Object[0] : params;
+ evaluate2(definitionName, targetObject, params!=null ? Arrays.asList(params) : null);
+ }
+
+ public void evaluate2(final String definitionName, final Object targetObject, List<Object> paramList) {
+ if (paramList==null)
+ paramList = Collections.emptyList();
final Type targetType = ctx.getType(targetObject);
- final Type[] paramTypes = new Type[params.length];
+ final Type[] paramTypes = new Type[paramList.size()];
for (int i = 0; i < paramTypes.length; i++) {
- paramTypes[i] = ctx.getType(params[i]);
+ Object obj = paramList.get(i);
+ paramTypes[i] = ctx.getType(obj);
}
final XpandDefinition def = ctx.findDefinition(definitionName, targetType, paramTypes);
@@ -53,8 +62,8 @@ public class XpandFacade {
ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE,
targetObject));
- for (int i = 0; i < params.length; i++) {
- final Variable v = new Variable(def.getParams()[i].getName().getValue(), params[i]);
+ for (int i = 0; i < paramList.size(); i++) {
+ final Variable v = new Variable(def.getParams()[i].getName().getValue(), paramList.get(i));
ctx = (XpandExecutionContext) ctx.cloneWithVariable(v);
}
ctx = (XpandExecutionContext) ctx.cloneWithResource(def.getOwner());