Package lupos.rif.model

Examples of lupos.rif.model.Constant


  public IRuleNode visit(RuleVariable obj, IRuleNode arg) throws RIFException {
    return new Constant(bindings.get(obj.getVariable()), arg);
  }

  public IRuleNode visit(Constant obj, IRuleNode arg) throws RIFException {
    return new Constant(obj.getLiteral(), arg);
  }
View Full Code Here


    final RuleList result = new RuleList();
    for (final Item item : arg.arguments) {
      if (item instanceof Variable)
        result.addItem(new RuleVariable(item.getName()));
      else if (item instanceof Literal)
        result.addItem(new Constant((Literal) item, result));
      else if (item instanceof IExpression)
        result.addItem((IExpression) item);
    }
    return result;
  }
View Full Code Here

          continue;
        }
        if (item instanceof Variable)
          list.addItem(new RuleVariable(item.getName()));
        else if (item instanceof Literal)
          list.addItem(new Constant((Literal) item, list));
        else if (item instanceof IExpression)
          list.addItem((IExpression) item);
      }
      return list;
    }
View Full Code Here

        final IExpression expr = original.get(i);
        if (i == index) {
          if (item instanceof Variable)
            list.addItem(new RuleVariable(item.getName()));
          else if (item instanceof Literal)
            list.addItem(new Constant((Literal) item, list));
          else if (item instanceof IExpression)
            list.addItem((IExpression) item);
        }
        list.addItem(expr);
      }
View Full Code Here

      final Item item = arg.arguments.get(1);
      IExpression lookingFor = null;
      if (item instanceof Variable)
        lookingFor = new RuleVariable(item.getName());
      else if (item instanceof Literal)
        lookingFor = new Constant((Literal) item, list);
      else if (item instanceof IExpression)
        lookingFor = (IExpression) item;
      final RuleList results = new RuleList();
      for (int i = 0; i < list.getItems().size(); i++) {
        if (list.getItems().get(i).equals(lookingFor))
          results.addItem(new Constant(BuiltinHelper
              .createXSLiteral(i, "integer"), results));
      }
      return results;
    }
    return null;
View Full Code Here

  public IRuleNode visit(RuleList obj, IRuleNode arg) throws RIFException {
    try {
      //Wenn Liste leer
      if (obj.getItems().isEmpty()) {
        return new Constant(
            LiteralFactory
                .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
            arg);
      }
      Conjunction conjunction = new Conjunction();
      conjunction.setParent(arg);
      int iteration = 0;
      //Listenidentifikator erstellen
      String baseName = aliasString + "list" + listCtr++ + "it";
      conjunction.addExpr(new RuleVariable(baseName + iteration));
      int ctr = obj.getItems().size();
      for (IExpression expr : obj.getItems()) {
        ctr--;
        IRuleNode result = expr.accept(this, conjunction);
        final String itVar = baseName + iteration++;
        if (result instanceof Conjunction) {
          for (IExpression item : new ArrayList<IExpression>(
              ((Conjunction) result).exprs))
            if (item instanceof RulePredicate)
              conjunction.addExpr(item);
            else if (item instanceof RuleVariable)
              result = item;
        }
        final RulePredicate item = new RulePredicate(
            new RuleVariable(itVar),
            new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#first>"),
                arg), (IExpression) result);
        conjunction.addExpr(item);
        final RulePredicate next = new RulePredicate(
            new RuleVariable(itVar),
            new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>"),
                arg),
            ctr == 0 ? new Constant(
                LiteralFactory
                    .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
                arg)
                : new RuleVariable(baseName + iteration));
        conjunction.addExpr(next);
View Full Code Here

            null);
        // Externals in Equality auswerten
        if (replacedEq.leftExpr instanceof External) {
          final Literal evaluated = (Literal) replacedEq.leftExpr
              .evaluate(replace.bindings, null, equalityMap);
          replacedEq.leftExpr = new Constant(evaluated, replacedEq);
        }
        if (replacedEq.rightExpr instanceof External) {
          final Literal evaluated = (Literal) replacedEq.rightExpr
              .evaluate(replace.bindings, null, equalityMap);
          replacedEq.rightExpr = new Constant(evaluated, replacedEq);
        }
        eqResult.getEqualityResult().add(replacedEq);
        equalityMap.put(replacedEq.leftExpr, replacedEq.rightExpr);
        equalityMap.put(replacedEq.rightExpr, replacedEq.leftExpr);
      }
View Full Code Here

TOP

Related Classes of lupos.rif.model.Constant

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.