Search in sources :

Example 1 with SinkTripleOutput

use of org.apache.jena.riot.out.SinkTripleOutput in project jena by apache.

the class ExRIOT_4 method main.

public static void main(String... argv) {
    String filename = "data.ttl";
    // This is the heart of N-triples printing ... outoput is heavily buffered
    // so the FilterSinkRDF called flush at the end of parsing.
    Sink<Triple> output = new SinkTripleOutput(System.out, null, SyntaxLabels.createNodeToLabel());
    StreamRDF filtered = new FilterSinkRDF(output, FOAF.name, FOAF.knows);
    // Call the parsing process.
    RDFParser.source(filename).parse(filtered);
}
Also used : Triple(org.apache.jena.graph.Triple) SinkTripleOutput(org.apache.jena.riot.out.SinkTripleOutput) StreamRDF(org.apache.jena.riot.system.StreamRDF)

Example 2 with SinkTripleOutput

use of org.apache.jena.riot.out.SinkTripleOutput in project jena by apache.

the class SerializationFactoryFinder method tripleSerializationFactory.

public static SerializationFactory<Triple> tripleSerializationFactory() {
    return new SerializationFactory<Triple>() {

        @Override
        public Sink<Triple> createSerializer(OutputStream out) {
            return new SinkTripleOutput(out, null, NodeToLabel.createBNodeByLabelEncoded());
        }

        @Override
        public Iterator<Triple> createDeserializer(InputStream in) {
            Tokenizer tokenizer = TokenizerFactory.makeTokenizerASCII(in);
            ParserProfile profile = RiotLib.createParserProfile(RiotLib.factoryRDF(LabelToNode.createUseLabelEncoded()), ErrorHandlerFactory.errorHandlerNoWarnings, IRIResolver.createNoResolve(), false);
            LangNTriples parser = new LangNTriples(tokenizer, profile, null);
            return parser;
        }

        @Override
        public long getEstimatedMemorySize(Triple item) {
            // TODO
            return 0;
        }
    };
}
Also used : Triple(org.apache.jena.graph.Triple) LangNTriples(org.apache.jena.riot.lang.LangNTriples) SinkTripleOutput(org.apache.jena.riot.out.SinkTripleOutput) BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) BindingOutputStream(org.apache.jena.sparql.engine.binding.BindingOutputStream) SerializationFactory(org.apache.jena.atlas.data.SerializationFactory) Tokenizer(org.apache.jena.riot.tokens.Tokenizer)

Aggregations

Triple (org.apache.jena.graph.Triple)2 SinkTripleOutput (org.apache.jena.riot.out.SinkTripleOutput)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 SerializationFactory (org.apache.jena.atlas.data.SerializationFactory)1 LangNTriples (org.apache.jena.riot.lang.LangNTriples)1 StreamRDF (org.apache.jena.riot.system.StreamRDF)1 Tokenizer (org.apache.jena.riot.tokens.Tokenizer)1 BindingInputStream (org.apache.jena.sparql.engine.binding.BindingInputStream)1 BindingOutputStream (org.apache.jena.sparql.engine.binding.BindingOutputStream)1