Class RDFParsers


  • public final class RDFParsers
    extends java.lang.Object

    Utilities for working with RDFParser

    Since:
    1.0
    Version:
    1.0
    Author:
    Michael Grove
    See Also:
    RDFFormat
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<RDFParser> forFormat​(RDFFormat theFormat)
      Return the parser associated with the given format
      static java.util.Set<Statement> read​(java.io.InputStream theStream, RDFFormat theFormat)
      Parse the RDF from the input and return the resulting statements
      static java.util.Set<Statement> read​(java.io.InputStream theStream, RDFFormat theFormat, Options theOptions)
      Parse the RDF from the input and return the resulting statements
      static <T> T read​(java.io.InputStream theStream, RDFFormat theFormat, Options theOptions, CollectingRDFHandler<T> theHandler)
      Parse the RDF from the specified stream
      static void read​(java.io.InputStream theStream, RDFFormat theFormat, Options theOptions, RDFHandler theHandler)
      Parse the RDF from the specified stream
      static java.util.Set<Statement> read​(java.lang.String theInput, RDFFormat theFormat)
      Parse the RDF from the given `String` input and return the resulting statements using the default parsing options
      static java.util.Set<Statement> read​(java.lang.String theInput, RDFFormat theFormat, Options theOptions)
      Parser the RDF from the given `String` input and return the resulting statements.
      static java.util.Set<Statement> read​(java.nio.file.Path thePath)
      Parse the RDF in the specified file and return the resulting statements.
      static java.util.Set<Statement> read​(java.nio.file.Path thePath, RDFFormat theFormat)
      Parse the RDF in the specified file and return the resulting statements.
      static java.util.Set<Statement> read​(java.nio.file.Path thePath, RDFFormat theFormat, Options theOptions)
      Parse the RDF in the specified file and return the resulting statements
      static <T> T read​(java.nio.file.Path thePath, RDFFormat theFormat, Options theOptions, CollectingRDFHandler<T> theHandler)
      Parse the RDF in the specified file
      static void register​(RDFParser theParser)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • register

        public static void register​(RDFParser theParser)
      • forFormat

        @Nonnull
        public static java.util.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 java.util.Set<Statement> read​(@Nonnull
                                                    java.io.InputStream theStream,
                                                    @Nonnull
                                                    RDFFormat theFormat)
                                             throws java.io.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:
        java.io.IOException - if there was an error while reading from the stream
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.lang.String theInput,
                                                    @Nonnull
                                                    RDFFormat theFormat)
                                             throws java.io.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:
        java.io.IOException - if there was an error while reading from the stream
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.lang.String theInput,
                                                    @Nonnull
                                                    RDFFormat theFormat,
                                                    @Nonnull
                                                    Options theOptions)
                                             throws java.io.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:
        java.io.IOException - if there was an error while reading from the stream
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.io.InputStream theStream,
                                                    @Nonnull
                                                    RDFFormat theFormat,
                                                    @Nonnull
                                                    Options theOptions)
                                             throws java.io.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:
        java.io.IOException - if there was an error while reading from the stream
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.nio.file.Path thePath)
                                             throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat` or the file uses an unknown RDF format
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.nio.file.Path thePath,
                                                    @Nonnull
                                                    RDFFormat theFormat)
                                             throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat` or the file uses an unknown RDF format
      • read

        @Nonnull
        public static java.util.Set<Statement> read​(@Nonnull
                                                    java.nio.file.Path thePath,
                                                    @Nonnull
                                                    RDFFormat theFormat,
                                                    @Nonnull
                                                    Options theOptions)
                                             throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        public static <T> T read​(@Nonnull
                                 java.nio.file.Path thePath,
                                 @Nonnull
                                 RDFFormat theFormat,
                                 @Nonnull
                                 Options theOptions,
                                 @Nonnull
                                 CollectingRDFHandler<T> theHandler)
                          throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        public static <T> T read​(@Nonnull
                                 java.io.InputStream theStream,
                                 @Nonnull
                                 RDFFormat theFormat,
                                 @Nonnull
                                 Options theOptions,
                                 @Nonnull
                                 CollectingRDFHandler<T> theHandler)
                          throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`
      • read

        public static void read​(@Nonnull
                                java.io.InputStream theStream,
                                @Nonnull
                                RDFFormat theFormat,
                                @Nonnull
                                Options theOptions,
                                @Nonnull
                                RDFHandler theHandler)
                         throws java.io.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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidRDF - if the RDF syntax was invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `RDFFormat`