当前位置: 首页>>代码示例>>Java>>正文


Java ParserContext.isStrongTyping方法代码示例

本文整理汇总了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()));
    }
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:21,代码来源:ExprValueAccessor.java

示例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);
        }
    }
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:14,代码来源:OperativeAssign.java

示例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);
        }
    }
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:34,代码来源:ForEachNode.java

示例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);

}
 
开发者ID:codehaus,项目名称:mvel,代码行数:54,代码来源:BinaryOperation.java


注:本文中的org.mvel2.ParserContext.isStrongTyping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。