本文整理汇总了Java中org.openrdf.query.resultio.QueryResultIO.createParser方法的典型用法代码示例。如果您正苦于以下问题:Java QueryResultIO.createParser方法的具体用法?Java QueryResultIO.createParser怎么用?Java QueryResultIO.createParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.query.resultio.QueryResultIO
的用法示例。
在下文中一共展示了QueryResultIO.createParser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newSparqlBooleanReader
import org.openrdf.query.resultio.QueryResultIO; //导入方法依赖的package包/类
public static BooleanQueryResultParser newSparqlBooleanReader(
final BooleanQueryResultFormat format) {
final BooleanQueryResultParser parser = QueryResultIO.createParser(format);
parser.setValueFactory(Data.getValueFactory());
return parser;
}
示例2: testGraphQuery
import org.openrdf.query.resultio.QueryResultIO; //导入方法依赖的package包/类
/**
* test get Graph Query.
* @throws Exception The test would fails if Exception occurs
*/
@Test
public void testGraphQuery() throws Exception {
//insert some statments first
for (final String tripleAsString : _data) {
final Statement triple = parseNX(tripleAsString).iterator().next();
TRIPLE_STORE.addData(triple);
}
//test Graph Query
String queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } ";
String uri = BASE_URI + Protocol.REPOSITORIES + "/" + REPO_ID;
File tmp = WebTestUtils.tmpFile();
final ServletOutputStream servletOutputStream = new StubServletOutputStream(tmp);
final HttpServletRequest request = mockHttpRequest(uri, METHOD_POST);
when(request.getContentType()).thenReturn(MIMETYPE_WWW_FORM);
when(request.getParameter(Protocol.QUERY_LANGUAGE_PARAM_NAME)).thenReturn(QueryLanguage.SPARQL.toString());
when(request.getParameter(Protocol.QUERY_PARAM_NAME)).thenReturn(queryString);
when(request.getParameter(Protocol.ACCEPT_PARAM_NAME)).thenReturn("application/x-binary-rdf-results-table");
Vector<String> vec = new Vector<String>();
when(request.getParameterNames()).thenReturn(vec.elements());
when(request.getCharacterEncoding()).thenReturn(UTF_8);
final HttpServletResponse response = mock(HttpServletResponse.class);
when(response.getOutputStream()).thenReturn(servletOutputStream);
_classUnderTest.service(request, response);
Set<TupleQueryResultFormat> tqrFormats = TupleQueryResultParserRegistry.getInstance().getKeys();
TupleQueryResultFormat format = TupleQueryResultFormat.matchMIMEType("application/x-binary-rdf-results-table", tqrFormats);
TupleQueryResultParser parser = QueryResultIO.createParser(format, valueFactory);
FileInputStream in = new FileInputStream(tmp);
BackgroundTupleResult tRes = new BackgroundTupleResult(parser, in, null);
parser.setQueryResultHandler(tRes);
parser.parseQueryResult(in);
assertTrue(tRes.hasNext());
verify(response).setStatus(HttpServletResponse.SC_OK);
servletOutputStream.close();
}
示例3: parse
import org.openrdf.query.resultio.QueryResultIO; //导入方法依赖的package包/类
private void parse(InputStream in, TupleQueryResultFormat format, QueryResultHandler handler, ValueFactory valueFactory) throws IOException, QueryResultParseException, QueryResultHandlerException, UnsupportedQueryResultFormatException {
QueryResultParser parser = QueryResultIO.createParser(format);
parser.setValueFactory(valueFactory);
parser.setQueryResultHandler(handler);
parser.parseQueryResult(in);
}
示例4: sendTupleQuery
import org.openrdf.query.resultio.QueryResultIO; //导入方法依赖的package包/类
/**
* TupleQuery
*
* @param queryString
* @param bindings
* @param start
* @param pageLength
* @param includeInferred
* @param baseURI
* @return
* @throws RepositoryException
* @throws MalformedQueryException
* @throws UnauthorizedException
* @throws QueryInterruptedException
*/
public TupleQueryResult sendTupleQuery(String queryString,SPARQLQueryBindingSet bindings, long start, long pageLength, boolean includeInferred, String baseURI) throws RepositoryException, MalformedQueryException,
QueryInterruptedException {
InputStream stream = null;
try {
stream = getClient().performSPARQLQuery(queryString, bindings, start, pageLength, this.tx, includeInferred, baseURI);
} catch (JsonProcessingException e) {
logger.error(e.getLocalizedMessage());
throw new MarkLogicSesameException("Issue processing json.");
}
TupleQueryResultParser parser = QueryResultIO.createParser(format, getValueFactory());
MarkLogicBackgroundTupleResult tRes = new MarkLogicBackgroundTupleResult(parser,stream);
execute(tRes);
return tRes;
}
示例5: newSparqlTupleParser
import org.openrdf.query.resultio.QueryResultIO; //导入方法依赖的package包/类
public static TupleQueryResultParser newSparqlTupleParser(final TupleQueryResultFormat format) {
final TupleQueryResultParser parser = QueryResultIO.createParser(format);
parser.setValueFactory(CompactValueFactory.getInstance());
return parser;
}