Class RDFParsers

java.lang.Object
com.stardog.stark.io.RDFParsers

public final class RDFParsers extends Object

Utilities for working with RDFParser

Since:
1.0
Version:
1.0
Author:
Michael Grove
See Also:
  • Method Details

    • register

      public static void register(RDFParser theParser)
    • forFormat

      @Nonnull public static Optional<RDFParser> forFormat(@Nonnull RDFFormat theFormat)
      Return the parser associated with the given format
      Parameters:
      theFormat - the format you wish to parse
      Returns:
      the parser for the format
    • read

      @Nonnull public static Set<Statement> read(@Nonnull InputStream theStream, @Nonnull RDFFormat theFormat) throws IOException
      Parse the RDF from the input and return the resulting statements
      Parameters:
      theStream - the `InputStream` to read from
      theFormat - the format of the RDF
      Returns:
      the parsed RDF
      Throws:
      IOException - if there was an error while reading from the stream
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      @Nonnull public static Set<Statement> read(@Nonnull String theInput, @Nonnull RDFFormat theFormat) throws IOException
      Parse the RDF from the given `String` input and return the resulting statements using the default parsing options
      Parameters:
      theInput - the RDF input
      theFormat - the format for the RDF
      Returns:
      the parsed statements
      Throws:
      IOException - if there was an error while reading from the stream
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      @Nonnull public static Set<Statement> read(@Nonnull String theInput, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions) throws IOException
      Parser the RDF from the given `String` input and return the resulting statements.
      Parameters:
      theInput - the RDF input
      theFormat - the format for the RDF
      theOptions - the parser options
      Returns:
      the parsed statements
      Throws:
      IOException - if there was an error while reading from the stream
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      @Nonnull public static Set<Statement> read(@Nonnull InputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions) throws IOException
      Parse the RDF from the input and return the resulting statements
      Parameters:
      theStream - the `InputStream` to read from
      theFormat - the format of the RDF
      theOptions - the parser options
      Returns:
      the parsed RDF
      Throws:
      IOException - if there was an error while reading from the stream
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      @Nonnull public static Set<Statement> read(@Nonnull Path thePath) throws IOException
      Parse the RDF in the specified file and return the resulting statements.
      Parameters:
      thePath - the file to read from
      Returns:
      the parsed statements
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat` or the file uses an unknown RDF format
    • read

      @Nonnull public static Set<Statement> read(@Nonnull Path thePath, @Nonnull RDFFormat theFormat) throws IOException
      Parse the RDF in the specified file and return the resulting statements.
      Parameters:
      thePath - the file to read from
      theFormat - the RDF format
      Returns:
      the parsed statements
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat` or the file uses an unknown RDF format
    • read

      @Nonnull public static Set<Statement> read(@Nonnull Path thePath, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions) throws IOException
      Parse the RDF in the specified file and return the resulting statements
      Parameters:
      thePath - the file to read from
      theFormat - the RDF format
      theOptions - the parser options
      Returns:
      the parsed statements
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      public static <T> T read(@Nonnull Path thePath, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions, @Nonnull CollectingRDFHandler<T> theHandler) throws IOException
      Parse the RDF in the specified file
      Parameters:
      thePath - the file whose contents should be parse
      theFormat - the RDF format of the file
      theOptions - the parser options
      theHandler - the handler of the parsed results
      Returns:
      the result
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      public static <T> T read(@Nonnull InputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions, @Nonnull CollectingRDFHandler<T> theHandler) throws IOException
      Parse the RDF from the specified stream
      Parameters:
      theStream - the stream whose contents should be parsed
      theFormat - the RDF format of the file
      theOptions - the parser options
      theHandler - the handler of the parsed results
      Returns:
      the result
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`
    • read

      public static void read(@Nonnull InputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Options theOptions, @Nonnull RDFHandler theHandler) throws IOException
      Parse the RDF from the specified stream
      Parameters:
      theStream - the stream whose contents should be parsed
      theFormat - the RDF format of the file
      theOptions - the parser options
      theHandler - the handler of the parsed results
      Throws:
      IOException - if there is an error opening or reading from the file
      InvalidRDF - if the RDF syntax was invalid wrt to the format
      IllegalArgumentException - if there is no known parser for the `RDFFormat`