/// <summary> /// Gets the Effective Boolean Value of this Expression as evaluated for a given Binding /// </summary> /// <param name="context">Evaluation Context</param> /// <param name="bindingID">Binding ID</param> /// <returns></returns> public virtual bool EffectiveBooleanValue(SparqlEvaluationContext context, int bindingID) { try { switch (this.NumericType(context, bindingID)) { case SparqlNumericType.Double: double dblvalue = this.DoubleValue(context, bindingID); return(!(dblvalue == 0.0d)); case SparqlNumericType.Float: float fvalue = this.FloatValue(context, bindingID); return(!(fvalue == 0.0f)); case SparqlNumericType.Decimal: decimal decvalue = this.DecimalValue(context, bindingID); return(!(decvalue == 0)); case SparqlNumericType.Integer: long intvalue = this.IntegerValue(context, bindingID); return(!(intvalue == 0)); default: return(false); } } catch (RdfQueryException) { //return false; return(SparqlSpecsHelper.EffectiveBooleanValue(this.Value(context, bindingID))); } }
/// <summary> /// Creates a new Node Expression /// </summary> /// <param name="n">Node</param> public NodeExpressionTerm(INode n) { this._node = n; //Compute the EBV try { this._ebv = SparqlSpecsHelper.EffectiveBooleanValue(this._node); } catch { this._ebv = false; } }
/// <summary> /// Gets the boolean value. /// </summary> /// <returns></returns> public bool AsBoolean() { switch (_numType) { case SparqlNumericType.Integer: return(AsInteger() != 0); case SparqlNumericType.Decimal: return(AsDecimal() != Decimal.Zero); case SparqlNumericType.Float: return(AsFloat() != 0.0f && !float.IsNaN(AsFloat())); case SparqlNumericType.Double: return(AsDouble() != 0.0d && !double.IsNaN(AsDouble())); default: return(SparqlSpecsHelper.EffectiveBooleanValue(this)); } }
/// <summary> /// Computes the Effective Boolean Value of this Expression as evaluated for a given Binding /// </summary> /// <param name="context">Evaluation Context</param> /// <param name="bindingID">Binding ID</param> /// <returns></returns> public bool EffectiveBooleanValue(SparqlEvaluationContext context, int bindingID) { INode value = this.Value(context, bindingID); return(SparqlSpecsHelper.EffectiveBooleanValue(value)); }
/// <summary> /// Gets the boolean value of the string /// </summary> /// <returns></returns> public bool AsBoolean() { return(SparqlSpecsHelper.EffectiveBooleanValue(this)); }
/// <summary> /// Gets the effective boolean value of the function in the given Evaluation Context for the given Binding ID /// </summary> /// <param name="context">Evaluation Context</param> /// <param name="bindingID">Binding ID</param> /// <returns></returns> public override bool EffectiveBooleanValue(SparqlEvaluationContext context, int bindingID) { return(SparqlSpecsHelper.EffectiveBooleanValue(this.Value(context, bindingID))); }