public ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() < 1){ throw new FormulaException("to_date function need at least 1 argument.we have " + getArgumentCount()); } String pattern = "yyyyMMddHHmmss"; if (getArgument(1) != null){ pattern = getArgument(1).getValue(provider).getString(); } String value = getArgument(0).getValue(provider).getString(); return new ExprValue(DateUtil.parseDate(value, pattern)); } }
public ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() != 2){ throw new FormulaException("nvl function need 2 arguments.we have " + getArgumentCount()); } ExprValue value = getArgument(0).getValue(provider); if (value == null){ value = getArgument(1).getValue(provider); } return value; }
/** * 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 ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() < 1){ throw new FormulaException("to_char function need at least 1 argument.we have " + getArgumentCount()); } String pattern = "yyyyMMddHHmmss"; if (getArgument(1) != null){ pattern = getArgument(1).getValue(provider).getString(); } Date value = getArgument(0).getValue(provider).getDate(); return new ExprValue(DateUtil.formatDate(value, pattern)); } }
public ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() != 1){ throw new FormulaException("to_string function need 1 argument."); } String value = getArgument(0).getValue(provider).toString(); return new ExprValue(value); } }
public ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() != 2){ throw new FormulaException("substr function need 2 argument."); } String srcString = getArgument(0).getValue(provider).getString(); String childString = getArgument(1).getValue(provider).getString(); return new ExprValue(srcString.indexOf(childString)); } }
public ExprValue getValue(DataProvider provider) throws FormulaException { if (getArgumentCount() != 2){ throw new FormulaException("match function need 2 argument."); } String srcString = getArgument(0).getValue(provider).getString(); String regex = getArgument(1).getValue(provider).getString(); return new ExprValue(srcString.matches(regex)); } }
@Override public ExprValue getValue(DataProvider provider){ if (provider == null){ throw new FormulaException("Data provider is null,can not get value of " + varName); } if (varContext == null){ varContext = provider.getContext(varName); } String value = provider.getValue(varName, varContext, null); return value != null ? new ExprValue(value): null; }
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."); } }
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."); } }
public void checkArgument(Expression arg) throws FormulaException { if (getArgumentCount() > 2){ throw new FormulaException("to_char function only supports 1 or 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); } }