public static Boolean coerceValueToBoolean(ValueEval ve, boolean stringsAreBlanks) throws EvaluationException {if (ve == null || ve == BlankEval.instance) {return null;}if (ve instanceof BoolEval) {return Boolean.valueOf(((BoolEval) ve).getBooleanValue());}if (ve instanceof StringEval) {if (stringsAreBlanks) {return null;}String str = ((StringEval) ve).getStringValue();if (str.equalsIgnoreCase("true")) {return Boolean.TRUE;}if (str.equalsIgnoreCase("false")) {return Boolean.FALSE;}throw new EvaluationException(ErrorEval.VALUE_INVALID);}if (ve instanceof NumericValueEval) {NumericValueEval ne = (NumericValueEval) ve;double d = ne.getNumberValue();if (Double.isNaN(d)) {throw new EvaluationException(ErrorEval.VALUE_INVALID);}return Boolean.valueOf(d != 0);}if (ve instanceof ErrorEval) {throw new EvaluationException((ErrorEval) ve);}throw new RuntimeException("Unexpected eval (" + ve.getClass().getName() + ")");}

public static Boolean coerceValueToBoolean ( ValueEval ve , boolean stringsAreBlanks ) throws EvaluationException { if ( ve == null || ve == BlankEval . instance ) { return null ; } if ( ve instanceof BoolEval ) { return Boolean . valueOf ( ( ( BoolEval ) ve ) . getBooleanValue ( ) ) ; } if ( ve instanceof StringEval ) { if ( stringsAreBlanks ) { return null ; } String str = ( ( StringEval ) ve ) . getStringValue ( ) ; if ( str . equalsIgnoreCase ( "true" ) ) { return Boolean . TRUE ; } if ( str . equalsIgnoreCase ( "false" ) ) { return Boolean . FALSE ; } throw new EvaluationException ( ErrorEval . VALUE_INVALID ) ; } if ( ve instanceof NumericValueEval ) { NumericValueEval ne = ( NumericValueEval ) ve ; double d = ne . getNumberValue ( ) ; if ( Double . isNaN ( d ) ) { throw new EvaluationException ( ErrorEval . VALUE_INVALID ) ; } return Boolean . valueOf ( d != 0 ) ; } if ( ve instanceof ErrorEval ) { throw new EvaluationException ( ( ErrorEval ) ve ) ; } throw new RuntimeException ( "Unexpected eval (" + ve . getClass ( ) . getName ( ) + ")" ) ; }
public static Boolean? CoerceValueToBoolean(ValueEval ve, bool stringsAreBlanks){if (ve == null || ve == BlankEval.instance){return null;}if (ve is BoolEval){return ((BoolEval)ve).BooleanValue;}if (ve is StringEval){if (stringsAreBlanks){return null;}String str = ((StringEval)ve).StringValue;if (str.Equals("true", StringComparison.OrdinalIgnoreCase)){return true;}if (str.Equals("false", StringComparison.OrdinalIgnoreCase)){return false;}throw new EvaluationException(ErrorEval.VALUE_INVALID);}if (ve is NumericValueEval){NumericValueEval ne = (NumericValueEval)ve;double d = ne.NumberValue;if (Double.IsNaN(d)){throw new EvaluationException(ErrorEval.VALUE_INVALID);}return d != 0;}if (ve is ErrorEval){throw new EvaluationException((ErrorEval)ve);}throw new InvalidOperationException("Unexpected eval (" + ve.GetType().Name + ")");}
