Class NQuadsParser

All Implemented Interfaces:
RdfMetaProvider, XmlMetaProvider

public class NQuadsParser extends RdfParser
Subclass of RdfParser for parsing N-Quads into POJOs.

Accepts RDF in N-Quads format (quads with optional graph component) and converts it to Java beans, maps, collections, and primitive types. Date/time literals are parsed via ISO 8601.

Examples:

// Parse N-Quads string into a bean. String nQuads = ...; // N-Quads content Person person = NQuadsParser.DEFAULT.read(nQuads, Person.class);

// Or use the NQuads marshaller for convenience. Person person = NQuads.to(nQuads, Person.class);

// Custom parser with swaps. NQuadsParser p = NQuadsParser.create().swaps(DateSwap.class).build(); MyBean bean = p.read(nQuads, 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" <graph> . <...> <.../address> <.../address> <graph> . <.../address> <.../street> "123 Main St" <graph> . <.../address> <.../city> "Boston" <graph> . <.../address> <.../state> "MA" <graph> .

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

    • DEFAULT

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

    • NQuadsParser

      public NQuadsParser(RdfParser.Builder<?> builder)
      Constructor.
      Parameters:
      builder - The builder for this object.
      Cannot be null.
  • Method Details

    • create

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