Package spark.api

Examples of spark.api.Result


      }
      throw e;
    }
    assert parser != null:"Could not find result parser";
   
    Result result = null;
    try {
      result = parser.parse(cmd, entity.getContent(), expectedType);
    } catch (IOException e) {
      throw new SparqlException("Error reading response from server", e);
    }
   
    if (result == null) {
      // Don't know how we got here, but parser should have returned a result or thrown an exception.
      throw new IllegalStateException("Could not parse result from server response.");
    }
   
    // Should never happen because the result format should have been validated against the expected
    // class when selecting the format to use for parsing, but check anyways.
    if (expectedType != null && !expectedType.getResultClass().isInstance(result)) {
      try {
        result.close();
      } catch (IOException e) {
        logger.warn("Error closing result of incorrect type", e);
      }
      throw new IllegalStateException("Result parsed from server response (" +
          result.getClass().getName() + ") does not match expected result type (" + expectedType + ")");
    }
   
    return result;
  }
View Full Code Here


  public static void testAsk() throws Exception {
    DataSource myDS = new ProtocolDataSource("http://DBpedia.org/sparql");
    Connection conn = myDS.getConnection(NoCredentials.INSTANCE);
    Command query = conn.createCommand("ASK { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");   
   
    Result r = query.execute();
    showMetadata(r);
    logger.debug("result = {}", ((BooleanResult)r).getResult());
   
    r.close();
    query.close();
    conn.close();
    myDS.close();
  }
View Full Code Here

TOP

Related Classes of spark.api.Result

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.