View Javadoc
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.
31       * Parameters can be null, then the triple will be silently ignored.
32       *
33       * @param s subject
34       * @param p predicate
35       * @param o object
36       * @param g graph
37       */
38      void writeTriple(Resource s, IRI p, Value o, IRI g);
39  
40      /**
41       * Write a triple.
42       * Parameters can be null, then the triple will be silently ignored.
43       *
44       * @param s subject
45       * @param p predicate
46       * @param o object
47       */
48      void writeTriple(Resource s, IRI p, Value o);
49  
50      /**
51       * Write a namespace.
52       *
53       * @param prefix the prefix of the namespace
54       * @param IRI    the long IRI identifying the namespace
55       */
56      void writeNamespace(String prefix, String IRI);
57  
58      /**
59       * <p>Close the result.</p>
60       * Extractors should close their results as soon as possible, but
61       * don't have to, the environment will close any remaining ones.
62       * Implementations should be robust against multiple close()
63       * invocations.
64       */
65      void close();
66  
67      /**
68       * Open a result nested in the current one.
69       *
70       * @param extractionContext the context to be used to open the sub result.
71       * @return the instance of the nested extraction result.
72       */
73      ExtractionResult openSubResult(ExtractionContext extractionContext);
74  
75  }