Coverage Report - org.apache.any23.extractor.rdf.RDFHandlerAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
RDFHandlerAdapter
0%
0/14
0%
0/4
1.333
 
 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.extractor.rdf;
 19  
 
 20  
 import org.apache.any23.extractor.ExtractionResult;
 21  
 import org.openrdf.model.Resource;
 22  
 import org.openrdf.model.Statement;
 23  
 import org.openrdf.model.URI;
 24  
 import org.openrdf.rio.RDFHandler;
 25  
 import org.openrdf.rio.RDFHandlerException;
 26  
 
 27  
 /**
 28  
  * An RDFHandler that relays statements and prefix definitions to
 29  
  * an {@link ExtractionResult}. Used to feed output from Sesame's
 30  
  * RDF parsers into Any23.
 31  
  *
 32  
  * @author Richard Cyganiak (richard@cyganiak.de)
 33  
  */
 34  
 public class RDFHandlerAdapter implements RDFHandler {
 35  
 
 36  
     private ExtractionResult target;
 37  
 
 38  0
     public RDFHandlerAdapter(ExtractionResult target) {
 39  0
         this.target = target;
 40  0
     }
 41  
 
 42  
     public void startRDF() throws RDFHandlerException {
 43  0
     }
 44  
 
 45  
     public void handleNamespace(String prefix, String uri) {
 46  0
         target.writeNamespace(prefix, uri);
 47  0
     }
 48  
 
 49  
     public void handleStatement(Statement stmt) {
 50  0
         if(stmt != null) {
 51  0
             final Resource context = stmt.getContext();
 52  0
             if(context instanceof URI) {
 53  0
                 target.writeTriple(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), (URI) context);
 54  
             } else {
 55  0
                 target.writeTriple(stmt.getSubject(), stmt.getPredicate(), stmt.getObject());
 56  
             }
 57  
         }
 58  0
     }
 59  
 
 60  
     public void handleComment(String comment) {
 61  
         // Empty.
 62  0
     }
 63  
 
 64  
     public void endRDF() throws RDFHandlerException {
 65  
         // Empty.
 66  0
     }
 67  
 
 68  
 }