Class NTripleParser

All Implemented Interfaces:
RdfMetaProvider, XmlMetaProvider

public class NTripleParser extends RdfParser
Subclass of RdfParser for parsing N-Triples into POJOs.

Accepts RDF in W3C N-Triples format (one triple per line) and converts it to Java beans, maps, collections, and primitive types. Date/time literals are parsed via ISO 8601.

Examples:

// Parse N-Triples string into a bean. String nTriples = ...; // N-Triples content Person person = NTripleParser.DEFAULT.read(nTriples, Person.class);

// Or use the NTriple marshaller for convenience. Person person = NTriple.DEFAULT.read(nTriples, Person.class);

// Parse into a map. Map<String, String> map = NTripleParser.DEFAULT.read(nTriples, Map.class, String.class, String.class);

// Custom parser with swaps. NTripleParser p = NTripleParser.create().swaps(DateSwap.class).build(); MyBean bean = p.read(nTriples, MyBean.class);

Example input (bean with name/age):

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

Complex (nested address + array):

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

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

    • DEFAULT

      public static final NTripleParser DEFAULT
      Default N-Triple parser, all default settings.
  • Constructor Details

  • Method Details

    • create

      public static RdfParser.Builder<?> create()
      Creates a new builder for this object.
      Returns:
      A new builder.