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.extractor.ExtractionContext;
21 import org.eclipse.rdf4j.model.Resource;
22 import org.eclipse.rdf4j.model.IRI;
23 import org.eclipse.rdf4j.model.Value;
24
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.Collections;
28
29
30
31
32
33
34
35 public class CompositeTripleHandler implements TripleHandler {
36
37 private Collection<TripleHandler> children = new ArrayList<TripleHandler>();
38
39
40
41
42 public CompositeTripleHandler() {
43 this(Collections.<TripleHandler> emptyList());
44 }
45
46
47
48
49
50
51
52 public CompositeTripleHandler(Collection<TripleHandler> children) {
53 this.children.addAll(children);
54 }
55
56
57
58
59
60
61
62 public void addChild(TripleHandler child) {
63 children.add(child);
64 }
65
66 public Collection<TripleHandler> getChilds() {
67 return children;
68 }
69
70 public void startDocument(IRI documentIRI) throws TripleHandlerException {
71 for (TripleHandler handler : children) {
72 handler.startDocument(documentIRI);
73 }
74 }
75
76 public void openContext(ExtractionContext context) throws TripleHandlerException {
77 for (TripleHandler handler : children) {
78 handler.openContext(context);
79 }
80 }
81
82 public void closeContext(ExtractionContext context) throws TripleHandlerException {
83 for (TripleHandler handler : children) {
84 handler.closeContext(context);
85 }
86 }
87
88 public void receiveTriple(Resource s, IRI p, Value o, IRI g, ExtractionContext context)
89 throws TripleHandlerException {
90 for (TripleHandler handler : children) {
91 handler.receiveTriple(s, p, o, g, context);
92 }
93 }
94
95 public void receiveNamespace(String prefix, String uri, ExtractionContext context) throws TripleHandlerException {
96 for (TripleHandler handler : children) {
97 handler.receiveNamespace(prefix, uri, context);
98 }
99 }
100
101 public void close() throws TripleHandlerException {
102 for (TripleHandler handler : children) {
103 handler.close();
104 }
105 }
106
107 public void endDocument(IRI documentIRI) throws TripleHandlerException {
108 for (TripleHandler handler : children) {
109 handler.endDocument(documentIRI);
110 }
111 }
112
113 public void setContentLength(long contentLength) {
114 for (TripleHandler handler : children) {
115 handler.setContentLength(contentLength);
116 }
117 }
118
119 }