Package csw.config.api
Class ConfigData
java.lang.Object
csw.config.api.ConfigData
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigData
An internally used method to create that take an akka source and length of data and creates a ConfigData instance out of itstatic ConfigData
fromBytes
(byte[] bytes) Create ConfigData from byte arraystatic ConfigData
Create ConfigData from file pathstatic ConfigData
fromString
(String str) Create ConfigData from stringlong
length()
akka.stream.scaladsl.Source<akka.util.ByteString,
Object> source()
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 dataCompletableFuture<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>
Writes config data to a provided file path and returns future filescala.concurrent.Future<String>
toStringF
(akka.actor.typed.ActorSystem<?> system) Returns a future string by reading the source
-
Constructor Details
-
ConfigData
public ConfigData()
-
-
Method Details
-
fromString
Create ConfigData from string- Parameters:
str
- the string which needs to be converted to ConfigData- Returns:
- the ConfigData created from the given string
-
fromPath
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
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 byteslength
- the length representing number of bytes- Returns:
- the ConfigData instance created out of provided dataBytes and length
-
source
-
length
public long length() -
toStringF
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 toConfig
model- Returns:
- a future that completes with
Config
model representing the file data
-
toJStringF
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 toConfig
model- Returns:
- a CompletableFuture that completes with
Config
model representing the file data
-
toPath
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 machinesystem
- an akka system required to start the stream of file data and dump it onto the providedpath
- Returns:
- a future of path that represents the file path on local machine
-
toInputStream
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
-