⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ceil.java

📁 mysql集群
💻 JAVA
字号:
/*****************************************************************************      SQLJEP - Java SQL Expression Parser 0.2      November 1 2006         (c) Copyright 2006, Alexey Gaidukov      SQLJEP Author: Alexey Gaidukov      SQLJEP is based on JEP 2.24 (http://www.singularsys.com/jep/)           (c) Copyright 2002, Nathan Funk       See LICENSE.txt for license information.*****************************************************************************/package com.meidusa.amoeba.sqljep.function;import java.math.BigDecimal;import com.meidusa.amoeba.sqljep.function.PostfixCommand;import com.meidusa.amoeba.sqljep.ASTFunNode;import com.meidusa.amoeba.sqljep.JepRuntime;import com.meidusa.amoeba.sqljep.ParseException;public class Ceil extends PostfixCommand {	final public int getNumberOfParameters() {		return 1;	}		public Comparable<?>[] evaluate(ASTFunNode node, JepRuntime runtime) throws ParseException {		node.childrenAccept(runtime.ev, null);		Comparable<?>  param = runtime.stack.pop();		return new Comparable<?>[]{param};	}	public static Comparable<?>  ceil(Comparable<?>  param) throws ParseException {		if (param == null) {			return null;		}		if (param instanceof String) {			param = parse((String)param);		}		if (param instanceof BigDecimal) {		// BigInteger is not supported			BigDecimal b = ((BigDecimal)param).setScale(0, BigDecimal.ROUND_CEILING);			try {				return b.longValueExact();			} catch (ArithmeticException e) {			}			return b;		}		if (param instanceof Double || param instanceof Float) {			return Math.ceil(((Number)param).doubleValue());		}		if (param instanceof Number) {		// Long, Integer, Short, Byte 			return param;		}		throw new ParseException(WRONG_TYPE+" ceil("+param.getClass()+")");	}	public Comparable<?> getResult(Comparable<?>... comparables)			throws ParseException {		return ceil(comparables[0]);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -