Package io.jawk.jrt

Interface InputSource

All Known Implementing Classes:
StreamInputSource

public interface InputSource
Strategy for sourcing input records for the AWK main loop.

The default AWK behavior reads records from an InputStream and splits them using the field separator (FS). Implementations of this interface can bypass that text-based flow and supply pre-structured records directly (for example, rows from an in-memory table).

  • Method Summary

    Modifier and Type
    Method
    Description
    Returns pre-split fields for the current record, or null when the runtime should split $0 using FS.
    default String
    Deprecated.
    default String
    Returns the current record text ($0), or null when the source only exposes pre-split fields for the current record.
    boolean
    Indicates whether the current record originates from a named file in the argument list.
    boolean
    Advances to the next input record.
  • Method Details

    • nextRecord

      boolean nextRecord() throws IOException
      Advances to the next input record.

      Implementations should keep the current record accessible through getRecordText() and getFields() until a subsequent call successfully advances to a new record. This allows END blocks to continue observing the last consumed record after the final EOF probe.

      Returns:
      true when a record is available, false when input is exhausted
      Throws:
      IOException - if an I/O error occurs
    • getRecordText

      default String getRecordText()
      Returns the current record text ($0), or null when the source only exposes pre-split fields for the current record.

      When both getRecordText() and getFields() return non-null values, the field list is authoritative for field/NF access while the record text is authoritative for the initial $0 value.

      Returns:
      current record text, or null when unavailable
    • getRecord

      @Deprecated default String getRecord()
      Deprecated.
      Returns the current record text ($0).

      Deprecated compatibility alias for embedders that still implement the historic getRecord() method instead of getRecordText(). New implementations should override getRecordText() directly.

      Returns:
      current record text, or null when unavailable
    • getFields

      List<String> getFields()
      Returns pre-split fields for the current record, or null when the runtime should split $0 using FS.

      When non-null, element 0 corresponds to $1, element 1 to $2, and so on.

      Returns:
      field values for $1..$NF, or null to request standard FS-based splitting
    • isFromFilenameList

      boolean isFromFilenameList()
      Indicates whether the current record originates from a named file in the argument list.
      Returns:
      true when sourced from a filename argument