Package lupos.datastructures.items.literal

Examples of lupos.datastructures.items.literal.Literal


    return n.f0.accept(this, argu);
  }

  public Object visit(final RIFQuotedURIref n, final IRuleNode argu) {
    final String uriRef = (String) n.f0.accept(this, argu);
    Literal literal;
    try {
      literal = LiteralFactory.createURILiteralWithoutLazyLiteral(uriRef);
    } catch (final URISyntaxException e) {
      throw new RIFException(e.toString());
    }
View Full Code Here


    return this.isRecursive;
  }

  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 {
View Full Code Here

    return BooleanLiteral.not(is_nmtoken(arg));
  }

  @Builtin(Name = "iri-string", Bindable = true)
  public static BooleanLiteral iri_string(final Argument arg) {
    Literal left = null;
    if (!arg.arguments.get(0).isVariable())
      left = (Literal) arg.arguments.get(0);
    Literal right = null;
    if (!arg.arguments.get(1).isVariable())
      right = (Literal) arg.arguments.get(1);

    // versuchen beide zu URI-Literalen umzuformen
    if (left != null && !(left instanceof URILiteral)) {
      String uri = null;
      if (left instanceof TypedLiteral)
        uri = ((TypedLiteral) left).getContent();
      else if (right instanceof StringLiteral)
        uri = left.getName();
      else if (left instanceof CodeMapLiteral)
        uri = left.toString();
      try {
        left = LiteralFactory.createURILiteral("<"
            + uri.substring(1, uri.length() - 1) + ">");
      } catch (URISyntaxException e) {
        return null;
      }
    }
    if (right != null && !(right instanceof URILiteral)) {
      String uri = null;
      if (right instanceof TypedLiteral)
        uri = ((TypedLiteral) right).getContent();
      else if (right instanceof StringLiteral)
        uri = right.getName();
      else if (right instanceof CodeMapLiteral)
        uri = right.toString();
      try {
        right = LiteralFactory.createURILiteral("<"
            + uri.substring(1, uri.length() - 1) + ">");
      } catch (URISyntaxException e) {
        return null;
View Full Code Here

  private static boolean matchPossible(final Item[] generateItems,
      final Item[] patItems) { // If there is one Generate literal, which
    // is not equal to corresponding
    // TriplePattern literal, then no match is possible
    Literal patLit;
    Literal generateLit;
    for (int b = 0; b < 3; b++) {
      if ((!generateItems[b].isVariable()) && (!patItems[b].isVariable())) {
        generateLit = (Literal) generateItems[b];
        patLit = (Literal) patItems[b];
        if (!generateLit.equals(patLit)) {
          return false;
        }
      }
    }
    return true;
View Full Code Here

        final JSONArray array = new JSONObject(jsonResult).getJSONArray("result");
        for(int i=0; i<array.length(); i++){
          final JSONObject entry = array.getJSONObject(i);

          final Variable var = Helper.createVariableFromJSON(entry.getJSONObject("variable"));
          Literal min = Helper.createLiteralFromJSON(entry.getJSONObject("minimum"));
          Literal max = Helper.createLiteralFromJSON(entry.getJSONObject("maximum"));

          // compare new min/max with possibly existing ones...

          boolean modified = false;
          final Tuple<Literal, Literal> minMax = result.get(var);
          if(minMax==null){
            modified = true;
          } else {
            final Literal otherMin = minMax.getFirst();
            if(min.compareToNotNecessarilySPARQLSpecificationConform(otherMin)<0){
              modified = true;
            } else {
              min = otherMin;
            }
            final Literal otherMax = minMax.getSecond();
            if(max.compareToNotNecessarilySPARQLSpecificationConform(otherMax)>0){
              modified = true;
            } else {
              max = otherMax;
            }
View Full Code Here

  public QueryResult process(final QueryResult oldBindings,
      final int operandID) {
    final QueryResult qr = QueryResult.createInstance();

    for (final Bindings oldBinding : oldBindings) {
      Literal literal = null;

      // process all items
      for (int i = 0; i < substitutionsLiteralLeft.size(); i++) {
        final Variable itemName = substitutionsLiteralLeft.get(i);
        // oldBinding.add(itemName, substitutionsLiteralRight.get(i));

        // if the item is an unbound variable
        if ((literal = oldBinding.get(itemName)) == null) {
          oldBinding.add(itemName, substitutionsLiteralRight.get(i));
        }
        // if the item is a variable which is already bound
        // and the value differs from the value of the triple
        // which would be used as binding, a conflict is
        // detected
        else if (!literal.valueEquals(substitutionsLiteralRight.get(i))) {
          System.out.println("Error " + this.toString() + ": "
              + itemName + ":" + substitutionsLiteralRight.get(i)
              + "<->" + literal);
          System.out.println(oldBinding);
          return null; // join within triple pattern!
View Full Code Here

    final LinkedList<Variable> replaceLitLeft = replaceLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> replaceLitRight = replaceLit
        .getSubstitutionsLiteralRight();
    Variable var;
    Literal lit;
    // Delete all not projected Tupels from ReplaceLit
    for (int i = 0; i < replaceLitLeft.size(); i++) {
      var = replaceLitLeft.get(i);
      if (!arrayContains(projectionVars, var)) {
        lit = replaceLitRight.get(i);
View Full Code Here

  public static String getKey(final Bindings bindings, final Collection<Variable> joinVariables){
    String keyJoin = "";
    final Iterator<Variable> it = joinVariables.iterator();
    while (it.hasNext()) {
      final Literal literal = bindings.get(it.next());
      if (literal == null) {
        keyJoin = null;
        break;
      }
      keyJoin += "|" + literal.getKey();
    }
    return keyJoin;
  }
View Full Code Here

    // only the keys of the second bindings object have to be
    // checked since the the first bindings object is updated
    for (final Variable b2key : bindings2.getVariableSet()) {

      final Literal literalB2 = bindings2.get(b2key);
      final Literal literalB1 = bindings1.get(b2key);

      // if the literal computed from the second bindings conflicts with
      // the corresponding one located in the first bindings object,
      // null is returned to indicate an unsolvable conflict
      if (literalB1 != null) {
        if (!literalB1.valueEquals(literalB2)) {
          return false;
        }
      }

      // otherwise add the new binding of the key and literal to
View Full Code Here

    // only the keys of the second bindings object have to be
    // checked since the the first bindings object is updated
    for (final Variable b2key : bindings2.getVariableSet()) {

      final Literal literalB2 = bindings2.get(b2key);
      final Literal literalB1 = bindings1.get(b2key);

      // if the literal computed from the second bindings conflicts with
      // the corresponding one located in the first bindings object,
      // null is returned to indicate an unsolvable conflict
      if (literalB1 != null) {
        if (!literalB1.valueEquals(literalB2)) {
          return null;
        }
      }

      // otherwise add the new binding of the key and literal to
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.literal.Literal

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.