当前位置: 首页>>代码示例>>Java>>正文


Java Query.isDescribeType方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.query.Query.isDescribeType方法的典型用法代码示例。如果您正苦于以下问题:Java Query.isDescribeType方法的具体用法?Java Query.isDescribeType怎么用?Java Query.isDescribeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.query.Query的用法示例。


在下文中一共展示了Query.isDescribeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sparqlDescribe

import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
/**
 * @return opened result Model
 */
@Override
public ClosableIterable<Statement> sparqlDescribe(String queryString)
        throws ModelRuntimeException {
	assertModel();
	Query query = QueryFactory.create(queryString);
	QueryExecution qexec = QueryExecutionFactory.create(query, this.jenaModel);
	
	if(query.isDescribeType()) {
		com.hp.hpl.jena.rdf.model.Model m = qexec.execDescribe();
		Model resultModel = new ModelImplJena(null, m, Reasoning.none);
		resultModel.open();
		return resultModel;
	} else {
		throw new RuntimeException("Cannot handle this type of queries! Please use DESCRIBE.");
	}
	
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:21,代码来源:ModelImplJena.java

示例2: sparqlDescribe

import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlDescribe(String query)
		throws ModelRuntimeException {
	Query jenaQuery = QueryFactory.create(query);
	QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
			this.dataset);

	if (jenaQuery.isDescribeType()) {
		com.hp.hpl.jena.rdf.model.Model m = qexec.execDescribe();
		Model resultModel = new ModelImplJena(null, m, Reasoning.none);
		resultModel.open();
		return resultModel;
	} else {
		throw new RuntimeException(
				"Cannot handle this type of query! Please use DESCRIBE.");
	}
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:18,代码来源:ModelSetImplJena.java

示例3: showQueryResults

import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
private void showQueryResults(String queryString, HttpServletRequest request, HttpServletResponse response) 
		throws IOException {
	Query query = QueryFactory.create(queryString);
	if(query.isSelectType() || query.isDescribeType()) {
		Config config = new Config(request);
		ResultsFormat fmt = ResultsFormat.lookup(request.getParameter("format"));
		Dataset tdbstore = TDBFactory.createDataset(config.getTripleStoreDir());
		QueryExecution qexec = QueryExecutionFactory.create(query, tdbstore);
		qexec.getContext().set(TDB.symUnionDefaultGraph, true);
		if(query.isSelectType()) {
 			ResultSet results = qexec.execSelect();
 			if(fmt == null) {
 				out.print(queryString+"\n");
 				ResultSetFormatter.out(out, results, query);
 			}
 			else
 				ResultSetFormatter.output(out, results, fmt);
		}
		else {
		  Model model = qexec.execDescribe();
       RDFWriter rdfWriter = model.getWriter("RDF/XML-ABBREV");
       rdfWriter.setProperty("showXmlDeclaration", "true");
       rdfWriter.setProperty("tab", "6");
       rdfWriter.write(model, out, null);
		}
	}
	else {
		out.print("Only select or describe queries allowed");
	}
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:31,代码来源:SparqlEndpoint.java

示例4: execute

import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
@Override
public Object execute(Map<String, EdmLiteral> parameters) throws ODataException
{
   EdmLiteral query_lit = parameters.remove("query");
   // Olingo2 checks for presence of non-nullable parameters for us!
   String query_s = query_lit.getLiteral();
   Query query = QueryFactory.create(query_s);
   if (!(query.isSelectType() || query.isDescribeType()))
   {
      throw new InvalidOperationException(query.getQueryType());
   }

   DrbCortexModel cortexmodel;
   try
   {
      cortexmodel = DrbCortexModel.getDefaultModel();
   }
   catch (IOException ex)
   {
      throw new RuntimeException(ex);
   }

   Model model = cortexmodel.getCortexModel().getOntModel();

   QueryExecution qexec = null;
   // FIXME: QueryExecution in newer versions of Jena (post apache incubation) implement AutoClosable.
   try
   {
      qexec = QueryExecutionFactory.create(query, model);
      if (query.isSelectType())
      {
         ResultSet results = qexec.execSelect();
         return ResultSetFormatter.asXMLString(results);
      }
      else
      {
         Model description = qexec.execDescribe();
         // newer version of Jena have the RIOT package for I/O
         StringWriter strwrt = new StringWriter();
         Abbreviated abb = new Abbreviated();
         abb.write(description, strwrt, null);
         return strwrt.toString();
      }
   }
   finally
   {
      if (qexec != null)
      {
         qexec.close();
      }
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:53,代码来源:Sparql.java


注:本文中的com.hp.hpl.jena.query.Query.isDescribeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。