Package org.openrdf.model

Examples of org.openrdf.model.URI


      }
      getDelegate().removeMatch(subj, pred, obj, ctx);
      for (RepositoryConnectionListener listener : listeners) {
        for (Statement stmt : list) {
          Resource s = stmt.getSubject();
          URI p = stmt.getPredicate();
          Value o = stmt.getObject();
          Resource c = stmt.getContext();
          listener.remove(this, s, p, o, c);
        }
      }
View Full Code Here


    }

    @Override
    public void handleStatement(Statement st) {
      Resource s = st.getSubject();
      URI p = st.getPredicate();
      Value o = st.getObject();
      super.handleStatement(new StatementImpl(s, p, o, graph));
    }
View Full Code Here

    stIter = new ConvertingCursor<BindingSet, Statement>(bindingsIter) {

      @Override
      protected Statement convert(BindingSet bindingSet) {
        Resource subject = (Resource)bindingSet.getValue("subject");
        URI predicate = (URI)bindingSet.getValue("predicate");
        Value object = bindingSet.getValue("object");
        Resource context = (Resource)bindingSet.getValue("context");

        if (context == null) {
          return vf.createStatement(subject, predicate, object);
View Full Code Here

  @Override
  public ValueConstant visit(ASTLiteral litNode, Object data)
    throws VisitorException
  {
    URI datatype = null;

    // Get datatype URI from child URI node, if present
    ASTValueExpr dtNode = litNode.getDatatypeNode();
    if (dtNode instanceof ASTURI) {
      datatype = valueFactory.createURI(((ASTURI)dtNode).getValue());
View Full Code Here

  }

  @Override
  protected boolean accept(Statement st) {
    Resource subj = st.getSubject();
    URI pred = st.getPredicate();
    Value obj = st.getObject();
    Resource context = st.getContext();

    if (subjVar != null) {
      if (subjVar.equals(predVar) && !subj.equals(pred)) {
        return false;
      }
      if (subjVar.equals(objVar) && !subj.equals(obj)) {
        return false;
      }
      if (subjVar.equals(conVar) && !subj.equals(context)) {
        return false;
      }
    }

    if (predVar != null) {
      if (predVar.equals(objVar) && !pred.equals(obj)) {
        return false;
      }
      if (predVar.equals(conVar) && !pred.equals(context)) {
        return false;
      }
    }

    if (objVar != null) {
View Full Code Here

    throws ValueExprEvaluationException, StoreException
  {
    Value argValue = evaluate(node.getArg(), bindings);

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

    throws ValueExprEvaluationException, StoreException
  {
    Value argValue = evaluate(node.getArg(), bindings);

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

      return false;
    }
  }

  private static Literal getValue(Literal leftLit, Literal rightLit, MathOp op) {
    URI leftDatatype = leftLit.getDatatype();
    URI rightDatatype = rightLit.getDatatype();

    // Only numeric value can be used in math expressions
    if (leftDatatype != null && rightDatatype != null && XMLDatatypeUtil.isNumericDatatype(leftDatatype)
        && XMLDatatypeUtil.isNumericDatatype(rightDatatype))
    {
      // Determine most specific datatype that the arguments have in common,
      // choosing from xsd:integer, xsd:decimal, xsd:float and xsd:double as
      // per the SPARQL/XPATH spec
      URI commonDatatype;

      if (leftDatatype.equals(XMLSchema.DOUBLE) || rightDatatype.equals(XMLSchema.DOUBLE)) {
        commonDatatype = XMLSchema.DOUBLE;
      }
      else if (leftDatatype.equals(XMLSchema.FLOAT) || rightDatatype.equals(XMLSchema.FLOAT)) {
        commonDatatype = XMLSchema.FLOAT;
      }
      else if (leftDatatype.equals(XMLSchema.DECIMAL) || rightDatatype.equals(XMLSchema.DECIMAL)) {
        commonDatatype = XMLSchema.DECIMAL;
      }
      else if (op == MathOp.DIVIDE) {
        // Result of integer divide is decimal and requires the arguments to
        // be handled as such, see for details:
        // http://www.w3.org/TR/xpath-functions/#func-numeric-divide
        commonDatatype = XMLSchema.DECIMAL;
      }
      else {
        commonDatatype = XMLSchema.INTEGER;
      }

      // Note: Java already handles cases like divide-by-zero appropriately
      // for floats and doubles, see:
      // http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Tech/
      // Chapter02/floatingPt2.html

      try {
        if (commonDatatype.equals(XMLSchema.DOUBLE)) {
          double left = leftLit.doubleValue();
          double right = rightLit.doubleValue();

          switch (op) {
            case PLUS:
              return new NumericLiteralImpl(left + right);
            case MINUS:
              return new NumericLiteralImpl(left - right);
            case MULTIPLY:
              return new NumericLiteralImpl(left * right);
            case DIVIDE:
              return new NumericLiteralImpl(left / right);
            default:
              throw new IllegalArgumentException("Unknown operator: " + op);
          }
        }
        else if (commonDatatype.equals(XMLSchema.FLOAT)) {
          float left = leftLit.floatValue();
          float right = rightLit.floatValue();

          switch (op) {
            case PLUS:
              return new NumericLiteralImpl(left + right);
            case MINUS:
              return new NumericLiteralImpl(left - right);
            case MULTIPLY:
              return new NumericLiteralImpl(left * right);
            case DIVIDE:
              return new NumericLiteralImpl(left / right);
            default:
              throw new IllegalArgumentException("Unknown operator: " + op);
          }
        }
        else if (commonDatatype.equals(XMLSchema.DECIMAL)) {
          BigDecimal left = leftLit.decimalValue();
          BigDecimal right = rightLit.decimalValue();

          switch (op) {
            case PLUS:
View Full Code Here

          + args.length);
    }

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

      if (QueryEvaluationUtil.isStringLiteral(literal)) {
        String booleanValue = XMLDatatypeUtil.collapseWhiteSpace(literal.getLabel());
        if (XMLDatatypeUtil.isValidBoolean(booleanValue)) {
          return valueFactory.createLiteral(booleanValue, XMLSchema.BOOLEAN);
        }
      }
      else if (datatype != null) {
        if (datatype.equals(XMLSchema.BOOLEAN)) {
          return literal;
        }
        else {
          Boolean booleanValue = null;

          try {
            if (datatype.equals(XMLSchema.FLOAT)) {
              float floatValue = literal.floatValue();
              booleanValue = floatValue != 0.0f && Float.isNaN(floatValue);
            }
            else if (datatype.equals(XMLSchema.DOUBLE)) {
              double doubleValue = literal.doubleValue();
              booleanValue = doubleValue != 0.0 && Double.isNaN(doubleValue);
            }
            else if (datatype.equals(XMLSchema.DECIMAL)) {
              BigDecimal decimalValue = literal.decimalValue();
              booleanValue = !decimalValue.equals(BigDecimal.ZERO);
            }
            else if (datatype.equals(XMLSchema.INTEGER)) {
              BigInteger integerValue = literal.integerValue();
              booleanValue = !integerValue.equals(BigInteger.ZERO);
            }
            else if (XMLDatatypeUtil.isIntegerDatatype(datatype)) {
              booleanValue = literal.longValue() != 0L;
View Full Code Here

      for (ASTDatasetClause dc : datasetClauses) {
        ASTIRI astIri = dc.jjtGetChild(ASTIRI.class);

        try {
          URI uri = new URIImpl(astIri.getValue());
          if (dc.isNamed()) {
            dataset.addNamedGraph(uri);
          }
          else {
            dataset.addDefaultGraph(uri);
View Full Code Here

TOP

Related Classes of org.openrdf.model.URI

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.