Search in sources :

Example 1 with SerializationFactory

use of org.apache.jena.atlas.data.SerializationFactory in project jena by apache.

the class SerializationFactoryFinder method quadSerializationFactory.

public static SerializationFactory<Quad> quadSerializationFactory() {
    return new SerializationFactory<Quad>() {

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

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

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

Example 2 with SerializationFactory

use of org.apache.jena.atlas.data.SerializationFactory 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

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