1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.rdf.simple;
19
20 import java.io.IOException;
21 import java.util.UUID;
22 import java.util.function.Consumer;
23
24 import org.apache.commons.rdf.api.IRI;
25 import org.apache.commons.rdf.api.Quad;
26 import org.apache.commons.rdf.api.RDF;
27 import org.apache.commons.rdf.experimental.RDFParser;
28 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser;
29 import org.apache.commons.rdf.simple.experimental.RDFParseException;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public class DummyRDFParserBuilder extends AbstractRDFParser<DummyRDFParserBuilder> {
51
52 @Override
53 protected void parseSynchronusly() throws IOException, IllegalStateException, RDFParseException {
54
55 final RDF factory = getRdfTermFactory().get();
56 final Consumer<Quad> t = getTarget();
57
58
59
60 final IRI parsing = factory.createIRI("urn:uuid:" + UUID.randomUUID());
61 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/greeting"),
62 factory.createLiteral("Hello world")));
63
64
65
66
67 if (getSourceIri().isPresent()) {
68 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
69 getSourceIri().get()));
70 }
71 if (getSourceFile().isPresent()) {
72 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
73 factory.createIRI(getSourceFile().get().toUri().toString())));
74 }
75 if (getSourceInputStream().isPresent()) {
76 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
77 factory.createBlankNode()));
78 }
79
80 if (getBase().isPresent()) {
81 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/base"), getBase().get()));
82 }
83 if (getContentType().isPresent()) {
84 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentType"),
85 factory.createLiteral(getContentType().get())));
86 }
87 if (getContentTypeSyntax().isPresent()) {
88 t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentTypeSyntax"),
89 factory.createLiteral(getContentTypeSyntax().get().name())));
90 }
91 }
92
93 }