removed unnecessary class. improvements to map projection/selection
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.springframework.expression.spel.ast;
|
||||
|
||||
/**
|
||||
* Special object that is used to wrap a map entry/value when iterating over a map. Providing a direct way for the
|
||||
* expression to refer to either the key or value.
|
||||
*
|
||||
* @author Andy Clement
|
||||
*/
|
||||
class KeyValuePair {
|
||||
|
||||
public Object key;
|
||||
public Object value;
|
||||
|
||||
public KeyValuePair(Object k, Object v) {
|
||||
this.key = k;
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class Projection extends SpelNodeImpl {
|
||||
mapdata.entrySet();
|
||||
for (Map.Entry entry : mapdata.entrySet()) {
|
||||
try {
|
||||
state.pushActiveContextObject(new TypedValue(new KeyValuePair(entry.getKey(), entry.getValue()),TypeDescriptor.valueOf(KeyValuePair.class)));
|
||||
state.pushActiveContextObject(new TypedValue(entry,TypeDescriptor.valueOf(Map.Entry.class)));
|
||||
result.add(getChild(0).getValueInternal(state).getValue());
|
||||
} finally {
|
||||
state.popActiveContextObject();
|
||||
|
||||
@@ -66,17 +66,16 @@ public class Selection extends SpelNodeImpl {
|
||||
for (Map.Entry entry : mapdata.entrySet()) {
|
||||
try {
|
||||
lastKey = entry.getKey();
|
||||
KeyValuePair kvp = new KeyValuePair(entry.getKey(),entry.getValue());
|
||||
TypedValue kvpair = new TypedValue(kvp,TypeDescriptor.valueOf(KeyValuePair.class));
|
||||
TypedValue kvpair = new TypedValue(entry,TypeDescriptor.valueOf(Map.Entry.class));
|
||||
state.pushActiveContextObject(kvpair);
|
||||
Object o = selectionCriteria.getValueInternal(state).getValue();
|
||||
if (o instanceof Boolean) {
|
||||
if (((Boolean) o).booleanValue() == true) {
|
||||
if (variant == FIRST) {
|
||||
result.put(kvp.key,kvp.value);
|
||||
result.put(entry.getKey(),entry.getValue());
|
||||
return new TypedValue(result);
|
||||
}
|
||||
result.put(kvp.key,kvp.value);
|
||||
result.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
} else {
|
||||
throw new SpelException(selectionCriteria.getCharPositionInLine(),
|
||||
@@ -108,8 +107,9 @@ public class Selection extends SpelNodeImpl {
|
||||
Object o = selectionCriteria.getValueInternal(state).getValue();
|
||||
if (o instanceof Boolean) {
|
||||
if (((Boolean) o).booleanValue() == true) {
|
||||
if (variant == FIRST)
|
||||
if (variant == FIRST) {
|
||||
return new TypedValue(element,TypeDescriptor.valueOf(op.getTypeDescriptor().getElementType()));
|
||||
}
|
||||
result.add(element);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user