1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.any23.writer;
19
20 import org.apache.any23.configuration.Settings;
21 import org.apache.any23.extractor.ExtractionContext;
22 import org.eclipse.rdf4j.common.lang.FileFormat;
23 import org.eclipse.rdf4j.model.IRI;
24 import org.eclipse.rdf4j.model.Resource;
25 import org.eclipse.rdf4j.model.Value;
26 import org.eclipse.rdf4j.rio.RDFFormat;
27
28 import java.io.OutputStream;
29
30
31
32
33
34
35
36 public interface TripleWriterFactory extends BaseWriterFactory<OutputStream> {
37
38
39
40
41 @Override
42 @Deprecated
43 default RDFFormat getRdfFormat() {
44 return getTripleFormat().toRDFFormat();
45 }
46
47
48
49
50 TripleFormat getTripleFormat();
51
52
53
54
55 @Override
56 @Deprecated
57 default String getMimeType() {
58 return getTripleFormat().getMimeType();
59 }
60
61
62
63
64 @Override
65 @Deprecated
66 default FormatWriter getRdfWriter(OutputStream os) {
67 TripleHandler th = getTripleWriter(os, Settings.of());
68 return th instanceof FormatWriter ? (FormatWriter) th : new FormatWriter() {
69 @Override
70 public boolean isAnnotated() {
71 return false;
72 }
73
74 @Override
75 public void setAnnotated(boolean f) {
76 }
77
78 @Override
79 public void startDocument(IRI documentIRI) throws TripleHandlerException {
80 th.startDocument(documentIRI);
81 }
82
83 @Override
84 public void openContext(ExtractionContext context) throws TripleHandlerException {
85 th.openContext(context);
86 }
87
88 @Override
89 public void receiveTriple(Resource s, IRI p, Value o, IRI g, ExtractionContext context)
90 throws TripleHandlerException {
91 th.receiveTriple(s, p, o, g, context);
92 }
93
94 @Override
95 public void receiveNamespace(String prefix, String uri, ExtractionContext context)
96 throws TripleHandlerException {
97 th.receiveNamespace(prefix, uri, context);
98 }
99
100 @Override
101 public void closeContext(ExtractionContext context) throws TripleHandlerException {
102 th.closeContext(context);
103 }
104
105 @Override
106 public void endDocument(IRI documentIRI) throws TripleHandlerException {
107 th.endDocument(documentIRI);
108 }
109
110 @Override
111 public void setContentLength(long contentLength) {
112 th.setContentLength(contentLength);
113 }
114
115 @Override
116 public void close() throws TripleHandlerException {
117 th.close();
118 }
119 };
120 }
121
122
123
124
125
126 @Override
127 Settings getSupportedSettings();
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 @Override
143 TripleHandler getTripleWriter(OutputStream out, Settings settings);
144
145 }