Class DataSource

java.lang.Object
com.github.cafapi.common.util.ref.DataSource
Direct Known Subclasses:
DataStoreSource

public abstract class DataSource extends Object
Interface for defining how to retrieve objects or streams from a reference.
  • Constructor Details

    • DataSource

      public DataSource()
  • Method Details

    • getObject

      public abstract <T> T getObject(String ref, Class<T> clazz) throws DataSourceException
      Retrieve an object of the specified class identified by a specific reference.
      Type Parameters:
      T - the type of the object instance
      Parameters:
      ref - the reference that points to an instance of an object of the specified class
      clazz - the class of the object instance the reference points to
      Returns:
      the object instance of the specified class identified by the specified reference
      Throws:
      DataSourceException - if the object instance cannot be acquired
    • getStream

      public abstract InputStream getStream(String ref) throws DataSourceException
      Retrieve a stream of data identified by a specific reference.
      Parameters:
      ref - the reference that points to a stream of data
      Returns:
      a stream of data identified by the specified reference
      Throws:
      DataSourceException - if the data stream cannot be acquired
    • getDataSize

      public abstract long getDataSize(String ref) throws DataSourceException
      Determine the size of the data abstracted.
      Parameters:
      ref - the reference that points to the data
      Returns:
      the size of the data, in bytes
      Throws:
      DataSourceException - if the data size cannot be acquired