本文整理汇总了Java中com.hp.hpl.jena.query.ResultSetFormatter.asText方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSetFormatter.asText方法的具体用法?Java ResultSetFormatter.asText怎么用?Java ResultSetFormatter.asText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.query.ResultSetFormatter
的用法示例。
在下文中一共展示了ResultSetFormatter.asText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryExecute
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public void queryExecute(Integer testNumber) throws Exception {
String queryString = readFile(path + queryFolder + "/test" + testNumber + "/query.txt",
Charset.defaultCharset());
String queryResultString = readFile(path + queryFolder + "/test"+ testNumber + "/queryresult.txt",
Charset.defaultCharset());
RemediatorQuery query = RemediatorQueryFactory.create(queryString);
RemediatorFederatedQuery federatedQuery = RemediatorFederatedQueryFactory.create(query, voidModel, false);
QueryExecution queryExecution = RemediatorQueryExecutionFactory.create(federatedQuery);
try {
ResultSet results = queryExecution.execSelect();
String resultString = ResultSetFormatter.asText(results);
writeFile(path + queryFolder + "/test"
+ testNumber + "/queryresult.res.txt", resultString.toString() );
assertEquals(resultString.toString(), queryResultString.replaceAll("\\s+",
""), resultString.toString().replaceAll("\\s+", ""));
} catch (Exception e) {
fail(e.getMessage());
} finally {
queryExecution.close();
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:25,代码来源:RemediatorQueryExecutionFactoryTest.java
示例2: queryExecute
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public void queryExecute(Integer testNumber) throws Exception {
String rewrittenQueryString = readFile(path + queryFolder + "/test" + testNumber + "/rewrite.txt",
Charset.defaultCharset());
String queryResultString = readFile(path + queryFolder + "/test"+ testNumber + "/queryresult.txt",
Charset.defaultCharset());
QueryExecution queryExecution = RemediatorQueryExecutionFactory.create(rewrittenQueryString);
try {
ResultSet results = queryExecution.execSelect();
String resultString = ResultSetFormatter.asText(results);
writeFile(path + queryFolder + "/test"
+ testNumber + "/queryresult.res.txt", resultString.toString() );
assertEquals(resultString.toString(), queryResultString.replaceAll("\\s+",
""), resultString.toString().replaceAll("\\s+", ""));
} catch (Exception e) {
fail(e.getStackTrace().toString());
} finally {
queryExecution.close();
}
}
示例3: onCreate
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rdfread_write);
TextView textView = (TextView) findViewById(R.id.rdfTextView);
textView.setMovementMethod(new ScrollingMovementMethod());
// create tdb dataset
File directory = new File(getFilesDir(), "tdb_dataset");
directory.delete();
directory.mkdir();
Dataset dataset = TDBFactory.createDataset(directory.getAbsolutePath()) ;
dataset.begin(ReadWrite.WRITE);
Model model = dataset.getDefaultModel();
// read a turtle file from assets and write them into a tdb backed model
try {
InputStream skos_ttl = getAssets().open("skos.ttl");
RDFDataMgr.read(model, skos_ttl, Lang.TURTLE);
skos_ttl.close();
InputStream geosparql_rdf_xml = getAssets().open("geosparql_vocab_all.rdf");
RDFDataMgr.read(model, geosparql_rdf_xml, Lang.RDFXML);
geosparql_rdf_xml.close();
} catch (IOException e) {
Log.e(TAG, e.toString());
e.printStackTrace();
}
// add some example data
String personURI = "http://somewhere/JohnSmith";
String fullName = "John Smith";
Resource johnSmith = model.createResource(personURI);
johnSmith.addProperty(VCARD.FN, fullName);
dataset.commit();
dataset.end();
// read from tdb and print triples
dataset.begin(ReadWrite.READ);
Query query = QueryFactory.create("SELECT * WHERE { ?s ?p ?o } LIMIT 2");
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect();
String resultString = ResultSetFormatter.asText(results);
Log.d(TAG, resultString);
StringWriter dump = new StringWriter();
RDFDataMgr.write(dump, dataset, RDFFormat.JSONLD_PRETTY);
dataset.end();
dataset.close();
textView.setText(dump.toString());
}
示例4: executar
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public static String executar(String queryText) {
Query query = QueryFactory.create(queryText);
QueryExecution qExe = QueryExecutionFactory.sparqlService(Endpoint.getURL(), query);
ResultSet results = qExe.execSelect();
return ResultSetFormatter.asText(results);
}
示例5: getFormattedResults
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public String getFormattedResults() {
if (this.results == null)
return "no query executed.";
this.results.reset();
String formattedResults = ResultSetFormatter.asText(this.results);
formattedResults = StringEscapeUtils.escapeXml(formattedResults);
formattedResults = "<pre>" + formattedResults + "</pre>";
return formattedResults;
}