Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Aspectran is a lightweight Java framework for building Enterprise-ready Web applications.
Also, It will be able to launch as a Console-based and Embedded application.
/**
* Copyright 2008-2016 Juho Jeong
*
* 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 com.aspectran.core.context.expr;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import com.aspectran.core.activity.Activity;
import com.aspectran.core.activity.request.parameter.FileParameter;
import com.aspectran.core.context.expr.token.Token;
import com.aspectran.core.context.rule.ItemRule;
import com.aspectran.core.context.rule.ItemRuleMap;
import com.aspectran.core.context.rule.type.ItemType;
import com.aspectran.core.context.rule.type.ItemValueType;
import com.aspectran.core.util.apon.GenericParameters;
import com.aspectran.core.util.apon.Parameters;
/**
* The Class ItemTokenExpression.
*
* @since 2008. 06. 19
*/
public class ItemTokenExpression extends TokenExpression implements ItemTokenEvaluator {
/**
* Instantiates a new ItemTokenExpression.
*
* @param activity the current Activity
*/
public ItemTokenExpression(Activity activity) {
super(activity);
}
@Override
public Map evaluate(ItemRuleMap itemRuleMap) {
Map valueMap = new LinkedHashMap<>();
evaluate(itemRuleMap, valueMap);
return valueMap;
}
@Override
public void evaluate(ItemRuleMap itemRuleMap, Map valueMap) {
for(ItemRule ir : itemRuleMap.values()) {
ItemType itemType = ir.getType();
ItemValueType valueType = ir.getValueType();
String name = ir.getName();
Object value = null;
if(itemType == ItemType.SINGULAR) {
Token[] tokens = ir.getTokens();
value = evaluate(name, tokens, valueType);
} else if(itemType == ItemType.ARRAY) {
value = evaluateAsArray(name, ir.getTokensList(), valueType);
} else if(itemType == ItemType.LIST) {
value = evaluateAsList(name, ir.getTokensList(), valueType);
} else if(itemType == ItemType.SET) {
value = evaluateAsSet(name, ir.getTokensList(), valueType);
} else if(itemType == ItemType.MAP) {
value = evaluateAsMap(name, ir.getTokensMap(), valueType);
} else if(itemType == ItemType.PROPERTIES) {
value = evaluateAsProperties(name, ir.getTokensMap(), valueType);
}
valueMap.put(name, value);
}
}
private Object evaluate(String parameterName, Token[] tokens, ItemValueType valueType) {
Object value = evaluate(parameterName, tokens);
if(value == null || valueType == null)
return value;
return valuelize(value, valueType);
}
@SuppressWarnings("all")
private Object[] evaluateAsArray(String parameterName, List tokensList, ItemValueType valueType) {
List