• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RDFHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.rdf4j.rio.RDFHandler的典型用法代码示例。如果您正苦于以下问题:Java RDFHandler类的具体用法?Java RDFHandler怎么用?Java RDFHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RDFHandler类属于org.eclipse.rdf4j.rio包,在下文中一共展示了RDFHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addFile

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
private void addFile(final InputStream in,
                     final RDFFormat format) throws Exception {
    Preconditions.checkNotNull(in);

    try {
        try (SailConnection sc = getConnection()) {
            RDFHandler h = new SailAdder(sc);
            RDFParser p = Rio.createParser(format);
            p.setRDFHandler(h);
            p.parse(in, "http://example.org/bogusBaseIRI/");
            commit(sc);
        }
    } finally {
        in.close();
    }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:17,代码来源:SailTest.java


示例2: propagateToHandler

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
private static void propagateToHandler(List<Statement> statements,
        RDFHandler handler)
        throws RDFHandlerException, RepositoryException {
    handler.startRDF();
    handler.handleNamespace(RDF.PREFIX, RDF.NAMESPACE);
    handler.handleNamespace(RDFS.PREFIX, RDFS.NAMESPACE);
    handler.handleNamespace(DCAT.PREFIX, DCAT.NAMESPACE);
    handler.handleNamespace(XMLSchema.PREFIX, XMLSchema.NAMESPACE);
    handler.handleNamespace(OWL.PREFIX, OWL.NAMESPACE);
    handler.handleNamespace(DCTERMS.PREFIX, DCTERMS.NAMESPACE);
    handler.handleNamespace(FDP.PREFIX, FDP.NAMESPACE);
    handler.handleNamespace(R3D.PREFIX, R3D.NAMESPACE);
    handler.handleNamespace("lang",
            "http://id.loc.gov/vocabulary/iso639-1/");
    for (Statement st : statements) {
        handler.handleStatement(st);
    }
    handler.endRDF();
}
 
开发者ID:DTL-FAIRData,项目名称:fairmetadata4j,代码行数:20,代码来源:MetadataUtils.java


示例3: callsStartRDFAndEndRDFOnGivenHandler

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
@Test
public void callsStartRDFAndEndRDFOnGivenHandler() throws Exception {
    // Arrange
    RDFHandler rdfHandler = mock(RDFHandler.class);
    Collection<Statement> statements = ImmutableList.of(
            createHttpStatement("s1", "p", "o", "g1")
    );
    Repository repository = FTDPUTestUtils.createRepository(statements);

    // Act
    try (MockRDFDataUnit rdfDataUnit = getDataUnit(statements);
         AllTriplesDataUnitLoader loader = getLoader(rdfDataUnit, 2)
    ) {
        loader.loadAllTriples(rdfHandler);
    }

    // Assert
    Mockito.verify(rdfHandler).startRDF();
    Mockito.verify(rdfHandler).endRDF();
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:21,代码来源:AllTriplesDataUnitLoaderTest.java


示例4: evaluate

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * evaluate graph query with RDFHandler
 *
 * @param resultHandler
 * @throws QueryEvaluationException
 * @throws RDFHandlerException
 */
@Override
public void evaluate(RDFHandler resultHandler) throws QueryEvaluationException, RDFHandlerException {
    GraphQueryResult queryResult = evaluate();
    if(queryResult.hasNext())
    {
        QueryResults.report(queryResult, resultHandler);
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicGraphQuery.java


示例5: getRepositoryData

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * Exports repository data from the specified context and passes it to the handler.
 *
 * @param contextUri Context from which the data should be exported. Optional
 * @param handler    Handler for the exported data
 */
public void getRepositoryData(URI contextUri, RDFHandler handler) {
    try {
        try (final RepositoryConnection connection = sesameRepository.getRepository().getConnection()) {
            final ValueFactory valueFactory = connection.getValueFactory();
            if (contextUri != null) {
                connection.export(handler, valueFactory.createIRI(contextUri.toString()));
            } else {
                connection.export(handler);
            }
        }
    } catch (RepositoryException | RDFHandlerException e) {
        LOG.error("Unable to read data from repository.", e);
    }
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:21,代码来源:DataDao.java


示例6: RDF4JJSONLDTripleCallback

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
public RDF4JJSONLDTripleCallback(RDFHandler nextHandler, ValueFactory vf,
        ParserConfig parserConfig, ParseErrorListener parseErrorListener) {
    this.handler = nextHandler;
    this.vf = vf;
    this.parserConfig = parserConfig;
    this.parseErrorListener = parseErrorListener;
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-tools,代码行数:8,代码来源:RDF4JJSONLDTripleCallback.java


示例7: loadAllTriplesForGraph

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
private int loadAllTriplesForGraph(IRI dataGraphURI, RDFHandler rdfHandler) throws OpenRDFException, DataUnitException {
    LOG.debug("Loading input quads from data unit for graph {}", dataGraphURI);
    int totalLoadedQuads = 0;
    int lastLoadedQuads = Integer.MAX_VALUE;
    for (int offset = 0; lastLoadedQuads >= maxSparqlResultsSize; offset += lastLoadedQuads) {
        String query = formatQuery(dataGraphURI, maxSparqlResultsSize, offset);
        lastLoadedQuads = addQuadsFromQuery(dataGraphURI, query, rdfHandler);
        totalLoadedQuads += lastLoadedQuads;

        if ((totalLoadedQuads - lastLoadedQuads) / LOG_LOOP_SIZE != totalLoadedQuads / LOG_LOOP_SIZE) {
            LOG.info("ODCS-FusionTool: Loaded {} quads from graph {} so far", totalLoadedQuads, dataGraphURI);
        }
    }
    return totalLoadedQuads;
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:16,代码来源:AllTriplesDataUnitLoader.java


示例8: addQuadsFromQuery

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
private int addQuadsFromQuery(IRI dataGraphURI, String sparqlQuery, RDFHandler rdfHandler) throws OpenRDFException, DataUnitException {
    int quadCount = 0;
    RepositoryConnection connection = getConnection();
    TupleQueryResult resultSet = connection.prepareTupleQuery(QueryLanguage.SPARQL, sparqlQuery).evaluate();
    try {
        ValueFactory valueFactory = connection.getRepository().getValueFactory();
        while (resultSet.hasNext()) {
            BindingSet bindings = resultSet.next();
            Statement quad = valueFactory.createStatement(
                    (Resource) bindings.getValue("s"),
                    (IRI) bindings.getValue("p"),
                    bindings.getValue("o"),
                    dataGraphURI);
            rdfHandler.handleStatement(quad);
            quadCount++;
        }
    } finally {
        resultSet.close();
        //if (connection instanceof VirtuosoRepositoryConnection)
        //    // fix potential error "Too many open statements" - Virtuoso doesn't release resources properly
        //    try {
        //        closeConnection();
        //    } catch (RepositoryException e) {
        //        // ignore
        //    }
        //}
    }
    return quadCount;
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:30,代码来源:AllTriplesDataUnitLoader.java


示例9: setRDFHandler

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
@Override
public RDFParser setRDFHandler(RDFHandler handler) {
  if (handler instanceof TimRdfHandler) {
    // It might be nicer to override statement, to make it contain the action, but it takes to much effort for now.
    ((TimRdfHandler) handler).registerActionSupplier(() -> actions.pop());
  }
  return super.setRDFHandler(handler);
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:9,代码来源:NquadsUdParser.java


示例10: emit

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
private static void emit(final RDFHandler out, final Resource s, final IRI p, final Value o)
        throws RDFHandlerException {
    final ValueFactory vf = SimpleValueFactory.getInstance();
    out.handleStatement(vf.createStatement(s, p, o));
}
 
开发者ID:Remper,项目名称:sociallink,代码行数:6,代码来源:RDFExporter.java


示例11: getHandler

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * @return the handler
 */
public RDFHandler getHandler() {
    return handler;
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-tools,代码行数:7,代码来源:RDF4JJSONLDTripleCallback.java


示例12: parseSynchronusly

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
@Override
protected void parseSynchronusly() throws IOException {
    final Optional<RDFFormat> formatByMimeType = getContentType().flatMap(Rio::getParserFormatForMIMEType);
    final String base = getBase().map(IRI::getIRIString).orElse(null);

    final ParserConfig parserConfig = getParserConfig();
    // TODO: Should we need to set anything?
    final RDFLoader loader = new RDFLoader(parserConfig, rdf4jTermFactory.getValueFactory());
    final RDFHandler rdfHandler = makeRDFHandler();
    if (getSourceFile().isPresent()) {
        // NOTE: While we could have used
        // loader.load(sourcePath.toFile()
        // if the path fs provider == FileSystems.getDefault(),
        // that RDFLoader method does not use absolute path
        // as the base URI, so to be consistent
        // we'll always do it with our own input stream
        //
        // That means we may have to guess format by extensions:
        final Optional<RDFFormat> formatByFilename = getSourceFile().map(Path::getFileName).map(Path::toString)
                .flatMap(Rio::getParserFormatForFileName);
        // TODO: for the excited.. what about the extension after following
        // symlinks?

        final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null));
        try (InputStream in = Files.newInputStream(getSourceFile().get())) {
            loader.load(in, base, format, rdfHandler);
        }
    } else if (getSourceIri().isPresent()) {
        try {
            // TODO: Handle international IRIs properly
            // (Unicode support for for hostname, path and query)
            final URL url = new URL(getSourceIri().get().getIRIString());
            // TODO: This probably does not support https:// -> http://
            // redirections
            loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler());
        } catch (final MalformedURLException ex) {
            throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex);
        }
    }
    // must be getSourceInputStream then, this is guaranteed by
    // super.checkSource();
    loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler);
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:44,代码来源:RDF4JParser.java


示例13: exportStatements

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * Exports statements via RDFHandler.
 *
 *
 *
 * @param subject Subject of the statement.
 * @param predicate Predicate of the statement.
 * @param object Object of the statement.
 * @param includeInferred if false returns only explicit statements. If true returns both explicit and implicit statements.
 * @param handler RDFHandler
 * @param contexts Var-arg for specified contexts.
 * @throws RepositoryException
 * @throws RDFHandlerException
 */
// TBD- should refactor
@Override
public void exportStatements(Resource subject, IRI predicate, Value object, boolean includeInferred, RDFHandler handler, Resource... contexts) throws RepositoryException, RDFHandlerException {
    try {
        RepositoryResult<Statement> st = this.getStatements(subject, predicate, object, includeInferred, contexts);
        handler.startRDF();
        QueryResults.stream(st).forEach(handler::handleStatement);
        handler.endRDF();
    }
    catch (MalformedQueryException | QueryEvaluationException e) {
        throw new RepositoryException(e);
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:28,代码来源:MarkLogicRepositoryConnection.java


示例14: export

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * Exports statements via RDFHandler.
 *
 *
 *
 * @param handler RDFHandler
 * @param contexts Var-arg for specified contexts.
 * @throws RepositoryException
 * @throws RDFHandlerException
 */
// TBD- should refactor
@Override
public void export(RDFHandler handler, Resource... contexts) throws RepositoryException, RDFHandlerException {
    exportStatements(null, null, null, false, handler, contexts);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicRepositoryConnection.java


示例15: setHandler

import org.eclipse.rdf4j.rio.RDFHandler; //导入依赖的package包/类
/**
 * @param handler
 *            the handler to set
 */
public void setHandler(RDFHandler handler) {
    this.handler = handler;
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-tools,代码行数:8,代码来源:RDF4JJSONLDTripleCallback.java



注:本文中的org.eclipse.rdf4j.rio.RDFHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TargetType类代码示例发布时间:2022-05-22
下一篇:
Java XMLGregorianCalendarImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap