/** * get date value from <code>ExprValue</code> * @return date value * @throws FormulaException en excption when data type is mismatched */ public Date getDate(){ if (dataType == DataType.Date){ return (Date)value; } throw new FormulaException("Can not get a date value from " + dataType.toString()); }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("nvl function only supports 2 arguments."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 1){ throw new FormulaException("to_double function only supports 1 argument."); } }
@Override public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("bind_raw function only supports less than 2 arguments."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("to_char function only supports 1 or 2 arguments."); } }
@Override public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("not_nvl function only supports 2 arguments."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("to_date function only supports 1 or 2 arguments."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 1){ throw new FormulaException("to_long function only supports 1 argument."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 3){ throw new FormulaException("substr function only supports 3 argument."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("instr function only supports 2 argument."); } }
@Override public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("bind function only supports less than 2 arguments."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 1){ throw new FormulaException("to_string function only supports 1 argument."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 1){ throw new FormulaException("strlen function only supports 1 argument."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("match function only supports 2 argument."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 3){ throw new FormulaException("choice function only supports 3 arguments."); } }
protected void match(char _type){ if( type == _type ) lookAhead(); else throw new FormulaException("mismatched token,index:" + current); } }
/** * get long value from <code>ExprValue</code> * @return long value of the expr value * @throws FormulaException en excption when data type is mismatched */ public long getLong(){ switch (dataType){ case Long:return ((Long)value).longValue(); case Double:return ((Double)value).longValue(); default: } throw new FormulaException("Can not get a long value from " + dataType.toString()); }
/** * to add a argument to argument list * @param arg the argument added * @return this */ public Function addArgument(Expression arg){ if (arg == null){ throw new FormulaException("argument can not be null."); } checkArgument(arg); args.add(arg); return this; }
@Override public Expression customize(String funcName) { try { Class<Function> found = static_mappings.get(funcName); if (found != null) { return found.newInstance(); } found = mappings.get(funcName); if (found != null) { return found.newInstance(); } if (parent != null) { return parent.customize(funcName); } throw new FormulaException("Can not find function :" + funcName); } catch (Exception ex) { LOG.error(ex.getMessage()); throw new FormulaException("Can not create function :" + funcName); } }
/** * get boolean value from <code>ExprValue</code> * @return boolean value * @throws FormulaException en excption when data type is mismatched */ public boolean getBoolean(){ switch (dataType){ case Long: return ((Long) value).longValue() != 0; case Boolean: return ((Boolean) value).booleanValue(); default: } throw new FormulaException("Can not get a boolean value from " + dataType.toString()); }