Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.BindingsMap


  public Object toDataStructure() {
    if (this.isTriple()){
      final Literal subject = (this.termParams.get(0) instanceof Constant)?
          ((Constant) this.termParams.get(0)).getLiteral():
          (Literal)((External) this.termParams.get(0)).evaluate(new BindingsMap());

      final Literal predicate = (this.termName instanceof Constant)?
          ((Constant) this.termName).getLiteral():
          (Literal)((External) this.termName).evaluate(new BindingsMap());

      final Literal object = (this.termParams.get(1) instanceof Constant)?
          ((Constant) this.termParams.get(1)).getLiteral():
          (Literal)((External) this.termParams.get(1)).evaluate(new BindingsMap());

      return new Triple(subject, predicate, object);
    } else {
      final Predicate pred = new Predicate();
      pred.setName(((Constant) this.termName).getLiteral());
      for (final IExpression expr : this.termParams) {
        pred.getParameters().add(  (expr instanceof Constant)?
                      ((Constant) expr).getLiteral():
                      (Literal)((External) expr).evaluate(new BindingsMap()));
      }
      return pred;
    }
  }
View Full Code Here


      final QueryResult result = QueryResult.createInstance();
      Bindings binding;
      // System.out.println(solutions.hasNext());
      while (solutions.hasNext()) {
        sol = solutions.nextSolution();
        binding = new BindingsMap(); // Bindings.createNewInstance();
        final Iterator<String> it = sol.varNames();
        while (it.hasNext()) {
          varname = it.next();
          if (sol.contains(varname)) {
            if (sol.get(varname).isLiteral()) {
View Full Code Here

    }
  }

  private final static BindingsMap readLuposBindingsMap(final InputStream in) throws IOException, ClassNotFoundException {
    if (Bindings.instanceClass == BindingsMap.class) {
      final Bindings b = new BindingsMap();
      final int number = InputHelper.readLuposIntVariableBytes(in);
      if (number < 0) {
        return null;
      }
      for (int i = 0; i < number; i++) {
        final String varName = InputHelper.readLuposString(in);
        final Variable v = new Variable(varName);
        final Literal l = InputHelper.readLuposLiteral(in);
        b.add(v, l);
      }
      return (BindingsMap) b;
    }
    return null;
  }
View Full Code Here

      this.tokenstemp.clear();

      return dbanswer;
    } else {
      System.out.println("Article has no description.");
      return new DBAnswer(new BindingsMap());
    }
  }
View Full Code Here

    /**
     * if none of the label's segments matches one of the title's, return
     * the first successful DBResult
     */
    if(!(detected.isEmpty())) return (detected.get(0));
    return new DBAnswer(new BindingsMap());
  }
View Full Code Here

        qr.add(new BindingsCollection());
    } else if (result instanceof TupleQueryResult) {
      qr = QueryResult.createInstance();
      while (((TupleQueryResult) result).hasNext()) {
        final BindingSet bs = ((TupleQueryResult) result).next();
        final Bindings binding = new BindingsMap();
        for (final Binding b : bs) {
          // Bindings bb = Bindings.createNewInstance();
          final Value v = b.getValue();
          if (v instanceof org.openrdf.model.Literal) {
            final org.openrdf.model.Literal lit = (org.openrdf.model.Literal) v;
            if (lit.getDatatype() != null) {
              binding.add(new Variable(b.getName()),
                  TypedLiteralOriginalContent
                      .createTypedLiteral("\""
                          + lit.getLabel() + "\"",
                          "<" + lit.getDatatype()
                              + ">"));
            } else {
              binding.add(new Variable(b.getName()),
                  LiteralFactory.createLiteral("\""
                      + lit.getLabel() + "\""));
            }
          } else if (v instanceof BNode) {
            binding.add(new Variable(b.getName()),
                new AnonymousLiteral(((BNode) v).toString()));
          } else if (v instanceof URI) {
            binding.add(new Variable(b.getName()), LiteralFactory
                .createURILiteral("<" + (v) + ">"));
          }
        }
        qr.add(binding);
      }
View Full Code Here

   * @param node the ASTBindings node in the abstract syntax tree
   * @return the computed queryresult
   */
  private QueryResult getQueryResultFromValuesClause(final ASTBindings node){
    final QueryResult bindingsQR = QueryResult.createInstance();
    Bindings binding = new BindingsMap();

    // Getting the variables which are used in the BINDINGS clause
    final LinkedList<Variable> varList = new LinkedList<Variable>();

    for (int k = 0; k < node.jjtGetNumChildren(); k++) {
      if (node.jjtGetChild(k) instanceof ASTVar) {
        final ASTVar var2 = (ASTVar) node.jjtGetChild(k);
        final Variable variable = new Variable(var2.getName());
        varList.add(variable);
      }
    }

    // Creating the bindings with the variables and the literals
    for (int j = 0; j < node.jjtGetNumChildren(); j++) {
      if (node.jjtGetChild(j) instanceof ASTPlusNode) {
        binding = new BindingsMap();
        for (int m = 0; m < node.jjtGetChild(j)
            .jjtGetNumChildren(); m++) {
          final Node litNode = node.jjtGetChild(j)
              .jjtGetChild(m);
          if (!(litNode instanceof ASTUndef)) {
            final Literal lit = LazyLiteral.getLiteral(litNode,
                true);
            binding.add(varList.get(m), lit);
          }
        }
        bindingsQR.add(binding);
      }
    }
View Full Code Here

      return result; // empty result
    } else {

      final Iterator<Bindings> it = queryResult.oneTimeIterator();
      while (it.hasNext()) {
        final Bindings b = new BindingsMap();
        final Bindings bindings = it.next();
        b.addAll(bindings);
        result.add(b);
      }
      return result;
    }
  }
View Full Code Here

TOP

Related Classes of lupos.datastructures.bindings.BindingsMap

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.