public class NQuadsWriter extends Object implements com.apicatalog.rdf.api.RdfQuadConsumer
This class implements the RdfQuadConsumer interface, allowing RDF
quads to be written to an output stream in the standard N-Quads
serialization. It supports writing IRIs, blank nodes, literals, and
language-tagged literals.
| Constructor and Description |
|---|
NQuadsWriter(Writer writer) |
| Modifier and Type | Method and Description |
|---|---|
static String |
literal(String literal,
String datatype,
String langTag,
String direction)
Formats an RDF literal with optional datatype, language tag, or direction.
|
protected static void |
literal(Writer writer,
String object,
String datatype,
String langTag,
String direction) |
static String |
nquad(String subject,
String predicate,
String object,
String graph)
Generates an N-Quad string representation for a quad with a resource subject,
predicate, and object.
|
static String |
nquad(String subject,
String predicate,
String literal,
String datatype,
String graph)
Generates an N-Quad string representation for a quad with a literal object
and a specified datatype.
|
static String |
nquad(String subject,
String predicate,
String literal,
String language,
String direction,
String graph)
Generates an N-Quad string representation for a quad with a lanauge-tagged
literal object and optionally direction.
|
static String |
nquad(String subject,
String predicate,
String object,
String datatype,
String language,
String direction,
String graph) |
protected static void |
nquad(Writer writer,
String subject,
String predicate,
String object,
String graph) |
protected static void |
nquad(Writer writer,
String subject,
String predicate,
String object,
String datatype,
String language,
String direction,
String graph) |
com.apicatalog.rdf.api.RdfQuadConsumer |
quad(String subject,
String predicate,
String object,
String datatype,
String language,
String direction,
String graph) |
static String |
resource(String iri)
Formats an IRI for use in N-Quads by enclosing it in angle brackets.
|
static String |
resourceOrBlank(String value)
Converts an IRI or a blank node identifier into an N-Quads compliant
representation.
|
protected final Writer writer
public NQuadsWriter(Writer writer)
public static final String resourceOrBlank(String value)
value - the IRI or blank node identifier to processIllegalArgumentException - if the input value is nullpublic static final String resource(String iri)
iri - the IRI to formatIllegalArgumentException - if the input IRI is nullpublic static final String literal(String literal, String datatype, String langTag, String direction)
literal - the literal valuedatatype - the optional datatype IRI (may be null)langTag - the optional language tag (may be null)direction - the optional text direction (may be null)IllegalArgumentException - if the literal value is nullpublic static final String nquad(String subject, String predicate, String object, String graph)
subject - The subject of the triple. This can be either an IRI or a
blank node.predicate - The predicate of the triple, which must be an IRI.object - The object of the triple, which can be either an IRI or a
blank node.graph - The named graph for the triple, or null if no graph is
specified.public static final String nquad(String subject, String predicate, String literal, String datatype, String graph)
subject - The subject of the triple. This can be either an IRI or a
blank node.predicate - The predicate of the triple, which must be an IRI.literal - The literal value for the object in the triple.datatype - The datatype IRI for the literal.graph - The named graph for the triple, or null if no graph
is specified.public static final String nquad(String subject, String predicate, String literal, String language, String direction, String graph)
subject - The subject of the triple. This can be either an IRI or a
blank node.predicate - The predicate of the triple, which must be an IRI.literal - The literal value for the object in the triple.language - The language tag for the literal.direction - The direction of the literal, or null if not applicable.graph - The named graph for the triple, or null if no graph is
specified.public static final String nquad(String subject, String predicate, String object, String datatype, String language, String direction, String graph)
public com.apicatalog.rdf.api.RdfQuadConsumer quad(String subject, String predicate, String object, String datatype, String language, String direction, String graph) throws com.apicatalog.rdf.api.RdfConsumerException
quad in interface com.apicatalog.rdf.api.RdfQuadConsumercom.apicatalog.rdf.api.RdfConsumerExceptionprotected static void nquad(Writer writer, String subject, String predicate, String object, String graph) throws IOException
IOExceptionprotected static void nquad(Writer writer, String subject, String predicate, String object, String datatype, String language, String direction, String graph) throws IOException
IOExceptionprotected static final void literal(Writer writer, String object, String datatype, String langTag, String direction) throws IOException
IOExceptionCopyright © 2020–2025. All rights reserved.