本文整理汇总了Java中com.hp.hpl.jena.query.ResultSetFormatter.toList方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSetFormatter.toList方法的具体用法?Java ResultSetFormatter.toList怎么用?Java ResultSetFormatter.toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.query.ResultSetFormatter
的用法示例。
在下文中一共展示了ResultSetFormatter.toList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public List<String> getResult(InputStream in, String query){
Model model=ModelFactory.createDefaultModel();
model.read(in,null,"TTL");
Query q = QueryFactory.create(query);
QueryExecution qe = QueryExecutionFactory.create(q, model);
ResultSet qresults = qe.execSelect();
List<QuerySolution> solutions=ResultSetFormatter.toList(qresults);
List<String> results=new ArrayList<String>();
for(QuerySolution qs:solutions){
results.add(qs.toString());
}
return results;
}
示例2: getInstances
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
private void getInstances() {
File metricFile = new File(
System.getProperty("user.dir") + "/sparql/queries/getInstances.sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
ParameterizedSparqlString pss = new ParameterizedSparqlString();
pss.setCommandText(queryString);
pss.setLiteral("typename", typename);
data.begin(ReadWrite.READ);
List<QuerySolution> rlist = null;
try (QueryExecution qe = QueryExecutionFactory.create(pss.asQuery(), data)) {
ResultSet results = qe.execSelect();
rlist = ResultSetFormatter.toList(results);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
e.printStackTrace();
}
instances = new String[rlist.size()];
for(int j = 0; j < rlist.size(); j++){
instances[j] = rlist.get(j).getLiteral("iname").getString();
}
data.end();
}
示例3: getSubtypes
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
private void getSubtypes() {
File metricFile = new File(
System.getProperty("user.dir") + "/sparql/queries/getSubtypes.sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
ParameterizedSparqlString pss = new ParameterizedSparqlString();
pss.setCommandText(queryString);
pss.setLiteral("typename", typename);
data.begin(ReadWrite.READ);
List<QuerySolution> rlist = null;
try (QueryExecution qe = QueryExecutionFactory.create(pss.asQuery(), data)) {
ResultSet results = qe.execSelect();
rlist = ResultSetFormatter.toList(results);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
e.printStackTrace();
}
data.end();
subtypes= new String[rlist.size()];
for(int j = 0; j < rlist.size(); j++){
subtypes[j] = rlist.get(j).getLiteral("sname").getString();
}
}
示例4: getDistantEntities
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
private void getDistantEntities(){
File metricFile = new File(
System.getProperty("user.dir") + "/sparql/smells/SemanticallyDistantEntity.sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
data.begin(ReadWrite.READ);
List<QuerySolution> rlist = null;
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
try (QueryExecution qe = QueryExecutionFactory.create(query, data)) {
ResultSet results = qe.execSelect();
rlist = ResultSetFormatter.toList(results);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
e.printStackTrace();
}
instances = new String[rlist.size()];
for(int j = 0; j < rlist.size(); j++){
instances[j] = rlist.get(j).getLiteral("entityname").getString();
}
data.end();
}
示例5: getDistantTypes
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
private void getDistantTypes(){
File metricFile = new File(
System.getProperty("user.dir") + "/sparql/smells/SemanticallyDistantType.sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
data.begin(ReadWrite.READ);
List<QuerySolution> rlist = null;
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
try (QueryExecution qe = QueryExecutionFactory.create(query, data)) {
ResultSet results = qe.execSelect();
rlist = ResultSetFormatter.toList(results);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
e.printStackTrace();
}
subtypes = new String[rlist.size()];
for(int j = 0; j < rlist.size(); j++){
subtypes[j] = rlist.get(j).getLiteral("typename").getString();
}
data.end();
}
示例6: executeQuery
import com.hp.hpl.jena.query.ResultSetFormatter; //导入方法依赖的package包/类
public void executeQuery() {
Query query = this.geraConsultaSPARQL(this.listaDePalavrasParaPesquisa);
QueryExecution qe = QueryExecutionFactory.create(query, this.getOntologia());
ResultSet results = qe.execSelect();
this.lstResultados = ResultSetFormatter.toList(results);
qe.close();
}