Exemple #1
0
    @Override
    protected QueryIterator processMethod() throws AsyncException {
      // subject a variable.

      if (objectArgs.size() != 2)
        throw new ExprEvalException("ListIndex : object not a list of length 2");
      Node indexNode = objectArgs.get(0);
      Node memberNode = objectArgs.get(1);

      final Collection<Node> x;
      if (!Var.isVar(memberNode))
        // If memberNode is defined, find lists containing it.
        x =
            GraphList.listFromMember(
                getHandler("x"), new GNode(execCxt.getActiveGraph(), memberNode));
      else
        // Hard. Subject unbound, no fixed member. Find every list and use BFI.
        x = GraphList.findAllLists(getHandler("x"), execCxt.getActiveGraph());
      return listIndex.super.allLists(
          getHandler(""),
          binding,
          x,
          listVar,
          predicate,
          new PropFuncArg(objectArgs, null),
          execCxt);
    }
Exemple #2
0
    @Override
    protected QueryIterator processMethod() throws AsyncException {
      if (Var.isVar(listNode))
        throw new ExprEvalException("ListIndex : subject not a list or variable bound to a list");

      if (objectArgs.size() != 2)
        throw new ExprEvalException("ListIndex : object not a list of length 2");

      Node indexNode = objectArgs.get(0);
      Node memberNode = objectArgs.get(1);

      Graph graph = execCxt.getActiveGraph();

      if (Var.isVar(indexNode) && !Var.isVar(memberNode))
        return findIndex(
            getHandler(""), graph, binding, listNode, Var.alloc(indexNode), memberNode, execCxt);

      //	        if ( ! Var.isVar(indexNode) && Var.isVar(memberNode) )
      //	            return getByIndex(getHandler(""), graph, binding, listNode, indexNode,
      // Var.alloc(memberNode), execCxt) ;
      //
      //	        if ( ! Var.isVar(indexNode) && ! Var.isVar(memberNode) )
      //	            return testSlotValue(getHandler(""), graph, binding, listNode, indexNode,
      // memberNode, execCxt) ;

      return findIndexMember(
          getHandler(""),
          graph,
          binding,
          listNode,
          Var.alloc(indexNode),
          Var.alloc(memberNode),
          execCxt);
    }