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; 19 20 import org.eclipse.rdf4j.model.Resource; 21 import org.eclipse.rdf4j.model.IRI; 22 import org.eclipse.rdf4j.model.Value; 23 24 /** 25 * Interface defining the methods that a representation of an extraction result must have. 26 */ 27 public interface ExtractionResult extends IssueReport { 28 29 /** 30 * Writes a triple. Parameters can be null, then the triple will be silently ignored. 31 * 32 * @param s 33 * subject 34 * @param p 35 * predicate 36 * @param o 37 * object 38 * @param g 39 * graph 40 */ 41 void writeTriple(Resource s, IRI p, Value o, IRI g); 42 43 /** 44 * Write a triple. Parameters can be null, then the triple will be silently ignored. 45 * 46 * @param s 47 * subject 48 * @param p 49 * predicate 50 * @param o 51 * object 52 */ 53 void writeTriple(Resource s, IRI p, Value o); 54 55 /** 56 * Write a namespace. 57 * 58 * @param prefix 59 * the prefix of the namespace 60 * @param IRI 61 * the long IRI identifying the namespace 62 */ 63 void writeNamespace(String prefix, String IRI); 64 65 /** 66 * <p> 67 * Close the result. 68 * </p> 69 * Extractors should close their results as soon as possible, but don't have to, the environment will close any 70 * remaining ones. Implementations should be robust against multiple close() invocations. 71 */ 72 void close(); 73 74 /** 75 * Open a result nested in the current one. 76 * 77 * @param extractionContext 78 * the context to be used to open the sub result. 79 * 80 * @return the instance of the nested extraction result. 81 */ 82 ExtractionResult openSubResult(ExtractionContext extractionContext); 83 84 }