Package io.jawk.jrt

Class AppendableAwkSink

java.lang.Object
io.jawk.jrt.AwkSink
io.jawk.jrt.AppendableAwkSink

public final class AppendableAwkSink extends AwkSink
Text AwkSink backed by an Appendable.

All writes to the underlying Appendable are synchronized on a shared lock so that concurrent access from the main AWK thread (print/ printf) and background DataPump threads (getPrintStream()) cannot corrupt the output.

  • Constructor Details

    • AppendableAwkSink

      public AppendableAwkSink(Appendable appendableParam)
      Creates a sink backed by an Appendable.
      Parameters:
      appendableParam - appendable that should receive AWK output
    • AppendableAwkSink

      public AppendableAwkSink(Appendable appendableParam, Locale locale)
      Creates a sink backed by an Appendable.
      Parameters:
      appendableParam - appendable that should receive AWK output
      locale - locale used for numeric formatting
  • Method Details

    • print

      public void print(String ofs, String ors, String ofmt, Object... values) throws IOException
      Description copied from class: AwkSink
      Writes one AWK print operation.
      Specified by:
      print in class AwkSink
      Parameters:
      ofs - output field separator
      ors - output record separator
      ofmt - numeric output format used by plain print
      values - values supplied to print
      Throws:
      IOException - if the sink cannot write the output
    • printf

      public void printf(String ofs, String ors, String ofmt, String format, Object... values) throws IOException
      Description copied from class: AwkSink
      Writes one AWK printf operation.
      Specified by:
      printf in class AwkSink
      Parameters:
      ofs - output field separator
      ors - output record separator
      ofmt - numeric output format available to the sink
      format - format string passed to printf
      values - arguments supplied after the format string
      Throws:
      IOException - if the sink cannot write the output
    • flush

      public void flush() throws IOException
      Description copied from class: AwkSink
      Flushes any buffered output held by this sink.
      Overrides:
      flush in class AwkSink
      Throws:
      IOException - if the sink cannot be flushed
    • getPrintStream

      public PrintStream getPrintStream()
      Description copied from class: AwkSink
      Returns a PrintStream view that receives raw process output written by spawned commands such as system("...").

      The default implementation returns a stream that silently discards all output. Override this method in sinks that need to capture process output.

      Overrides:
      getPrintStream in class AwkSink
      Returns:
      print stream that should receive raw process output