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