public Constant Verify(int opPositin, BaseMetadata[] args) { if (args == null) { throw new ArgumentException("运算操作符参数为空"); } if (args.Length != 1) { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数个数不匹配" , THIS_OPERATOR.Token , opPositin ); } BaseMetadata first = args[0]; if (first == null) { throw new NullReferenceException("操作符\"" + THIS_OPERATOR.Token + "\"参数为空"); } if (DataType.DATATYPE_DOUBLE == first.GetDataType()) { return(new Constant(DataType.DATATYPE_DOUBLE, 0.0D)); } else if (DataType.DATATYPE_FLOAT == first.GetDataType()) { return(new Constant(DataType.DATATYPE_FLOAT, 0F)); } else if (DataType.DATATYPE_LONG == first.GetDataType()) { return(new Constant(DataType.DATATYPE_LONG, 0L)); } else if (DataType.DATATYPE_INT == first.GetDataType()) { return(new Constant(DataType.DATATYPE_INT, 0)); } else { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数类型错误" , THIS_OPERATOR.Token , opPositin ); } }
public Constant Verify(int opPositin, BaseMetadata[] args) { if (args == null) { throw new ArgumentException("运算操作符参数为空"); } if (args.Length != 2) { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数个数不匹配" , THIS_OPERATOR.Token , opPositin ); } BaseMetadata first = args[1]; BaseMetadata second = args[0]; if (first == null || second == null) { throw new NullReferenceException("操作符\"" + THIS_OPERATOR.Token + "\"参数为空"); } if (DataType.DATATYPE_DATE == first.GetDataType() && DataType.DATATYPE_DATE == second.GetDataType()) { //日期类型比较 return(new Constant(DataType.DATATYPE_BOOLEAN, false)); } else if (DataType.DATATYPE_STRING == first.GetDataType() && DataType.DATATYPE_STRING == second.GetDataType()) { //字窜类型比较 return(new Constant(DataType.DATATYPE_BOOLEAN, false)); } else if ((DataType.DATATYPE_DOUBLE == first.GetDataType() || DataType.DATATYPE_FLOAT == first.GetDataType() || DataType.DATATYPE_LONG == first.GetDataType() || DataType.DATATYPE_INT == first.GetDataType()) && (DataType.DATATYPE_DOUBLE == second.GetDataType() || DataType.DATATYPE_FLOAT == second.GetDataType() || DataType.DATATYPE_LONG == second.GetDataType() || DataType.DATATYPE_INT == second.GetDataType()) ) { //数值类型比较 return(new Constant(DataType.DATATYPE_BOOLEAN, false)); } else { //LT操作不支持其他类型,抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数类型错误"); } }
public Constant Verify(int opPositin, BaseMetadata[] args) { if (args == null) { throw new ArgumentException("运算操作符参数为空"); } if (args.Length != 2) { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数个数不匹配" , THIS_OPERATOR.Token , opPositin ); } BaseMetadata first = args[1]; BaseMetadata second = args[0]; if (first == null || second == null) { throw new NullReferenceException("操作符\"" + THIS_OPERATOR.Token + "\"参数为空"); } if (DataType.DATATYPE_BOOLEAN == first.GetDataType() && DataType.DATATYPE_BOOLEAN == second.GetDataType()) { return(new Constant(DataType.DATATYPE_BOOLEAN, false)); } else { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数类型错误" , THIS_OPERATOR.Token , opPositin ); } }
public Constant Verify(int opPositin, BaseMetadata[] args) { if (args == null) { throw new ArgumentException("运算操作符参数为空"); } if (args.Length != 2) { //抛异常 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数个数不匹配" , THIS_OPERATOR.Token , opPositin ); } BaseMetadata first = args[1]; BaseMetadata second = args[0]; if (first == null || second == null) { throw new NullReferenceException("操作符\"" + THIS_OPERATOR.Token + "\"参数为空"); } //集合类型EQ运算单独处理 if (DataType.DATATYPE_LIST == first.GetDataType() || DataType.DATATYPE_LIST == second.GetDataType()) { //目前不支持集合EQ比较,(太麻烦鸟).考虑使用后期使用函数实现 throw new IllegalExpressionException("操作符\"" + THIS_OPERATOR.Token + "\"参数类型错误" , THIS_OPERATOR.Token , opPositin); } if (DataType.DATATYPE_STRING == first.GetDataType() || DataType.DATATYPE_STRING == second.GetDataType() || DataType.DATATYPE_NULL == first.GetDataType() || DataType.DATATYPE_NULL == second.GetDataType() || DataType.DATATYPE_BOOLEAN == first.GetDataType() || DataType.DATATYPE_BOOLEAN == second.GetDataType() || DataType.DATATYPE_DATE == first.GetDataType() || DataType.DATATYPE_DATE == second.GetDataType()) { return(new Constant(DataType.DATATYPE_STRING, null)); } else if (DataType.DATATYPE_DOUBLE == first.GetDataType() || DataType.DATATYPE_DOUBLE == second.GetDataType()) { return(new Constant(DataType.DATATYPE_DOUBLE, 0.0D)); } else if (DataType.DATATYPE_FLOAT == first.GetDataType() || DataType.DATATYPE_FLOAT == second.GetDataType()) { return(new Constant(DataType.DATATYPE_FLOAT, 0.0F)); } else if (DataType.DATATYPE_LONG == first.GetDataType() || DataType.DATATYPE_LONG == second.GetDataType()) { return(new Constant(DataType.DATATYPE_LONG, 0L)); } else { return(new Constant(DataType.DATATYPE_INT, 0)); } }