Allow arrays containing null in Filter & ForEach - fixes #741

This commit is contained in:
Tom Morris 2013-07-26 15:20:44 -04:00
parent c8f0e88bd4
commit dc4d04c132
2 changed files with 30 additions and 6 deletions

View File

@ -81,7 +81,11 @@ public class Filter implements Control {
results = new ArrayList<Object>(values.length);
for (Object v : values) {
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);
if (r instanceof Boolean && ((Boolean) r).booleanValue()) {
@ -97,7 +101,11 @@ public class Filter implements Control {
try {
Object v = a.get(i);
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);
if (r instanceof Boolean && ((Boolean) r).booleanValue()) {
@ -113,7 +121,11 @@ public class Filter implements Control {
results = new ArrayList<Object>(collection.size());
for (Object v : collection) {
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);
if (r instanceof Boolean && ((Boolean) r).booleanValue()) {

View File

@ -81,7 +81,11 @@ public class ForEach implements Control {
results = new ArrayList<Object>(values.length);
for (Object v : values) {
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);
@ -96,7 +100,11 @@ public class ForEach implements Control {
try {
Object v = a.get(i);
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);
@ -111,7 +119,11 @@ public class ForEach implements Control {
results = new ArrayList<Object>(collection.size());
for (Object v : collection) {
bindings.put(name, v);
if (v != null) {
bindings.put(name, v);
} else {
bindings.remove(name);
}
Object r = args[2].evaluate(bindings);