Package zeroecho.sdk.content.builtin
package zeroecho.sdk.content.builtin
Built-in plain content sources: bytes, strings, files, and passwords.
This package provides simple DataContent
implementations that act as the first stage of a pipeline. They expose bytes
via DataContent.getStream() and deliberately
reject upstream input because they are sources, not transforms.
Components
PlainBytes- wraps an in-memory byte array and exposes it as a read-only stream. The provided array is defensively copied so later caller mutations do not affect the content.PlainString- wraps a UTF-8 string and exposes it as bytes on demand.PlainFile- reads content from aURLsuch asfile:orhttps:.SecretPassword- destroyable secret content backed by an owned character array. Its inherited string representation is always redacted.
Behavior
- These classes start a data pipeline and therefore throw
IllegalArgumentExceptionifDataContent.setInput(zeroecho.sdk.content.api.DataContent)is called with a non-null argument. - Callers must close the
InputStreamreturned byDataContent.getStream(). PlainBytesreturns a defensive copy fromDataContent.toBytes()andPlainStringencodes to UTF-8 when bytes are requested.
Typical usage
// Wrap a byte[] as a DataContent source and stream it to an OutputStream.
zeroecho.sdk.content.api.DataContent src = new zeroecho.sdk.content.builtin.PlainBytes(data);
try (java.io.InputStream in = src.getStream()) {
in.transferTo(out);
}
// Read from a file URL.
java.net.URL url = java.nio.file.Path.of("input.bin").toUri().toURL();
zeroecho.sdk.content.api.DataContent fileSrc = new zeroecho.sdk.content.builtin.PlainFile(url);
try (java.io.InputStream in = fileSrc.getStream()) {
in.transferTo(out);
}
// Use a password source and destroy it after consumption.
zeroecho.sdk.content.builtin.SecretPassword secret =
new zeroecho.sdk.content.builtin.SecretPassword(24);
try (java.io.InputStream in = secret.getStream()) {
in.transferTo(out);
} finally {
secret.destroy();
}
- Since:
- 1.0
-
ClassesClassDescriptionAn implementation of
PlainContentthat encapsulates a byte array.APlainContentimplementation that reads content from a file-like URL.APlainContentimplementation that wraps a UTF-8 string.Destroyable password content backed exclusively by an owned character array.