Package org.openrdf.query.algebra.evaluation

Examples of org.openrdf.query.algebra.evaluation.ValueExprEvaluationException


  }

  public Value evaluate(And node, BindingSet bindings)
    throws ValueExprEvaluationException, StoreException
  {
    ValueExprEvaluationException failure = null;
    for (ValueExpr arg : node.getArgs()) {
      try {
        Value value = evaluate(arg, bindings);
        if (QueryEvaluationUtil.getEffectiveBooleanValue(value) == false) {
          // Argument evaluates to false, we don't need to look any further
View Full Code Here


  }

  public Value evaluate(Or node, BindingSet bindings)
    throws ValueExprEvaluationException, StoreException
  {
    ValueExprEvaluationException failure = null;
    for (ValueExpr arg : node.getArgs()) {
      try {
        Value value = evaluate(arg, bindings);
        if (QueryEvaluationUtil.getEffectiveBooleanValue(value) == true) {
          // Left argument evaluates to true, we don't need to look any
View Full Code Here

          return false;
        }
      }
    }

    throw new ValueExprEvaluationException();
  }
View Full Code Here

        case EQ:
          return valuesEqual(leftVal, rightVal);
        case NE:
          return !valuesEqual(leftVal, rightVal);
        default:
          throw new ValueExprEvaluationException(
              "Only literals with compatible, ordered datatypes can be compared using <, <=, > and >= operators");
      }
    }
  }
View Full Code Here

            // Note: XMLGregorianCalendar.compare() returns compatible
            // values
            // (-1, 0, 1) but INDETERMINATE needs special treatment
            if (compareResult == DatatypeConstants.INDETERMINATE) {
              throw new ValueExprEvaluationException("Indeterminate result for date/time comparison");
            }
          }
          else if (commonDatatype.equals(XMLSchema.STRING)) {
            compareResult = leftLit.getLabel().compareTo(rightLit.getLabel());
          }
        }
        catch (IllegalArgumentException e) {
          // One of the basic-type method calls failed, try syntactic match
          // before throwing an error
          if (leftLit.equals(rightLit)) {
            switch (operator) {
              case EQ:
                return true;
              case NE:
                return false;
            }
          }

          throw new ValueExprEvaluationException(e);
        }
      }
    }

    if (compareResult != null) {
      // Literals have compatible ordered datatypes
      switch (operator) {
        case LT:
          return compareResult.intValue() < 0;
        case LE:
          return compareResult.intValue() <= 0;
        case EQ:
          return compareResult.intValue() == 0;
        case NE:
          return compareResult.intValue() != 0;
        case GE:
          return compareResult.intValue() >= 0;
        case GT:
          return compareResult.intValue() > 0;
        default:
          throw new IllegalArgumentException("Unknown operator: " + operator);
      }
    }
    else {
      // All other cases, e.g. literals with languages, unequal or
      // unordered datatypes, etc. These arguments can only be compared
      // using the operators 'EQ' and 'NE'. See SPARQL's RDFterm-equal
      // operator

      boolean literalsEqual = leftLit.equals(rightLit);

      if (!literalsEqual) {
        if (leftDatatype != null && rightDatatype != null
            && XMLDatatypeUtil.isCalendarDatatype(leftDatatype)
            && XMLDatatypeUtil.isCalendarDatatype(rightDatatype))
        {
          // left and right arguments have different date/time datatypes,
          // these are always unequal
        }
        else if (leftDatatype != null && rightLit.getLanguage() == null || rightDatatype != null
            && leftLit.getLanguage() == null)
        {
          // For literals with unsupported datatypes we don't know if their
          // values are equal
          throw new ValueExprEvaluationException("Unable to compare literals with unsupported types");
        }
      }

      switch (operator) {
        case EQ:
          return literalsEqual;
        case NE:
          return !literalsEqual;
        case LT:
        case LE:
        case GE:
        case GT:
          throw new ValueExprEvaluationException(
              "Only literals with compatible, ordered datatypes can be compared using <, <=, > and >= operators");
        default:
          throw new IllegalArgumentException("Unknown operator: " + operator);
      }
    }
View Full Code Here

    if (value == null) {
      value = bindings.getValue(var.getName());
    }

    if (value == null) {
      throw new ValueExprEvaluationException();
    }

    return value;
  }
View Full Code Here

      else {
        return tripleSource.getValueFactory().createLiteral(literal.getLabel());
      }
    }
    else {
      throw new ValueExprEvaluationException();
    }
  }
View Full Code Here

      else {
        return tripleSource.getValueFactory().createLiteral(literal.getLabel());
      }
    }
    else {
      throw new ValueExprEvaluationException();
    }
  }
View Full Code Here

      }

      return tripleSource.getValueFactory().createLiteral(langTag);
    }

    throw new ValueExprEvaluationException();
  }
View Full Code Here

        // simple literal
        return XMLSchema.STRING;
      }
    }

    throw new ValueExprEvaluationException();
  }
View Full Code Here

TOP

Related Classes of org.openrdf.query.algebra.evaluation.ValueExprEvaluationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.