Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.Var


  public Var visit(ASTReifiedStat node, Object data)
    throws VisitorException
  {
    assert node.getID() != null : "ID variable not set";

    Var subjVar = (Var)node.getSubject().jjtAccept(this, null);
    Var predVar = (Var)node.getPredicate().jjtAccept(this, null);
    Var objVar = (Var)node.getObject().jjtAccept(this, null);
    Var idVar = (Var)node.getID().jjtAccept(this, null);

    Var contextVar = graphPattern.getContextVar();
    StatementPattern.Scope spScope = graphPattern.getStatementPatternScope();

    Var rdfType = new Var("_rdfType", RDF.TYPE);
    Var rdfStatement = new Var("_rdfStatement", RDF.STATEMENT);
    Var rdfSubject = new Var("_rdfSubject", RDF.SUBJECT);
    Var rdfPredicate = new Var("_rdfPredicate", RDF.PREDICATE);
    Var rdfObject = new Var("_rdfObject", RDF.OBJECT);

    graphPattern.addRequiredTE(new StatementPattern(spScope, idVar, rdfType, rdfStatement, contextVar));
    graphPattern.addRequiredTE(new StatementPattern(spScope, idVar, rdfSubject, subjVar, contextVar));
    graphPattern.addRequiredTE(new StatementPattern(spScope, idVar, rdfPredicate, predVar, contextVar));
    graphPattern.addRequiredTE(new StatementPattern(spScope, idVar, rdfObject, objVar, contextVar));
View Full Code Here


  @Override
  public Var visit(ASTVar node, Object data)
    throws VisitorException
  {
    Var var = new Var(node.getName());
    var.setAnonymous(node.isAnonymous());
    return var;
  }
View Full Code Here

  }

  @Override
  public void meet(StatementPattern sp) {
    super.meet(sp);
    Var subjVar = sp.getSubjectVar();
    Var predVar = sp.getPredicateVar();
    Var objVar = sp.getObjectVar();
    Var ctxVar = sp.getContextVar();

    Value subjValue = getVarValue(subjVar, bindings);
    Value predValue = getVarValue(predVar, bindings);
    Value objValue = getVarValue(objVar, bindings);
    Value ctxValue = getVarValue(ctxVar, bindings);
View Full Code Here

      filter.getArg().visit(new VarRenamer(oldVar.getName(), newVar.getName()));

      // Replace SameTerm-filter with an Extension, the old variable name
      // might still be relevant to nodes higher in the tree
      Extension extension = new Extension(filter.getArg());
      extension.addElement(new ExtensionElem(new Var(newVar.getName()), oldVar.getName()));
      filter.replaceWith(extension);
    }
View Full Code Here

      throw new IllegalArgumentException("valueExpr is a: " + valueExpr.getClass());
    }
  }

  private Var createConstVar(Value value) {
    Var var = createAnonVar("-const-" + constantVarID++);
    var.setValue(value);
    return var;
  }
View Full Code Here

    var.setValue(value);
    return var;
  }

  private Var createAnonVar(String varName) {
    Var var = new Var(varName);
    var.setAnonymous(true);
    return var;
  }
View Full Code Here

    TupleExpr result = (TupleExpr)data;

    ProjectionElemList projElemList = new ProjectionElemList();

    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      Var projVar = (Var)node.jjtGetChild(i).jjtAccept(this, null);
      projElemList.addElement(new ProjectionElem(projVar.getName()));
    }

    result = new Projection(result, projElemList);

    if (node.isDistinct()) {
View Full Code Here

  {
    TupleExpr result = (TupleExpr)data;

    // Create a graph query that produces the statements that have the
    // requests resources as subject or object
    Var subjVar = createAnonVar("-descr-subj");
    Var predVar = createAnonVar("-descr-pred");
    Var objVar = createAnonVar("-descr-obj");
    StatementPattern sp = new StatementPattern(subjVar, predVar, objVar);

    if (result == null) {
      result = sp;
    }
    else {
      result = new Join(result, sp);
    }

    List<SameTerm> sameTerms = new ArrayList<SameTerm>(2 * node.jjtGetNumChildren());

    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      ValueExpr resource = (ValueExpr)node.jjtGetChild(i).jjtAccept(this, null);

      sameTerms.add(new SameTerm(subjVar.clone(), resource));
      sameTerms.add(new SameTerm(objVar.clone(), resource));
    }

    ValueExpr constraint = sameTerms.get(0);
    for (int i = 0; i < sameTerms.size(); i++) {
      constraint = new Or(constraint, sameTerms.get(i));
    }

    result = new Filter(result, constraint);

    ProjectionElemList projElemList = new ProjectionElemList();
    projElemList.addElement(new ProjectionElem(subjVar.getName(), "subject"));
    projElemList.addElement(new ProjectionElem(predVar.getName(), "predicate"));
    projElemList.addElement(new ProjectionElem(objVar.getName(), "object"));
    result = new Projection(result, projElemList);

    return result;
  }
View Full Code Here

  @Override
  public Object visit(ASTGraphGraphPattern node, Object data)
    throws VisitorException
  {
    Var oldContext = graphPattern.getContextVar();
    Scope oldScope = graphPattern.getStatementPatternScope();

    ValueExpr newContext = (ValueExpr)node.jjtGetChild(0).jjtAccept(this, null);

    graphPattern.setContextVar(valueExpr2Var(newContext));
View Full Code Here

    ValueExpr subject = (ValueExpr)data;
    ValueExpr predicate = (ValueExpr)propListNode.getVerb().jjtAccept(this, null);
    @SuppressWarnings("unchecked")
    List<ValueExpr> objectList = (List<ValueExpr>)propListNode.getObjectList().jjtAccept(this, null);

    Var subjVar = valueExpr2Var(subject);
    Var predVar = valueExpr2Var(predicate);

    for (ValueExpr object : objectList) {
      Var objVar = valueExpr2Var(object);
      graphPattern.addRequiredSP(subjVar, predVar, objVar);
    }

    ASTPropertyList nextPropList = propListNode.getNextPropertyList();
    if (nextPropList != null) {
View Full Code Here

TOP

Related Classes of org.openrdf.query.algebra.Var

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.