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.openrdf.model.Resource;
21 import org.openrdf.model.URI;
22 import org.openrdf.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, URI p, Value o, URI 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, URI p, Value o);
49
50 /**
51 * Write a namespace.
52 *
53 * @param prefix the prefix of the namespace
54 * @param uri the long URI identifying the namespace
55 */
56 void writeNamespace(String prefix, String uri);
57
58 /**
59 * Close the result.
60 * <p/>
61 * Extractors should close their results as soon as possible, but
62 * don't have to, the environment will close any remaining ones.
63 * Implementations should be robust against multiple close()
64 * invocations.
65 */
66 void close();
67
68 /**
69 * Open a result nested in the current one.
70 *
71 * @param extractionContext the context to be used to open the sub result.
72 * @return the instance of the nested extraction result.
73 */
74 ExtractionResult openSubResult(ExtractionContext extractionContext);
75
76 }