Module io.xpipe.api
Package io.xpipe.api

Interface DataSource

All Known Subinterfaces:
DataRaw, DataStructure, DataTable, DataText
All Known Implementing Classes:
DataRawImpl, DataSourceImpl, DataStructureImpl, DataTableImpl, DataTextImpl

public interface DataSource
Represents a reference to a data source that is managed by XPipe.

The actual data is only queried when required and is not cached. Therefore, the queried data is always up-to-date at the point of calling a method that queries the data.

As soon a data source reference is created, the data source is locked within XPipe to prevent concurrent modification and the problems that can arise from it. By default, the lock is held until the calling program terminates and prevents other applications from modifying the data source in any way. To unlock the data source earlier, you can make use the unlock() method.

  • Method Details

    • drain

      static DataSource drain()
      NOT YET IMPLEMENTED!

      Creates a new supplier data source that will be interpreted as the generated data source. In case this program should be a data source generator, this method has to be called at least once to register that it actually generates a data source.

      All content that is written to this data source until the generator program terminates is will be available later on when the data source is used as a supplier later on.

      In case this method is called multiple times, the same data source is returned.

      Returns:
      the generator data source
    • sink

      static DataSource sink()
      NOT YET IMPLEMENTED!

      Creates a data source sink that will block with any read operations until an external data producer routes the output into this sink.

    • getById

      static DataSource getById(String id)
      Throws:
      IllegalArgumentException - if id is not a valid data source id
    • getLatest

      static DataSource getLatest()
      Wrapper for get(DataSourceReference) using the latest reference.
    • getByName

      static DataSource getByName(String name)
      Wrapper for get(DataSourceReference) using a name reference.
    • get

      static DataSource get(io.xpipe.core.source.DataSourceReference ref)
      Retrieves the data source for a given reference.
      Parameters:
      ref - the data source reference
    • unlock

      static void unlock()
      Releases the lock held by this program for this data source such that other applications can modify the data source again.
    • createAnonymous

      static DataSource createAnonymous(String type, Path path)
      Wrapper for create(DataStoreId, String, InputStream) that creates an anonymous data source.
    • create

      static DataSource create(io.xpipe.core.source.DataStoreId id, String type, Path path)
    • createAnonymous

      static DataSource createAnonymous(String type, URL url)
      Wrapper for create(DataStoreId, String, InputStream) that creates an anonymous data source.
    • create

      static DataSource create(io.xpipe.core.source.DataStoreId id, String type, URL url)
    • createAnonymous

      static DataSource createAnonymous(String type, InputStream in)
      Wrapper for create(DataStoreId, String, InputStream) that creates an anonymous data source.
    • create

      static DataSource create(io.xpipe.core.source.DataStoreId id, String type, InputStream in)
      Creates a new data source from an input stream.
      Parameters:
      id - the data source id
      type - the data source type
      in - the input stream to read
      Returns:
      a DataSource instances that can be used to access the underlying data
    • create

      static DataSource create(io.xpipe.core.source.DataStoreId id, io.xpipe.core.source.DataSource<?> source)
      Creates a new data source from an input stream.
      Parameters:
      id - the data source id
      Returns:
      a DataSource instances that can be used to access the underlying data
    • create

      static DataSource create(io.xpipe.core.source.DataStoreId id, String type, io.xpipe.core.store.DataStore in)
      Creates a new data source from an input stream. 1
      Parameters:
      id - the data source id
      type - the data source type
      in - the data store to add
      Returns:
      a DataSource instances that can be used to access the underlying data
    • forwardTo

      void forwardTo(DataSource target)
    • appendTo

      void appendTo(DataSource target)
    • getInternalSource

      io.xpipe.core.source.DataSource<?> getInternalSource()
    • getId

      io.xpipe.core.source.DataStoreId getId()
      Returns the id of this data source.
    • getType

      io.xpipe.core.source.DataSourceType getType()
      Returns the type of this data source.
    • getConfig

      DataSourceConfig getConfig()
    • asTable

      default DataTable asTable()
      Attempts to cast this object to a DataTable.
      Throws:
      UnsupportedOperationException - if the data source is not a table
    • asStructure

      default DataStructure asStructure()
      Attempts to cast this object to a DataStructure.
      Throws:
      UnsupportedOperationException - if the data source is not a structure
    • asText

      default DataText asText()
      Attempts to cast this object to a DataText.
      Throws:
      UnsupportedOperationException - if the data source is not a text
    • asRaw

      default DataRaw asRaw()
      Attempts to cast this object to a DataRaw.
      Throws:
      UnsupportedOperationException - if the data source is not raw