Package org.eolang
Class Dataized
java.lang.Object
org.eolang.Dataized
A dataized object.
The class automates the process of turning EO objects into data. The mechanism is explained in details in our canonical paper. Simply put, it makes an attempt to either type-cast the provided object into data or find "Δ" attribute inside it. If neither of that works, there is a runtime exception.
- Since:
- 0.1
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasBool()Extract the data from the object and convert to boolean.asBytes()Extract the data from the object and convert toBytes.asNumber()Extract the data from the object and convert to number.asString()Extract the data from the object and convert to string.byte[]take()Extracts the data from the EO object as a byte array.<T> TTake the data with a type.
-
Constructor Details
-
Dataized
Ctor.- Parameters:
src- The object
-
Dataized
Ctor.- Parameters:
src- The objectlog- Logger
-
-
Method Details
-
take
public byte[] take()Extracts the data from the EO object as a byte array.This method performs the dataization process, which involves converting the EO object into a byte array. It logs the dataization process if the logging level is set to FINE and the current dataization level is within the maximum allowed level. If an error occurs during dataization, it logs the error details and rethrows the exception.
Usage example:
Phi phi = ...; // Initialize your EO object Dataized dataized = new Dataized(phi); byte[] data = dataized.take();- Returns:
- The data
-
take
Take the data with a type.- Type Parameters:
T- The type- Parameters:
type- The type- Returns:
- The data
-
asString
Extract the data from the object and convert to string.- Returns:
- Data as string
-
asNumber
Extract the data from the object and convert to number.- Returns:
- Data as number
-
asBool
Extract the data from the object and convert to boolean.- Returns:
- Data as boolean
-
asBytes
Extract the data from the object and convert toBytes.- Returns:
- Data as
Bytes
-