本文整理汇总了Java中org.mvel2.ParserContext.isStrongTyping方法的典型用法代码示例。如果您正苦于以下问题:Java ParserContext.isStrongTyping方法的具体用法?Java ParserContext.isStrongTyping怎么用?Java ParserContext.isStrongTyping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mvel2.ParserContext
的用法示例。
在下文中一共展示了ParserContext.isStrongTyping方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExprValueAccessor
import org.mvel2.ParserContext; //导入方法依赖的package包/类
public ExprValueAccessor(String ex, Class expectedType, Object ctx, VariableResolverFactory factory, ParserContext pCtx) {
stmt = (ExecutableStatement) ParseTools.subCompileExpression(ex.toCharArray(), pCtx);
//if (expectedType.isArray()) {
Class tt = getSubComponentType(expectedType);
Class et = stmt.getKnownEgressType();
if (stmt.getKnownEgressType() != null && !tt.isAssignableFrom(et)) {
if ((stmt instanceof ExecutableLiteral) && canConvert(et, tt)) {
try {
stmt = new ExecutableLiteral(convert(stmt.getValue(ctx, factory), tt));
return;
}
catch (IllegalArgumentException e) {
// fall through;
}
}
if (pCtx != null && pCtx.isStrongTyping())
throw new CompileException("was expecting type: " + tt + "; but found type: " + (et == null ? "null" : et.getName()));
}
}
示例2: OperativeAssign
import org.mvel2.ParserContext; //导入方法依赖的package包/类
public OperativeAssign(String variableName, char[] expr, int operation, int fields, ParserContext pCtx) {
this.varName = variableName;
this.operation = operation;
this.name = expr;
if ((fields & COMPILE_IMMEDIATE) != 0) {
egressType = (statement = (ExecutableStatement) subCompileExpression(expr, pCtx)).getKnownEgressType();
if (pCtx.isStrongTyping()) {
knownInType = ParseTools.__resolveType(egressType);
}
}
}
示例3: handleCond
import org.mvel2.ParserContext; //导入方法依赖的package包/类
private void handleCond(char[] condition, int fields, ParserContext pCtx) {
int cursor = 0;
while (cursor < condition.length && condition[cursor] != ':') cursor++;
if (cursor == condition.length || condition[cursor] != ':')
throw new CompileException("expected : in foreach");
int x;
if ((x = (item = createStringTrimmed(condition, 0, cursor)).indexOf(' ')) != -1) {
String tk = new String(condition, 0, x).trim();
try {
itemType = ParseTools.findClass(null, tk, pCtx);
item = new String(condition, x, cursor - x).trim();
}
catch (ClassNotFoundException e) {
throw new CompileException("cannot resolve identifier: " + tk);
}
}
this.cond = subset(condition, ++cursor);
if ((fields & COMPILE_IMMEDIATE) != 0) {
Class egress = (this.condition = (ExecutableStatement) subCompileExpression(this.cond, pCtx)).getKnownEgressType();
if (itemType != null && egress.isArray()) {
enforceTypeSafety(itemType, getBaseComponentType(this.condition.getKnownEgressType()));
}
else if (pCtx.isStrongTyping()) {
determineIterType(egress);
}
}
}
示例4: BinaryOperation
import org.mvel2.ParserContext; //导入方法依赖的package包/类
public BinaryOperation(int operation, ASTNode left, ASTNode right, ParserContext ctx) {
this.operation = operation;
if ((this.left = left) == null) {
throw new CompileException("not a statement");
}
if ((this.right = right) == null) {
throw new CompileException("not a statement");
}
if (ctx.isStrongTyping()) {
switch (operation) {
case Operator.ADD:
/**
* In the special case of Strings, the return type may leftward propogate.
*/
if (left.getEgressType() == String.class || right.getEgressType() == String.class) {
egressType = String.class;
lType = ParseTools.__resolveType(left.egressType);
rType = ParseTools.__resolveType(right.egressType);
return;
}
default:
if (!left.getEgressType().isAssignableFrom(right.getEgressType())) {
if (right.isLiteral() && canConvert(right.getEgressType(), left.getEgressType())) {
this.right = new LiteralNode(convert(right.getReducedValueAccelerated(null, null, null), left.getEgressType()));
}
else if (!(Number.class.isAssignableFrom(right.getEgressType()) && Number.class.isAssignableFrom(left.getEgressType()))
&& ((!right.getEgressType().isPrimitive() && !left.getEgressType().isPrimitive())
|| (!canConvert(boxPrimitive(left.getEgressType()), boxPrimitive(right.getEgressType()))))) {
throw new CompileException("incompatible types in statement: " + right.getEgressType() + " (compared from: " + left.getEgressType() + ")");
}
}
}
}
if (this.left.isLiteral() && this.right.isLiteral()) {
if (this.left.egressType == this.right.egressType) {
lType = rType = ParseTools.__resolveType(left.egressType);
}
else {
lType = ParseTools.__resolveType(this.left.egressType);
rType = ParseTools.__resolveType(this.right.egressType);
}
}
egressType = getReturnTypeFromOp(operation, this.left.egressType, this.right.egressType);
}