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.
/**
* MVEL 2.0
* Copyright (C) 2007 The Codehaus
* Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
*
* 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.mvel2.util;
import static org.mvel2.util.ParseTools.balancedCapture;
import static org.mvel2.util.ParseTools.createStringTrimmed;
import static org.mvel2.util.ParseTools.getBaseComponentType;
import static org.mvel2.util.ParseTools.isIdentifierPart;
import static org.mvel2.util.ParseTools.isWhitespace;
import static org.mvel2.util.ParseTools.skipWhitespace;
import static org.mvel2.util.ParseTools.subCompileExpression;
import static org.mvel2.util.ReflectionUtil.isAssignableFrom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.mvel2.CompileException;
import org.mvel2.DataConversion;
import org.mvel2.ParserContext;
import org.mvel2.compiler.ExecutableStatement;
/**
* This is the inline collection sub-parser. It produces a skeleton model of the collection which is in turn translated
* into a sequenced AST to produce the collection efficiently at runtime, and passed off to one of the JIT's if
* configured.
*
* @author Christopher Brock
*/
public class CollectionParser {
public static final int LIST = 0;
public static final int ARRAY = 1;
public static final int MAP = 2;
private static final Object[] EMPTY_ARRAY = new Object[0];
private char[] property;
private int cursor;
private int start;
private int end;
private int type;
private Class colType;
private ParserContext pCtx;
public CollectionParser() {
}
public CollectionParser(int type) {
this.type = type;
}
public Object parseCollection(char[] property, int start, int offset, boolean subcompile, ParserContext pCtx) {
this.property = property;
this.pCtx = pCtx;
this.end = start + offset;
while (start < end && isWhitespace(property[start])) {
start++;
}
this.start = this.cursor = start;
return parseCollection(subcompile);
}
public Object parseCollection(char[] property, int start, int offset, boolean subcompile, Class colType, ParserContext pCtx) {
if (colType != null) this.colType = getBaseComponentType(colType);
this.property = property;
this.end = start + offset;
while (start < end && isWhitespace(property[start])) {
start++;
}
this.start = this.cursor = start;
this.pCtx = pCtx;
return parseCollection(subcompile);
}
private Object parseCollection(boolean subcompile) {
if (end - start == 0) {
if (type == LIST) return new ArrayList();
else return EMPTY_ARRAY;
}
Map