Class ConfigData

java.lang.Object
csw.config.api.ConfigData

public class ConfigData extends Object
This class represents the contents of the files being managed. It wraps an Akka streams of ByteString.

param: source an akka source that materializes to stream of bytes param: length the length representing number of bytes

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static ConfigData
    from(akka.stream.scaladsl.Source<akka.util.ByteString,Object> dataBytes, long length)
    An internally used method to create that take an akka source and length of data and creates a ConfigData instance out of it
    static ConfigData
    fromBytes(byte[] bytes)
    Create ConfigData from byte array
    static ConfigData
    fromPath(Path path)
    Create ConfigData from file path
    static ConfigData
    Create ConfigData from string
    long
     
    akka.stream.scaladsl.Source<akka.util.ByteString,Object>
     
    scala.concurrent.Future<com.typesafe.config.Config>
    toConfigObject(akka.actor.typed.ActorSystem<?> system)
    Returns a future of Config object if the data is in valid parseable HOCON format.
    toInputStream(akka.actor.typed.ActorSystem<?> system)
    Returns an inputStream which emits the bytes read from source of file data
    CompletableFuture<com.typesafe.config.Config>
    toJConfigObject(akka.actor.typed.ActorSystem<?> system)
    Returns a future of Config object if the data is in valid parseable HOCON format.
    toJStringF(akka.actor.typed.ActorSystem<?> system)
    Java API that returns a future string by reading the source.
    scala.concurrent.Future<Path>
    toPath(Path path, akka.actor.typed.ActorSystem<?> system)
    Writes config data to a provided file path and returns future file
    scala.concurrent.Future<String>
    toStringF(akka.actor.typed.ActorSystem<?> system)
    Returns a future string by reading the source

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigData

      public ConfigData()
  • Method Details

    • fromString

      public static ConfigData fromString(String str)
      Create ConfigData from string

      Parameters:
      str - the string which needs to be converted to ConfigData
      Returns:
      the ConfigData created from the given string
    • fromPath

      public static ConfigData fromPath(Path path)
      Create ConfigData from file path

      Parameters:
      path - the path which needs to be converted to ConfigData
      Returns:
      the ConfigData created from the given path
    • fromBytes

      public static ConfigData fromBytes(byte[] bytes)
      Create ConfigData from byte array

      Parameters:
      bytes - an array of bytes that is converted to ConfigData
      Returns:
      the ConfigData created from the given array of bytes
    • from

      public static ConfigData from(akka.stream.scaladsl.Source<akka.util.ByteString,Object> dataBytes, long length)
      An internally used method to create that take an akka source and length of data and creates a ConfigData instance out of it

      Parameters:
      dataBytes - an akka source that materializes to stream of bytes
      length - the length representing number of bytes
      Returns:
      the ConfigData instance created out of provided dataBytes and length
    • source

      public akka.stream.scaladsl.Source<akka.util.ByteString,Object> source()
    • length

      public long length()
    • toStringF

      public scala.concurrent.Future<String> toStringF(akka.actor.typed.ActorSystem<?> system)
      Returns a future string by reading the source

      Parameters:
      system - an akka system required to start the stream of file data that will form a string out of bytes
      Returns:
      a future that completes with string representation of file data
    • toConfigObject

      public scala.concurrent.Future<com.typesafe.config.Config> toConfigObject(akka.actor.typed.ActorSystem<?> system)
      Returns a future of Config object if the data is in valid parseable HOCON format. Else, throws ConfigException.

      Parameters:
      system - an akka system required to start the stream of file data that will form a string out of bytes and parse it to Config model
      Returns:
      a future that completes with Config model representing the file data
    • toJStringF

      public CompletableFuture<String> toJStringF(akka.actor.typed.ActorSystem<?> system)
      Java API that returns a future string by reading the source.

      Parameters:
      system - required to start the stream of file data that will form a string out of bytes
      Returns:
      a CompletableFuture that completes with string representation of file data
    • toJConfigObject

      public CompletableFuture<com.typesafe.config.Config> toJConfigObject(akka.actor.typed.ActorSystem<?> system)
      Returns a future of Config object if the data is in valid parseable HOCON format. Else, throws ConfigException.

      Parameters:
      system - an akka system required to start the stream of file data that will form a string out of bytes and parse it to Config model
      Returns:
      a CompletableFuture that completes with Config model representing the file data
    • toPath

      public scala.concurrent.Future<Path> toPath(Path path, akka.actor.typed.ActorSystem<?> system)
      Writes config data to a provided file path and returns future file

      Parameters:
      path - the path to which the file data from config service is dumped on local machine
      system - an akka system required to start the stream of file data and dump it onto the provided path
      Returns:
      a future of path that represents the file path on local machine
    • toInputStream

      public InputStream toInputStream(akka.actor.typed.ActorSystem<?> system)
      Returns an inputStream which emits the bytes read from source of file data

      Parameters:
      system - an akka system required to start the stream of file data and convert it to InputStream
      Returns:
      an inputStream which emits the bytes read from source of file data