Interface InputSource
- All Known Implementing Classes:
StreamInputSource
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 TypeMethodDescriptionReturns pre-split fields for the current record, ornullwhen the runtime should split$0using FS.default StringDeprecated.default StringReturns the current record text ($0), ornullwhen the source only exposes pre-split fields for the current record.booleanIndicates whether the current record originates from a named file in the argument list.booleanAdvances to the next input record.
-
Method Details
-
nextRecord
Advances to the next input record.Implementations should keep the current record accessible through
getRecordText()andgetFields()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:
truewhen a record is available,falsewhen input is exhausted- Throws:
IOException- if an I/O error occurs
-
getRecordText
Returns the current record text ($0), ornullwhen the source only exposes pre-split fields for the current record.When both
getRecordText()andgetFields()return non-null values, the field list is authoritative for field/NF access while the record text is authoritative for the initial$0value.- Returns:
- current record text, or
nullwhen unavailable
-
getRecord
Deprecated.usegetRecordText()Returns the current record text ($0).Deprecated compatibility alias for embedders that still implement the historic
getRecord()method instead ofgetRecordText(). New implementations should overridegetRecordText()directly.- Returns:
- current record text, or
nullwhen unavailable
-
getFields
Returns pre-split fields for the current record, ornullwhen the runtime should split$0using FS.When non-null, element
0corresponds to$1, element1to$2, and so on.- Returns:
- field values for
$1..$NF, ornullto request standard FS-based splitting
-
isFromFilenameList
boolean isFromFilenameList()Indicates whether the current record originates from a named file in the argument list.- Returns:
truewhen sourced from a filename argument
-
getRecordText()