Package com.complexible.common.rdf.rio

# Class RDFStreams

java.lang.Object
com.complexible.common.rdf.rio.RDFStreams

public final class RDFStreams extends Object
A simple interface for parsers. A parser represents an atomic unit of input that will generate triples.

Since:
  2.0
Version:
  6.0
Author:
  Evren Sirin

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static long`
  `BYTE_PER_STATEMENT`
  `static final RDFStream`
  `EMPTY`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static long`
  `estimatedCount(long theBytes, RDFFormat theFormat)`
  `static long`
  `estimatedCount(Iterable<RDFStream> theStreams)`
  `static RDFStreamBuilder`
  `forFile(Path theFile)`
  `static RDFStreamBuilder`
  `forFiles(Path... theFiles)`
  `static RDFStreamBuilder`
  `forFiles(Collection<Path> theFiles)`
  `static String`
  `formatParseException(RDFStream theStream, Exception theError)`
  `static RDFStream`
  `forStatements(Iterable<Statement> theStatements, Resource theContext)`
  `static RDFStream`
  `forStatements(Iterator<Statement> theStatements, Resource theContext)`
  `static RDFStream`
  `forStatements(Iterator<Statement> theStatements, Resource theContext, long estimatedSize)`
  `static RDFStreamBuilder`
  `forStream(InputStream theStream)`
  `static boolean`
  `hasContext(Iterable<RDFStream> theStreams)`
  `static long`
  `length(Iterable<RDFStream> theStreams)`
  `static Set<Statement>`
  `parse(List<RDFStream> theStreams)`
  Parses the contents of the given streams and returns a set of statements.
  `static void`
  `parse(List<RDFStream> theStreams, RDFHandler theHandler)`
  Parses the contents of the given streams with the specified handler and closes all the streams at the end.
  `static List<Namespace>`
  `parseNamespaces(List<RDFStream> theStreams)`
  Parses the namespaces from the given streams and returns all the namespaces parsed.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### BYTE_PER_STATEMENT

    public static long BYTE_PER_STATEMENT

  - ### EMPTY

    public static final RDFStream EMPTY

- ## Method Details

  - ### forFile

    public static RDFStreamBuilder forFile(Path theFile)

  - ### forFiles

    public static RDFStreamBuilder forFiles(Path... theFiles)

  - ### forFiles

    public static RDFStreamBuilder forFiles(Collection<Path> theFiles)

  - ### forStream

    public static RDFStreamBuilder forStream(InputStream theStream)

  - ### forStatements

    public static RDFStream forStatements(Iterable<Statement> theStatements, Resource theContext)

  - ### forStatements

    public static RDFStream forStatements(Iterator<Statement> theStatements, Resource theContext)

  - ### forStatements

    public static RDFStream forStatements(Iterator<Statement> theStatements, Resource theContext, long estimatedSize)

  - ### hasContext

    public static boolean hasContext(Iterable<RDFStream> theStreams)

  - ### length

    public static long length(Iterable<RDFStream> theStreams)

  - ### estimatedCount

    public static long estimatedCount(Iterable<RDFStream> theStreams)

  - ### estimatedCount

    public static long estimatedCount(long theBytes, RDFFormat theFormat)

  - ### formatParseException

    public static String formatParseException(RDFStream theStream, Exception theError)

  - ### parse

    public static void parse(List<RDFStream> theStreams, RDFHandler theHandler) throws InvalidRDF, IOException
    Parses the contents of the given streams with the specified handler and closes all the streams at the end. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.
    Parameters:
      `theStreams` - streams to parse
      `theHandler` - handler
    Throws:
      `InvalidRDF`
      `IOException`

  - ### parse

    public static Set<Statement> parse(List<RDFStream> theStreams) throws InvalidRDF, IOException
    Parses the contents of the given streams and returns a set of statements. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.
    Parameters:
      `theStreams` - streams to parse
    Returns:
      set of statements parsed from all the streams
    Throws:
      `InvalidRDF`
      `IOException`

  - ### parseNamespaces

    public static List<Namespace> parseNamespaces(List<RDFStream> theStreams) throws InvalidRDF
    Parses the namespaces from the given streams and returns all the namespaces parsed. This function will only parse the namespaces declared at the beginning of the stream and will stop parsing as soon as the first statement is parsed. Therefore, it can efficiently parse the namespaces from very large streams without processing the whole stream but if a stream has namespace declarations mixed with statements they will not be returned in the results. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.
    Parameters:
      `theStreams` - streams to parse
    Returns:
      set of statements parsed from all the streams
    Throws:
      `InvalidRDF`