|
| 1 | +package com.apicatalog.jsonld.deseralization; |
| 2 | + |
| 3 | +import com.apicatalog.rdf.api.RdfConsumerException; |
| 4 | + |
| 5 | +/** |
| 6 | + * An RDF triple consumer interface designed for high-speed processing and |
| 7 | + * seamless integration with third-party libraries. |
| 8 | + * |
| 9 | + * Intended to be used in cases where triples are emitted in bulk as a set |
| 10 | + * belonging to the same graph, and where a producer keeps triple sets |
| 11 | + * associated with graphs. |
| 12 | + * |
| 13 | + * This interface minimizes unnecessary object instantiation, enhancing |
| 14 | + * efficiency in RDF data processing. |
| 15 | + */ |
| 16 | +interface RdfTripleConsumer { |
| 17 | + |
| 18 | + /** |
| 19 | + * Sets the default graph as the active scope. This method is invoked when |
| 20 | + * triples belong to the unnamed default graph. |
| 21 | + * |
| 22 | + * @return An instance enabling fluent programming; never {@code null}. |
| 23 | + * |
| 24 | + * @throws RdfConsumerException if an error occurs while processing the N-Quad |
| 25 | + * statement |
| 26 | + */ |
| 27 | + RdfTripleConsumer defaultGraph() throws RdfConsumerException; |
| 28 | + |
| 29 | + /** |
| 30 | + * Sets a named graph as the active scope. Ensures that subsequent triples are |
| 31 | + * associated with the specified graph. |
| 32 | + * |
| 33 | + * @param graph The name of the graph (IRI or blank node identifier prefixed |
| 34 | + * with "_:"); never {@code null}. |
| 35 | + * |
| 36 | + * @return An instance enabling fluent programming; never {@code null}. |
| 37 | + * |
| 38 | + * @throws RdfConsumerException if an error occurs while processing the N-Quad |
| 39 | + * statement |
| 40 | + */ |
| 41 | + RdfTripleConsumer namedGraph(String graph) throws RdfConsumerException; |
| 42 | + |
| 43 | + /** |
| 44 | + * Accepts an RDF triple where the object is an IRI or a blank node. The triple |
| 45 | + * is processed within the currently active graph scope. |
| 46 | + * |
| 47 | + * @param subject The subject of the triple (IRI or blank node identifier |
| 48 | + * prefixed with "_:"); never {@code null}. |
| 49 | + * @param predicate The predicate of the triple (IRI); never {@code null}. |
| 50 | + * @param object The object of the triple (IRI or blank node identifier |
| 51 | + * prefixed with "_:"); never {@code null}. |
| 52 | + * |
| 53 | + * @return An instance enabling fluent programming; never {@code null}. |
| 54 | + * |
| 55 | + * @throws RdfConsumerException if an error occurs while processing the N-Quad |
| 56 | + * statement |
| 57 | + */ |
| 58 | + RdfTripleConsumer triple( |
| 59 | + String subject, |
| 60 | + String predicate, |
| 61 | + String object) throws RdfConsumerException; |
| 62 | + |
| 63 | + /** |
| 64 | + * Accepts an RDF triple where the object is a literal with a datatype. |
| 65 | + * Optimized for efficient handling of typed literals. The triple is processed |
| 66 | + * within the currently active graph scope. |
| 67 | + * |
| 68 | + * @param subject The subject of the triple (IRI or blank node identifier |
| 69 | + * prefixed with "_:"); never {@code null}. |
| 70 | + * @param predicate The predicate of the triple (IRI); never {@code null}. |
| 71 | + * @param literal The literal value of the object; never {@code null}. |
| 72 | + * @param datatype The datatype IRI of the literal; never {@code null}. |
| 73 | + * |
| 74 | + * @return An instance enabling fluent programming; never {@code null}. |
| 75 | + * |
| 76 | + * @throws RdfConsumerException if an error occurs while processing the N-Quad |
| 77 | + * statement |
| 78 | + */ |
| 79 | + RdfTripleConsumer triple( |
| 80 | + String subject, |
| 81 | + String predicate, |
| 82 | + String literal, |
| 83 | + String datatype) throws RdfConsumerException; |
| 84 | + |
| 85 | + /** |
| 86 | + * Accepts an RDF triple where the object is a localized string value. Optimized |
| 87 | + * for efficient handling of language-tagged literals. The triple is processed |
| 88 | + * within the currently active graph scope. |
| 89 | + * |
| 90 | + * @param subject The subject of the triple (IRI or blank node identifier |
| 91 | + * prefixed with "_:"); never {@code null}. |
| 92 | + * @param predicate The predicate of the triple (IRI); never {@code null}. |
| 93 | + * @param literal The literal value of the object; never {@code null}. |
| 94 | + * @param language The language tag of the literal; never {@code null}. |
| 95 | + * @param direction The text direction of the literal (optional, may be |
| 96 | + * {@code null}). |
| 97 | + * |
| 98 | + * @return An instance enabling fluent programming; never {@code null}. |
| 99 | + * |
| 100 | + * @throws RdfConsumerException if an error occurs while processing the N-Quad |
| 101 | + * statement |
| 102 | + */ |
| 103 | + RdfTripleConsumer triple( |
| 104 | + String subject, |
| 105 | + String predicate, |
| 106 | + String literal, |
| 107 | + String language, |
| 108 | + String direction) throws RdfConsumerException; |
| 109 | +} |
0 commit comments