Package org.openrdf.result

Examples of org.openrdf.result.ModelResult


  }

  public boolean hasMatch(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts)
    throws StoreException
  {
    ModelResult stIter = match(subj, pred, obj, includeInferred, contexts);
    try {
      return stIter.hasNext();
    }
    finally {
      stIter.close();
    }
  }
View Full Code Here


    finally {
      nsIter.close();
    }

    // Export statements
    ModelResult stIter = match(subj, pred, obj, includeInferred, contexts);

    try {
      while (stIter.hasNext()) {
        handler.handleStatement(stIter.next());
      }
    }
    finally {
      stIter.close();
    }

    handler.endRDF();
    return handler;
  }
View Full Code Here

  @Override
  public void removeMatch(Resource subj, URI pred, Value obj, Resource... ctx)
    throws StoreException
  {
    if (activated && reportDeltas()) {
      ModelResult stmts;
      stmts = getDelegate().match(subj, pred, obj, false, ctx);
      List<Statement> list = new ArrayList<Statement>();
      try {
        while (stmts.hasNext()) {
          list.add(stmts.next());
        }
      }
      finally {
        stmts.close();
      }
      getDelegate().removeMatch(subj, pred, obj, ctx);
      for (RepositoryConnectionListener listener : listeners) {
        for (Statement stmt : list) {
          Resource s = stmt.getSubject();
View Full Code Here

  {
    testCon.add(bob, name, nameBob);

    assertTrue("Repository should contain statement", testCon.hasMatch(bob, name, nameBob, false));

    ModelResult result = testCon.match(null, name, null, false);

    try {
      assertNotNull("Iterator should not be null", result);
      assertTrue("Iterator should not be empty", result.hasNext());

      while (result.hasNext()) {
        Statement st = result.next();
        assertNull("Statement should not be in a context ", st.getContext());
        assertEquals("Statement predicate should be equal to name ", name, st.getPredicate());
      }
    }
    finally {
      result.close();
    }

    List<Statement> list = testCon.match(null, name, null, false).asList();

    assertNotNull("List should not be null", list);
View Full Code Here

    assertFalse("Repository should not contain statement in context2", testCon.hasMatch(bob, name, nameBob,
        false, context2));

    // Check handling of getStatements without context IDs
    ModelResult result = testCon.match(bob, name, null, false);
    try {
      while (result.hasNext()) {
        Statement st = result.next();
        assertEquals(bob, st.getSubject());
        assertEquals(name, st.getPredicate());
        assertEquals(nameBob, st.getObject());
        assertEquals(context1, st.getContext());
      }
    }
    finally {
      result.close();
    }

    // Check handling of getStatements with a known context ID
    result = testCon.match(null, null, null, false, context1);
    try {
      while (result.hasNext()) {
        Statement st = result.next();
        assertEquals(context1, st.getContext());
      }
    }
    finally {
      result.close();
    }

    // Check handling of getStatements with an unknown context ID
    result = testCon.match(null, null, null, false, unknownContext);
    try {
      assertNotNull(result);
      assertFalse(result.hasNext());
    }
    finally {
      result.close();
    }

    List<Statement> list = testCon.match(null, name, null, false, context1).asList();

    assertNotNull("List should not be null", list);
View Full Code Here

    testCon.add(alice, mbox, mboxAlice, context2);
    testCon.add(context2, publisher, nameAlice);
    testCon.commit();

    // get statements with either no context or context2
    ModelResult iter = testCon.match(null, null, null, false, null, context2);

    try {
      int count = 0;
      while (iter.hasNext()) {
        count++;
        Statement st = iter.next();

        assertTrue(st.getContext() == null || context2.equals(st.getContext()));
      }

      assertEquals("there should be three statements", 3, count);
    }
    finally {
      iter.close();
    }

    // get all statements with context1 or context2. Note that context1 and
    // context2 are both known
    // in the store because they have been created through the store's own
    // value vf.
    iter = testCon.match(null, null, null, false, context1, context2);

    try {
      int count = 0;
      while (iter.hasNext()) {
        count++;
        Statement st = iter.next();
        // we should have _only_ statements from context2
        assertEquals(context2, st.getContext());
      }
      assertEquals("there should be two statements", 2, count);
    }
    finally {
      iter.close();
    }

    // get all statements with unknownContext or context2.
    iter = testCon.match(null, null, null, false, unknownContext, context2);

    try {
      int count = 0;
      while (iter.hasNext()) {
        count++;
        Statement st = iter.next();
        // we should have _only_ statements from context2
        assertEquals(context2, st.getContext());
      }
      assertEquals("there should be two statements", 2, count);
    }
    finally {
      iter.close();
    }

    // add statements to context1
    testCon.begin();
    testCon.add(bob, name, nameBob, context1);
    testCon.add(bob, mbox, mboxBob, context1);
    testCon.add(context1, publisher, nameBob);
    testCon.commit();

    iter = testCon.match(null, null, null, false, context1);
    try {
      assertNotNull(iter);
      assertTrue(iter.hasNext());
    }
    finally {
      iter.close();
    }

    // get statements with either no context or context2
    iter = testCon.match(null, null, null, false, null, context2);
    try {
      int count = 0;
      while (iter.hasNext()) {
        count++;
        Statement st = iter.next();
        // we should have _only_ statements from context2, or without
        // context
        assertTrue(st.getContext() == null || context2.equals(st.getContext()));
      }
      assertEquals("there should be four statements", 4, count);
    }
    finally {
      iter.close();
    }

    // get all statements with context1 or context2
    iter = testCon.match(null, null, null, false, context1, context2);

    try {
      int count = 0;
      while (iter.hasNext()) {
        count++;
        Statement st = iter.next();
        assertTrue(context1.equals(st.getContext()) || context2.equals(st.getContext()));
      }
      assertEquals("there should be four statements", 4, count);
    }
    finally {
      iter.close();
    }
  }
View Full Code Here

    testCon.commit();

    assertTrue(testCon.hasMatch(bob, name, nameBob, false));
    assertTrue(testCon.hasMatch(alice, name, nameAlice, false));

    ModelResult iter = testCon.match(null, null, null, false);

    try {
      testCon.remove(iter);
    }
    finally {
      iter.close();
    }

    assertFalse(testCon.hasMatch(bob, name, nameBob, false));
    assertFalse(testCon.hasMatch(alice, name, nameAlice, false));
View Full Code Here

    throws Exception
  {
    testCon.add(bob, name, nameBob);

    Statement st;
    ModelResult statements = testCon.match(null, null, null, true);
    try {
      st = statements.next();
    }
    finally {
      statements.close();
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(st);
View Full Code Here

    throws Exception
  {
    testCon.add(bob, name, nameBob);

    Statement st;
    ModelResult statements = testCon.match(null, name, nameBob, false);
    try {
      st = statements.next();
    }
    finally {
      statements.close();
    }

    BNode bnode = (BNode)st.getSubject();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    throws Exception
  {
    testCon.add(bob, name, nameBob);

    Statement st;
    ModelResult statements = testCon.match(null, null, null, false);
    try {
      st = statements.next();
    }
    finally {
      statements.close();
    }

    URI uri = st.getPredicate();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.openrdf.result.ModelResult

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.