Coverage Report - org.apache.any23.writer.CountingTripleHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
CountingTripleHandler
0%
0/20
0%
0/2
1.083
 
 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  
 import org.slf4j.Logger;
 25  
 import org.slf4j.LoggerFactory;
 26  
 
 27  
 /**
 28  
  * A simple {@link TripleHandler} that merely counts the number
 29  
  * of triples it has received.
 30  
  *
 31  
  * @author Richard Cyganiak (richard@cyganiak.de)
 32  
  * @author Michele Mostarda (mostarda@fbk.eu)
 33  
  */
 34  
 public class CountingTripleHandler implements TripleHandler {
 35  
 
 36  0
     private static final Logger logger = LoggerFactory.getLogger(CountingTripleHandler.class);
 37  
 
 38  
     private final boolean logTriples;
 39  
 
 40  0
     private int count = 0;
 41  
 
 42  0
     public CountingTripleHandler(boolean logTriples) {
 43  0
         this.logTriples = logTriples;
 44  0
     }
 45  
 
 46  
     public CountingTripleHandler() {
 47  0
         this(false);
 48  0
     }
 49  
 
 50  
     public int getCount() {
 51  0
         return count;
 52  
     }
 53  
 
 54  
     public void reset() {
 55  0
         count = 0;
 56  0
     }
 57  
 
 58  
     public void startDocument(URI documentURI) throws TripleHandlerException {
 59  
         // ignore
 60  0
     }
 61  
 
 62  
     public void openContext(ExtractionContext context) throws TripleHandlerException {
 63  
         // ignore
 64  0
     }
 65  
 
 66  
     public void closeContext(ExtractionContext context) throws TripleHandlerException {
 67  
         // ignore
 68  0
     }
 69  
 
 70  
     public void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context)
 71  
     throws TripleHandlerException {
 72  0
         count++;
 73  0
         if(logTriples) logger.debug( String.format("%s %s %s %s %s\n", s, p, o, g, context) );
 74  0
     }
 75  
 
 76  
     public void receiveNamespace(String prefix, String uri, ExtractionContext context)
 77  
     throws TripleHandlerException {
 78  
         // ignore
 79  0
     }
 80  
 
 81  
     public void close() throws TripleHandlerException {
 82  
         // ignore
 83  0
     }
 84  
 
 85  
     public void endDocument(URI documentURI) throws TripleHandlerException {
 86  
         //ignore
 87  0
     }
 88  
 
 89  
     public void setContentLength(long contentLength) {
 90  
         //ignore
 91  0
     }
 92  
 }