Interface Source


@Experimental public interface Source
Provides access to the contents of a source independently of the backing store (e.g. file system, database, memory).

This is mainly used to parse files into objects such as Project, Model, Settings, or PersistedToolchains.

Since:
4.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Provides a user-friendly hint about the location of the source.
    Provides access the file to be parsed, if this source is backed by a file.
    Creates a new byte stream to the source contents.
    resolve(String relative)
    Returns a new source identified by a relative path.
  • Method Details

    • getPath

      @Nullable Path getPath()
      Provides access the file to be parsed, if this source is backed by a file.
      Returns:
      the underlying Path, or null if this source is not backed by a file
    • openStream

      @Nonnull InputStream openStream() throws IOException
      Creates a new byte stream to the source contents. Closing the returned stream is the responsibility of the caller.
      Returns:
      a byte stream to the source contents, never null
      Throws:
      IOException - in case of IO issue
    • getLocation

      @Nonnull String getLocation()
      Provides a user-friendly hint about the location of the source. This could be a local file path, a URI or just an empty string. The intention is to assist users during error reporting.
      Returns:
      a user-friendly hint about the location of the source, never null
    • resolve

      Source resolve(String relative)
      Returns a new source identified by a relative path. Implementation MUST be able to accept relative parameter values that
      • use either / or \ file path separator,
      • have .. parent directory references,
      • point either at file or directory.
      Parameters:
      relative - is the path of the requested source relative to this source
      Returns:
      related source or null if no such source