Class PlainString
java.lang.Object
zeroecho.sdk.content.builtin.PlainString
- All Implemented Interfaces:
DataContent, PlainContent
A
PlainContent implementation that wraps a UTF-8 string.- Author:
- Leo Galambos
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe plain text content represented by this instance.Fields inherited from interface DataContent
DEFAULT_MAX_READ_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns anInputStreamof the UTF-8 encoded string.voidsetInput(DataContent input) Connects this content to the output of a previous stage in the pipeline.byte[]toBytes()Returns the UTF-8 encoded byte array of the string.toText()Returns the original string content.
-
Field Details
-
str
The plain text content represented by this instance.
-
-
Constructor Details
-
PlainString
Constructs a PlainString with the given string.- Parameters:
str- the plain text content; must not be null
-
-
Method Details
-
toText
Returns the original string content.- Specified by:
toTextin interfaceDataContent- Returns:
- the string
-
setInput
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
PlainContentbeing encrypted, or an encrypted content being decrypted).PlainStringrepresents the start of aDataContentchain and therefore must not have any input. Calling this method with a non-nullargument will result in an exception.- Specified by:
setInputin interfaceDataContent- Parameters:
input- the precedingDataContent, which must benull- Throws:
IllegalArgumentException- ifinputis notnull
-
getStream
Returns anInputStreamof the UTF-8 encoded string.- Specified by:
getStreamin interfaceDataContent- Returns:
- a
ByteArrayInputStream
-
toBytes
public byte[] toBytes()Returns the UTF-8 encoded byte array of the string.- Specified by:
toBytesin interfaceDataContent- Returns:
- a byte array representation
-