Class TurtleParser

All Implemented Interfaces:
RdfMetaProvider, XmlMetaProvider

public class TurtleParser extends RdfParser
Subclass of RdfParser for parsing Turtle into POJOs.

Accepts RDF in W3C Turtle format and converts it to Java beans, maps, collections, and primitive types. Date/time literals are parsed via ISO 8601.

Examples:

// Parse Turtle string into a bean. String turtle = ...; // Turtle content Person person = TurtleParser.DEFAULT.read(turtle, Person.class);

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

// Parse into a list of beans. List<Person> people = TurtleParser.DEFAULT.read(turtle, List.class, Person.class);

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

Example input (bean with name/age):

  • Field Details

    • DEFAULT

      public static final TurtleParser DEFAULT
      Default Turtle parser, all default settings.
  • Constructor Details

    • TurtleParser

      public TurtleParser(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.