##### Coverage Report - org.apache.any23.writer.CompositeTripleHandler

Classes in this File | Line Coverage | Branch Coverage | Complexity
CompositeTripleHandler |
0% | 0/31
0% | 0/14
| 1.5833333333333333;1.583

1 |  |
     /*
2 |  |
      * Licensed to the Apache Software Foundation (ASF) under one or more
3 |  |
      * contributor license agreements.  See the NOTICE file distributed with
4 |  |
      * this work for additional information regarding copyright ownership.
5 |  |
      * The ASF licenses this file to You under the Apache License, Version 2.0
6 |  |
      * (the "License"); you may not use this file except in compliance with
7 |  |
      * the License.  You may obtain a copy of the License at
8 |  |
      *
9 |  |
      *  http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      * Unless required by applicable law or agreed to in writing, software
12 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      * See the License for the specific language governing permissions and
15 |  |
      * limitations under the License.
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 |  |
      * A {@link TripleHandler} multi decorator, that wraps zero or more
31 |  |
      * other triple handlers and dispatches all events to each of them.
32 |  |
      *
33 |  |
      * @author Richard Cyganiak (richard@cyganiak.de)
34 |  |
      */
35 |  |
     public class CompositeTripleHandler implements TripleHandler {
36 |  |
37 | 0 |
         private Collection<TripleHandler> children = new ArrayList<TripleHandler>();
38 |  |
39 |  |
         /**
40 |  |
          * Constructor with empty decorated list.
41 |  |
          */
42 |  |
         public CompositeTripleHandler() {
43 | 0 |
             this(Collections.<TripleHandler>emptyList());
44 | 0 |
         }
45 |  |
46 |  |
         /**
47 |  |
          * Constructor with initial list of decorated handlers.
48 |  |
          *
49 |  |
          * @param children list of decorated handlers.
50 |  |
          */
51 | 0 |
         public CompositeTripleHandler(Collection<TripleHandler> children) {
52 | 0 |
             this.children.addAll(children);
53 | 0 |
         }
54 |  |
55 |  |
         /**
56 |  |
          * Adds a decorated handler.
57 |  |
          *
58 |  |
          * @param child the decorated handler.
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 |  |
             // Empty.
114 | 0 |
         }
115 |  |
116 |  |
     }