Package org.nutz.el.opt.logic

Source Code of org.nutz.el.opt.logic.OrOpt

package org.nutz.el.opt.logic;

import org.nutz.el.ElException;
import org.nutz.el.opt.TwoTernary;

/**
* or(||)
* @author juqkai(juqkai@gmail.com)
*
*/
public class OrOpt extends TwoTernary{
   
    public int fetchPriority() {
        return 12;
    }
    public Object calculate() {
        Object lval = calculateItem(left);
        if(!(lval instanceof Boolean)){
            throw new ElException("操作数类型错误!");
        }
        if((Boolean)lval){
            return true;
        }
        Object rval = calculateItem(right);
        if(!(rval instanceof Boolean)){
            throw new ElException("操作数类型错误!");
        }
        if((Boolean)rval){
            return true;
        }
        return false;
    }
    public String fetchSelf() {
        return "||";
    }

}
TOP

Related Classes of org.nutz.el.opt.logic.OrOpt

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.