Example #1
0
 private QueryIterator length(
     Binding binding, Graph graph, Node listNode, Var varLength, ExecutionContext execCxt) {
   int x = GraphList.length(new GNode(graph, listNode));
   if (x < 0) return IterLib.noResults(execCxt);
   Node n = NodeFactoryExtra.intToNode(x);
   return IterLib.oneResult(binding, varLength, n, execCxt);
 }
Example #2
0
  private QueryIterator verify(
      Binding binding, Graph graph, Node listNode, Node length, ExecutionContext execCxt) {
    int x = GraphList.length(new GNode(graph, listNode));
    int len = NodeFactoryExtra.nodeToInt(length);

    if (x == len) return IterLib.result(binding, execCxt);
    return IterLib.noResults(execCxt);
  }
  // Remove all triples associated with this magic property.
  // Make an instance record.
  private static PropertyFunctionInstance magicProperty(
      Context context, Triple pfTriple, BasicPattern triples) {
    List<Triple> listTriples = new ArrayList<>();

    GNode sGNode = new GNode(triples, pfTriple.getSubject());
    GNode oGNode = new GNode(triples, pfTriple.getObject());
    List<Node> sList = null;
    List<Node> oList = null;

    if (GraphList.isListNode(sGNode)) {
      sList = GraphList.members(sGNode);
      GraphList.allTriples(sGNode, listTriples);
    }
    if (GraphList.isListNode(oGNode)) {
      oList = GraphList.members(oGNode);
      GraphList.allTriples(oGNode, listTriples);
    }

    PropFuncArg subjArgs = new PropFuncArg(sList, pfTriple.getSubject());
    PropFuncArg objArgs = new PropFuncArg(oList, pfTriple.getObject());

    // Confuses single arg with a list of one.
    PropertyFunctionInstance pfi =
        new PropertyFunctionInstance(subjArgs, pfTriple.getPredicate(), objArgs);

    triples.getList().removeAll(listTriples);
    return pfi;
  }