Package com.apicatalog.rdf.nquads
Class NQuadsWriter
- java.lang.Object
-
- com.apicatalog.rdf.nquads.NQuadsWriter
-
- All Implemented Interfaces:
com.apicatalog.rdf.api.RdfQuadConsumer
public class NQuadsWriter extends java.lang.Object implements com.apicatalog.rdf.api.RdfQuadConsumerA writer for serializing RDF data in the N-Quads format.This class implements the
RdfQuadConsumerinterface, 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.- See Also:
- RDF 1.1 N-Quads Specification
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.Writerwriter
-
Constructor Summary
Constructors Constructor Description NQuadsWriter(java.io.Writer writer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidliteral(java.io.Writer writer, java.lang.String object, java.lang.String datatype, java.lang.String langTag, java.lang.String direction)static java.lang.Stringliteral(java.lang.String literal, java.lang.String datatype, java.lang.String langTag, java.lang.String direction)Formats an RDF literal with optional datatype, language tag, or direction.protected static voidnquad(java.io.Writer writer, java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph)protected static voidnquad(java.io.Writer writer, java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph)static java.lang.Stringnquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph)Generates an N-Quad string representation for a quad with a resource subject, predicate, and object.static java.lang.Stringnquad(java.lang.String subject, java.lang.String predicate, java.lang.String literal, java.lang.String datatype, java.lang.String graph)Generates an N-Quad string representation for a quad with a literal object and a specified datatype.static java.lang.Stringnquad(java.lang.String subject, java.lang.String predicate, java.lang.String literal, java.lang.String language, java.lang.String direction, java.lang.String graph)Generates an N-Quad string representation for a quad with a lanauge-tagged literal object and optionally direction.static java.lang.Stringnquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph)com.apicatalog.rdf.api.RdfQuadConsumerquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph)static java.lang.Stringresource(java.lang.String iri)Formats an IRI for use in N-Quads by enclosing it in angle brackets.static java.lang.StringresourceOrBlank(java.lang.String value)Converts an IRI or a blank node identifier into an N-Quads compliant representation.
-
-
-
Method Detail
-
resourceOrBlank
public static final java.lang.String resourceOrBlank(java.lang.String value)
Converts an IRI or a blank node identifier into an N-Quads compliant representation.- Parameters:
value- the IRI or blank node identifier to process- Returns:
- the formatted IRI in angle brackets or the blank node identifier
- Throws:
java.lang.IllegalArgumentException- if the input value isnull
-
resource
public static final java.lang.String resource(java.lang.String iri)
Formats an IRI for use in N-Quads by enclosing it in angle brackets.- Parameters:
iri- the IRI to format- Returns:
- the IRI wrapped in angle brackets
- Throws:
java.lang.IllegalArgumentException- if the input IRI isnull
-
literal
public static final java.lang.String literal(java.lang.String literal, java.lang.String datatype, java.lang.String langTag, java.lang.String direction)Formats an RDF literal with optional datatype, language tag, or direction.- Parameters:
literal- the literal valuedatatype- the optional datatype IRI (may benull)langTag- the optional language tag (may benull)direction- the optional text direction (may benull)- Returns:
- the formatted N-Quads literal representation
- Throws:
java.lang.IllegalArgumentException- if the literal value isnull
-
nquad
public static final java.lang.String nquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph)Generates an N-Quad string representation for a quad with a resource subject, predicate, and object.- Parameters:
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.- Returns:
- The N-Quad representation of the triple as a string.
-
nquad
public static final java.lang.String nquad(java.lang.String subject, java.lang.String predicate, java.lang.String literal, java.lang.String datatype, java.lang.String graph)Generates an N-Quad string representation for a quad with a literal object and a specified datatype.- Parameters:
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, ornullif no graph is specified.- Returns:
- The N-Quad representation of the triple as a string.
-
nquad
public static final java.lang.String nquad(java.lang.String subject, java.lang.String predicate, java.lang.String literal, java.lang.String language, java.lang.String direction, java.lang.String graph)Generates an N-Quad string representation for a quad with a lanauge-tagged literal object and optionally direction.- Parameters:
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.- Returns:
- The N-Quad representation of the triple as a string.
-
nquad
public static final java.lang.String nquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph)
-
quad
public com.apicatalog.rdf.api.RdfQuadConsumer quad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph) throws com.apicatalog.rdf.api.RdfConsumerException- Specified by:
quadin interfacecom.apicatalog.rdf.api.RdfQuadConsumer- Throws:
com.apicatalog.rdf.api.RdfConsumerException
-
nquad
protected static void nquad(java.io.Writer writer, java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph) throws java.io.IOException- Throws:
java.io.IOException
-
nquad
protected static void nquad(java.io.Writer writer, java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph) throws java.io.IOException- Throws:
java.io.IOException
-
literal
protected static final void literal(java.io.Writer writer, java.lang.String object, java.lang.String datatype, java.lang.String langTag, java.lang.String direction) throws java.io.IOException- Throws:
java.io.IOException
-
-