Package org.openrdf.query.algebra.evaluation

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


    if (argValue instanceof URI) {
      URI uri = (URI)argValue;
      return tripleSource.getValueFactory().createURI(uri.getNamespace());
    }
    else {
      throw new ValueExprEvaluationException();
    }
  }
View Full Code Here


    if (argValue instanceof URI) {
      URI uri = (URI)argValue;
      return tripleSource.getValueFactory().createLiteral(uri.getLocalName());
    }
    else {
      throw new ValueExprEvaluationException();
    }
  }
View Full Code Here

            break;
          case 'u':
            f |= Pattern.UNICODE_CASE;
            break;
          default:
            throw new ValueExprEvaluationException(flags);
        }
      }
      Pattern pattern = Pattern.compile(ptn, f);
      boolean result = pattern.matcher(text).find();
      return BooleanLiteralImpl.valueOf(result);
    }

    throw new ValueExprEvaluationException();
  }
View Full Code Here

      }

      return BooleanLiteralImpl.valueOf(result);
    }

    throw new ValueExprEvaluationException();

  }
View Full Code Here

    else if (val instanceof Literal) {
      strVal = ((Literal)val).getLabel();
    }

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

    if (!node.isCaseSensitive()) {
      // Convert strVal to lower case, just like the pattern has been done
      strVal = strVal.toLowerCase();
View Full Code Here

      Value rightValue = evaluate(node.getRightArg(), bindings);
      if (QueryEvaluationUtil.getEffectiveBooleanValue(rightValue) == false) {
        return BooleanLiteralImpl.FALSE;
      }
      else {
        throw new ValueExprEvaluationException();
      }
    }

    // Left argument evaluated to 'true', result is determined
    // by the evaluation of the right argument.
View Full Code Here

      Value rightValue = evaluate(node.getRightArg(), bindings);
      if (QueryEvaluationUtil.getEffectiveBooleanValue(rightValue) == true) {
        return BooleanLiteralImpl.TRUE;
      }
      else {
        throw new ValueExprEvaluationException();
      }
    }

    // Left argument evaluated to 'false', result is determined
    // by the evaluation of the right argument.
View Full Code Here

  public Literal evaluate(ValueFactory valueFactory, Value... args)
    throws ValueExprEvaluationException
  {
    if (args.length != 1) {
      throw new ValueExprEvaluationException("xsd:double cast requires exactly 1 argument, got "
          + args.length);
    }

    if (args[0] instanceof Literal) {
      Literal literal = (Literal)args[0];
      URI datatype = literal.getDatatype();

      if (QueryEvaluationUtil.isStringLiteral(literal)) {
        String doubleValue = XMLDatatypeUtil.collapseWhiteSpace(literal.getLabel());
        if (XMLDatatypeUtil.isValidDouble(doubleValue)) {
          return valueFactory.createLiteral(doubleValue, XMLSchema.DOUBLE);
        }
      }
      else if (datatype != null) {
        if (datatype.equals(XMLSchema.DOUBLE)) {
          return literal;
        }
        else if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
          // FIXME: doubles must be processed separately, see
          // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
          try {
            double doubleValue = literal.doubleValue();
            return valueFactory.createLiteral(doubleValue);
          }
          catch (NumberFormatException e) {
            throw new ValueExprEvaluationException(e.getMessage(), e);
          }
        }
        else if (datatype.equals(XMLSchema.BOOLEAN)) {
          try {
            return valueFactory.createLiteral(literal.booleanValue() ? 1.0 : 0.0);
          }
          catch (IllegalArgumentException e) {
            throw new ValueExprEvaluationException(e.getMessage(), e);
          }
        }
      }
    }

    throw new ValueExprEvaluationException("Invalid argument for xsd:double cast: " + args[0]);
  }
View Full Code Here

  public Literal evaluate(ValueFactory valueFactory, Value... args)
    throws ValueExprEvaluationException
  {
    if (args.length != 1) {
      throw new ValueExprEvaluationException("xsd:integer cast requires exactly 1 argument, got "
          + args.length);
    }

    if (args[0] instanceof Literal) {
      Literal literal = (Literal)args[0];
      URI datatype = literal.getDatatype();

      if (QueryEvaluationUtil.isStringLiteral(literal)) {
        String integerValue = XMLDatatypeUtil.collapseWhiteSpace(literal.getLabel());
        if (XMLDatatypeUtil.isValidInteger(integerValue)) {
          return valueFactory.createLiteral(integerValue, XMLSchema.INTEGER);
        }
      }
      else if (datatype != null) {
        if (datatype.equals(XMLSchema.INTEGER)) {
          return literal;
        }
        else if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
          // FIXME: decimals, floats and doubles must be processed
          // separately, see
          // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
          try {
            BigInteger integerValue = literal.integerValue();
            return valueFactory.createLiteral(integerValue.toString(), XMLSchema.INTEGER);
          }
          catch (NumberFormatException e) {
            throw new ValueExprEvaluationException(e.getMessage(), e);
          }
        }
        else if (datatype.equals(XMLSchema.BOOLEAN)) {
          try {
            return valueFactory.createLiteral(literal.booleanValue() ? "1" : "0", XMLSchema.INTEGER);
          }
          catch (IllegalArgumentException e) {
            throw new ValueExprEvaluationException(e.getMessage(), e);
          }
        }
      }
    }

    throw new ValueExprEvaluationException("Invalid argument for xsd:integer cast: " + args[0]);
  }
View Full Code Here

  public Literal evaluate(ValueFactory valueFactory, Value... args)
    throws ValueExprEvaluationException
  {
    if (args.length != 1) {
      throw new ValueExprEvaluationException("xsd:string cast requires exactly 1 argument, got " + args.length);
    }

    Value value = args[0];
    if (value instanceof URI) {
      return valueFactory.createLiteral(value.toString(), XMLSchema.STRING);
    }
    else if (value instanceof Literal) {
      Literal literal = (Literal)value;
      URI datatype = literal.getDatatype();

      if (QueryEvaluationUtil.isSimpleLiteral(literal)) {
        return valueFactory.createLiteral(literal.getLabel(), XMLSchema.STRING);
      }
      else if (datatype != null) {
        if (datatype.equals(XMLSchema.STRING)) {
          return literal;
        }
        else if (XMLDatatypeUtil.isNumericDatatype(datatype) || datatype.equals(XMLSchema.BOOLEAN)
            || datatype.equals(XMLSchema.DATETIME))
        {
          // FIXME: conversion to xsd:string is much more complex than
          // this, see
          // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
          return valueFactory.createLiteral(literal.getLabel(), XMLSchema.STRING);
        }
      }
    }

    throw new ValueExprEvaluationException("Invalid argument for xsd:string cast: " + value);
  }
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.