Package org.nutz.el.opt.logic

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

package org.nutz.el.opt.logic;

import java.util.Queue;

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

/**
* Not(!)
* @author juqkai(juqkai@gmail.com)
*
*/
public class NotOpt extends AbstractOpt{
  private Object right;
 
  public int fetchPriority() {
    return 7;
  }
  public void wrap(Queue<Object> rpn){
    right = rpn.poll();
  }
 
  public Object calculate() {
    Object rval = calculateItem(this.right);
    if(rval instanceof Boolean){
      return !(Boolean) rval;
    }
    throw new ElException("'!'操作符操作失败!");
  }
 
  public String fetchSelf() {
    return "!";
  }
}
TOP

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

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.