java.lang.Object
io.helidon.common.Base64Value
Base64 wrapper.
APIs use base64 encoding to transfer binary data as strings. This class provides helpful methods
to handle such transitions.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Base64Value
create
(byte[] bytes) Create a base64 value from bytes.static Base64Value
Create a base64 value from plain text.static Base64Value
createFromEncoded
(String base64Text) Create from an already encoded base64 value.toBase64()
Base64 encoded string.byte[]
toBytes()
Decoded value as bytes.Returns decoded bytes as a string.toString()
-
Method Details
-
create
Create a base64 value from plain text. This method uses UTF-8 bytes of the string to create a base64 encoded string.- Parameters:
plainText
- plain text to use- Returns:
- a new value
-
create
Create a base64 value from bytes. The bytes are encoded using base64.- Parameters:
bytes
- bytes to use- Returns:
- a new value
-
createFromEncoded
Create from an already encoded base64 value.- Parameters:
base64Text
- base64 to use (no encoding will be done)- Returns:
- a new value
-
toBase64
Base64 encoded string.- Returns:
- base64 value
-
toBytes
public byte[] toBytes()Decoded value as bytes.- Returns:
- bytes
-
toDecodedString
Returns decoded bytes as a string.WARNING - this method is potentially dangerous, as it uses the underlying bytes to create a new string without any validation whether it is in fact bytes fit for a readable string. Use only when the data is known to be a string.
- Returns:
- string value from the decoded bytes
-
toString
-