Class NTripleSerializer

All Implemented Interfaces:
Function<Object,String>, ThrowingFunction<Object,String>, RdfMetaProvider, XmlMetaProvider

public class NTripleSerializer extends RdfSerializer
Subclass of RdfSerializer for serializing POJOs to N-Triples notation.

Produces one RDF triple per line in W3C N-Triples format. Simple, line-oriented, and easy to parse.

Examples:

// Serialize a bean to N-Triples string. Person person = new Person("Alice", 30); String nTriples = NTripleSerializer.DEFAULT.write(person);

// Or use the NTriple marshaller for convenience. String nTriples = NTriple.DEFAULT.write(person);

// Custom serializer with swaps. NTripleSerializer s = NTripleSerializer.create().swaps(DateSwap.class).build(); String nTriples = s.write(person);

Example output (bean with name/age):

<...> <.../name> "Alice" . <...> <.../age> "30"^^<http://www.w3.org/2001/XMLSchema#int> .

Complex (nested address + array):

<...> <.../name> "Alice" . <...> <.../age> "30"^^... . <...> <.../address> <.../address> . <.../address> <.../street> "123 Main St" . <.../address> <.../city> "Boston" . <.../address> <.../state> "MA" .

Notes:
  • This class is thread safe and reusable.
See Also: