Class PlainString

java.lang.Object
zeroecho.sdk.content.builtin.PlainString
All Implemented Interfaces:
DataContent, PlainContent

public class PlainString extends Object implements PlainContent
A PlainContent implementation that wraps a UTF-8 string.
Author:
Leo Galambos
  • Field Details

    • str

      protected String str
      The plain text content represented by this instance.
  • Constructor Details

    • PlainString

      public PlainString(String str)
      Constructs a PlainString with the given string.
      Parameters:
      str - the plain text content; must not be null
  • Method Details

    • toText

      public String toText()
      Returns the original string content.
      Specified by:
      toText in interface DataContent
      Returns:
      the string
    • setInput

      public void setInput(DataContent input)
      Connects this content to the output of a previous stage in the pipeline.

      This method is used to supply the input data that this content will process (e.g., a PlainContent being encrypted, or an encrypted content being decrypted).

      PlainString represents the start of a DataContent chain and therefore must not have any input. Calling this method with a non-null argument will result in an exception.
      Specified by:
      setInput in interface DataContent
      Parameters:
      input - the preceding DataContent, which must be null
      Throws:
      IllegalArgumentException - if input is not null
    • getStream

      public InputStream getStream()
      Returns an InputStream of the UTF-8 encoded string.
      Specified by:
      getStream in interface DataContent
      Returns:
      a ByteArrayInputStream
    • toBytes

      public byte[] toBytes()
      Returns the UTF-8 encoded byte array of the string.
      Specified by:
      toBytes in interface DataContent
      Returns:
      a byte array representation