Class Base64Value

java.lang.Object
io.helidon.common.Base64Value

public class Base64Value extends Object
Base64 wrapper. APIs use base64 encoding to transfer binary data as strings. This class provides helpful methods to handle such transitions.
See Also:
  • Method Details

    • create

      public static Base64Value create(String plainText)
      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

      public static Base64Value create(byte[] bytes)
      Create a base64 value from bytes. The bytes are encoded using base64.
      Parameters:
      bytes - bytes to use
      Returns:
      a new value
    • createFromEncoded

      public static Base64Value createFromEncoded(String base64Text)
      Create from an already encoded base64 value.
      Parameters:
      base64Text - base64 to use (no encoding will be done)
      Returns:
      a new value
    • toBase64

      public String toBase64()
      Base64 encoded string.
      Returns:
      base64 value
    • toBytes

      public byte[] toBytes()
      Decoded value as bytes.
      Returns:
      bytes
    • toDecodedString

      public String 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

      public String toString()
      Overrides:
      toString in class Object