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 a URL such as file: or https:.
  • SecretPassword - destroyable secret content backed by an owned character array. Its inherited string representation is always redacted.

Behavior

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