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


Java StreamRDF.start方法代码示例

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


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

示例1: writeTurtle

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
public void writeTurtle(String baseIRI, PrefixMapping prefixes, boolean writeBase) {
	// Auto-register RDF prefix so that rdf:type is displayed well
	// All other prefixes come from the query and should be as author intended
	prefixes = ensureRDFPrefix(prefixes);

	if (writeBase) {
		// Jena's streaming Turtle writers don't output base even if it is provided,
		// so we write it directly.
		IndentedWriter w = new IndentedWriter(out);
		RiotLib.writeBase(w, baseIRI);
		w.flush();
	}
	
	StreamRDF writer = new WriterStreamRDFBlocks(out);
	if (dedupWindowSize > 0) {
		writer = new StreamRDFDedup(writer, dedupWindowSize);
	}
	writer.start();
	writer.base(baseIRI);
	for (Entry<String, String> e : prefixes.getNsPrefixMap().entrySet()) {
		writer.prefix(e.getKey(), e.getValue());
	}
	StreamOps.sendTriplesToStream(triples, writer);
	writer.finish();
}
 
开发者ID:tarql,项目名称:tarql,代码行数:26,代码来源:StreamingRDFWriter.java

示例2: write

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
private static void write(final RdfStream rdfStream,
                   final OutputStream output,
                   final Lang dataFormat,
                   final MediaType dataMediaType) throws IOException {

    final RDFFormat format = defaultSerialization(dataFormat);

    // For formats that can be block-streamed (n-triples, turtle)
    if (format != null) {
        LOGGER.debug("Stream-based serialization of {}", dataFormat.toString());
        final StreamRDF stream = getWriterStream(output, format);
        stream.start();
        rdfStream.forEach(stream::triple);
        stream.finish();

    // For formats that require analysis of the entire model and cannot be streamed directly (rdfxml, n3)
    } else {
        LOGGER.debug("Non-stream serialization of {}", dataFormat.toString());
        final Model model = rdfStream.collect(toModel());
        // use block output streaming for RDFXML
        if (RDFXML.equals(dataFormat)) {
            RDFDataMgr.write(output, model.getGraph(), RDFXML_PLAIN);
        } else if (JSONLD.equals(dataFormat)) {
            final RDFFormat jsonldFormat = getFormatFromMediaType(dataMediaType);
            RDFDataMgr.write(output, model.getGraph(), jsonldFormat);
        } else {
            RDFDataMgr.write(output, model.getGraph(), dataFormat);
        }
    }
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:31,代码来源:RdfStreamStreamingOutput.java

示例3: write

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Override
public void write(final Stream<? extends Triple> triples, final OutputStream output, final RDFSyntax syntax,
        final IRI... profiles) {
    requireNonNull(triples, "The triples stream may not be null!");
    requireNonNull(output, "The output stream may not be null!");
    requireNonNull(syntax, "The RDF syntax value may not be null!");

    try {
        if (RDFA.equals(syntax)) {
            htmlSerializer.write(output, triples, profiles.length > 0 ? profiles[0] : null);
        } else {
            final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                    new RuntimeTrellisException("Invalid content type: " + syntax.mediaType()));

            final RDFFormat format = defaultSerialization(lang);

            if (nonNull(format)) {
                LOGGER.debug("Writing stream-based RDF: {}", format);
                final StreamRDF stream = getWriterStream(output, format);
                stream.start();
                ofNullable(nsService).ifPresent(svc -> svc.getNamespaces().forEach(stream::prefix));
                triples.map(rdf::asJenaTriple).forEachOrdered(stream::triple);
                stream.finish();
            } else {
                LOGGER.debug("Writing buffered RDF: {}", lang);
                final org.apache.jena.graph.Graph graph = createDefaultGraph();
                ofNullable(nsService).map(NamespaceService::getNamespaces)
                    .ifPresent(graph.getPrefixMapping()::setNsPrefixes);
                triples.map(rdf::asJenaTriple).forEachOrdered(graph::add);
                if (JSONLD.equals(lang)) {
                    writeJsonLd(output, DatasetGraphFactory.create(graph), profiles);
                } else {
                    RDFDataMgr.write(output, graph, lang);
                }
            }
        }
    } catch (final AtlasException ex) {
        throw new RuntimeTrellisException(ex);
    }
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:41,代码来源:JenaIOService.java

示例4: write

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Override
public void write(final Stream<? extends Triple> triples, final OutputStream output, final RDFSyntax syntax,
        final IRI... profiles) {
    requireNonNull(triples, "The triples stream may not be null!");
    requireNonNull(output, "The output stream may not be null!");
    requireNonNull(syntax, "The RDF syntax value may not be null!");

    try {
        if (RDFA_HTML.equals(syntax)) {
            htmlSerializer.write(output, triples, profiles.length > 0 ? profiles[0] : null);
        } else {
            final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                    new RuntimeRepositoryException("Invalid content type: " + syntax.mediaType));

            final RDFFormat format = defaultSerialization(lang);

            if (nonNull(format)) {
                LOGGER.debug("Writing stream-based RDF: {}", format);
                final StreamRDF stream = getWriterStream(output, format);
                stream.start();
                ofNullable(nsService).ifPresent(svc -> svc.getNamespaces().forEach(stream::prefix));
                triples.map(rdf::asJenaTriple).forEachOrdered(stream::triple);
                stream.finish();
            } else {
                LOGGER.debug("Writing buffered RDF: {}", lang);
                final org.apache.jena.graph.Graph graph = createDefaultGraph();
                ofNullable(nsService).map(NamespaceService::getNamespaces)
                    .ifPresent(graph.getPrefixMapping()::setNsPrefixes);
                triples.map(rdf::asJenaTriple).forEachOrdered(graph::add);
                if (JSONLD.equals(lang)) {
                    writeJsonLd(output, DatasetGraphFactory.create(graph), profiles);
                } else {
                    RDFDataMgr.write(output, graph, lang);
                }
            }
        }
    } catch (final AtlasException ex) {
        throw new RuntimeRepositoryException(ex);
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:41,代码来源:JenaIOService.java

示例5: exec

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Override
    protected void exec() {
        StreamRDF dest  = new StreamPatch(System.out);
        dest.start();
        
        if ( getPositional().isEmpty() )
            execOne(System.in);
        getPositional().forEach(fn->{
            RDFDataMgr.parse(dest, fn);
//            InputStream input = IO.openFile(fn);
//            execOne(input);
        });

        dest.finish();
    }
 
开发者ID:afs,项目名称:rdf-delta,代码行数:16,代码来源:rdf2patch.java

示例6: exportTree

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Override
public void exportTree(String uri, StreamRDF out) {
    RegisterItem item = asItem(uri);
    out.start();
    try {
        doExportTree(item, out);
    } finally {
        out.finish();
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:11,代码来源:StoreBaseImpl.java

示例7: write

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
private static void write(final RdfStream rdfStream,
                   final OutputStream output,
                   final Lang dataFormat,
                   final MediaType dataMediaType,
                   final Map<String, String> nsPrefixes) throws IOException {

    final RDFFormat format = defaultSerialization(dataFormat);

    // For formats that can be block-streamed (n-triples, turtle)
    if (format != null) {
        LOGGER.debug("Stream-based serialization of {}", dataFormat.toString());
        final StreamRDF stream = new SynchonizedStreamRDFWrapper(getWriterStream(output, format));
        stream.start();
        nsPrefixes.forEach(stream::prefix);
        rdfStream.forEach(stream::triple);
        stream.finish();

    // For formats that require analysis of the entire model and cannot be streamed directly (rdfxml, n3)
    } else {
        LOGGER.debug("Non-stream serialization of {}", dataFormat.toString());
        final Model model = rdfStream.collect(toModel());
        model.setNsPrefixes(nsPrefixes);
        // use block output streaming for RDFXML
        if (RDFXML.equals(dataFormat)) {
            RDFDataMgr.write(output, model.getGraph(), RDFXML_PLAIN);
        } else if (JSONLD.equals(dataFormat)) {
            final RDFFormat jsonldFormat = getFormatFromMediaType(dataMediaType);
            RDFDataMgr.write(output, model.getGraph(), jsonldFormat);
        } else {
            RDFDataMgr.write(output, model.getGraph(), dataFormat);
        }
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:34,代码来源:RdfStreamStreamingOutput.java

示例8: writeNTriples

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
public void writeNTriples() {
	StreamRDF writer = new WriterStreamRDFPlain(new IndentedWriter(out));
	if (dedupWindowSize > 0) {
		writer = new StreamRDFDedup(writer, dedupWindowSize);
	}
	writer.start();
	StreamOps.sendTriplesToStream(triples, writer);
	writer.finish();
}
 
开发者ID:tarql,项目名称:tarql,代码行数:10,代码来源:StreamingRDFWriter.java

示例9: shouldPassThroughTriples

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Test public void shouldPassThroughTriples() {
	StreamRDF dedup = new StreamRDFDedup(new MockStreamRDF());
	dedup.start();
	dedup.triple(triple("<a> <a> <a>"));
	dedup.triple(triple("<b> <b> <b>"));
	dedup.triple(triple("<c> <c> <c>"));
	dedup.finish();
	assertEquals(triples("<a> <a> <a>", "<b> <b> <b>", "<c> <c> <c>"), received);
}
 
开发者ID:tarql,项目名称:tarql,代码行数:10,代码来源:StreamRDFDedupTest.java

示例10: shouldRemoveDuplicateInWindow

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Test public void shouldRemoveDuplicateInWindow() {
	StreamRDF dedup = new StreamRDFDedup(new MockStreamRDF());
	dedup.start();
	dedup.triple(triple("<a> <a> <a>"));
	dedup.triple(triple("<a> <a> <a>"));
	dedup.finish();
	assertEquals(triples("<a> <a> <a>"), received);
}
 
开发者ID:tarql,项目名称:tarql,代码行数:9,代码来源:StreamRDFDedupTest.java

示例11: shouldNotRemoveDuplicateOutsideWindow

import org.apache.jena.riot.system.StreamRDF; //导入方法依赖的package包/类
@Test public void shouldNotRemoveDuplicateOutsideWindow() {
	StreamRDF dedup = new StreamRDFDedup(new MockStreamRDF(), 2);
	dedup.start();
	dedup.triple(triple("<a> <a> <a>"));
	dedup.triple(triple("<b> <b> <b>"));
	dedup.triple(triple("<a> <a> <a>"));
	dedup.triple(triple("<c> <c> <c>"));
	dedup.triple(triple("<a> <a> <a>"));
	dedup.finish();
	assertEquals(triples("<a> <a> <a>", "<b> <b> <b>", "<c> <c> <c>", "<a> <a> <a>"), received);
}
 
开发者ID:tarql,项目名称:tarql,代码行数:12,代码来源:StreamRDFDedupTest.java


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