Coverage Report - org.apache.any23.writer.TripleHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
TripleHandler
N/A
N/A
1
 
 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  
 /**
 26  
  * Defines a document based triple handler.
 27  
  */
 28  
 public interface TripleHandler {
 29  
 
 30  
     void startDocument(URI documentURI) throws TripleHandlerException;
 31  
 
 32  
     /**
 33  
      * Informs the handler that a new context has been established.
 34  
      * Contexts are not guaranteed to receive any triples, so they
 35  
      * might be closed without any triple.
 36  
      */
 37  
     void openContext(ExtractionContext context) throws TripleHandlerException;
 38  
 
 39  
     /**
 40  
      * Invoked with a currently open context,
 41  
      * notifies the detection of a triple.
 42  
      *
 43  
      * @param s triple subject, cannot be <code>null</code>.
 44  
      * @param p triple predicate, cannot be <code>null</code>.
 45  
      * @param o triple object, cannot be <code>null</code>.
 46  
      * @param g triple graph, can be <code>null</code>.
 47  
      * @param context extraction context.
 48  
      * @throws TripleHandlerException
 49  
      */
 50  
     void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context) throws TripleHandlerException;
 51  
 
 52  
     /**
 53  
      * Invoked with a currently open context, notifies the detection of a
 54  
      * namespace.
 55  
      *
 56  
      * @param prefix namespace prefix.
 57  
      * @param uri namespace <i>URI</i>.
 58  
      * @param context namespace context.
 59  
      * @throws TripleHandlerException
 60  
      */
 61  
     void receiveNamespace(String prefix, String uri, ExtractionContext context) throws TripleHandlerException;
 62  
 
 63  
     /**
 64  
      * Informs the handler that no more triples will come from a
 65  
      * previously opened context. All contexts are guaranteed to
 66  
      * be closed before the final close(). The document context
 67  
      * for each document is guaranteed to be closed after all
 68  
      * local contexts of that document.
 69  
      *
 70  
      * @param context the context to be closed.
 71  
      * @throws TripleHandlerException
 72  
      */
 73  
     void closeContext(ExtractionContext context) throws TripleHandlerException;
 74  
 
 75  
     /**
 76  
      * Informs the handler that the end of the document
 77  
      * has been reached.
 78  
      *
 79  
      * @param documentURI document URI.
 80  
      * @throws TripleHandlerException
 81  
      */
 82  
     void endDocument(URI documentURI) throws TripleHandlerException;
 83  
 
 84  
     /**
 85  
      * Sets the length of the content to be processed.
 86  
      *
 87  
      * @param contentLength
 88  
      * @throws TripleHandlerException
 89  
      */
 90  
     void setContentLength(long contentLength);
 91  
 
 92  
     /**
 93  
      * Will be called last and exactly once.
 94  
      * @throws TripleHandlerException
 95  
      */
 96  
     void close() throws TripleHandlerException;
 97  
 
 98  
 }