Package io.jawk.jrt
Class AppendableAwkSink
java.lang.Object
io.jawk.jrt.AwkSink
io.jawk.jrt.AppendableAwkSink
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.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionAppendableAwkSink(Appendable appendableParam) Creates a sink backed by anAppendable.AppendableAwkSink(Appendable appendableParam, Locale locale) Creates a sink backed by anAppendable. -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Flushes any buffered output held by this sink.Returns aPrintStreamview that receives raw process output written by spawned commands such assystem("...").voidWrites one AWKprintoperation.voidWrites one AWKprintfoperation.Methods inherited from class io.jawk.jrt.AwkSink
formatOutputValue, formatPrintArgument, formatPrintfResult, from, from, from, from, from, from, getLocale, normalizePrintArgument, sprintf
-
Constructor Details
-
AppendableAwkSink
Creates a sink backed by anAppendable.- Parameters:
appendableParam- appendable that should receive AWK output
-
AppendableAwkSink
Creates a sink backed by anAppendable.- Parameters:
appendableParam- appendable that should receive AWK outputlocale- locale used for numeric formatting
-
-
Method Details
-
print
Description copied from class:AwkSinkWrites one AWKprintoperation.- Specified by:
printin classAwkSink- Parameters:
ofs- output field separatorors- output record separatorofmt- numeric output format used by plainprintvalues- values supplied toprint- 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:AwkSinkWrites one AWKprintfoperation.- Specified by:
printfin classAwkSink- Parameters:
ofs- output field separatorors- output record separatorofmt- numeric output format available to the sinkformat- format string passed toprintfvalues- arguments supplied after the format string- Throws:
IOException- if the sink cannot write the output
-
flush
Description copied from class:AwkSinkFlushes any buffered output held by this sink.- Overrides:
flushin classAwkSink- Throws:
IOException- if the sink cannot be flushed
-
getPrintStream
Description copied from class:AwkSinkReturns aPrintStreamview that receives raw process output written by spawned commands such assystem("...").The default implementation returns a stream that silently discards all output. Override this method in sinks that need to capture process output.
- Overrides:
getPrintStreamin classAwkSink- Returns:
- print stream that should receive raw process output
-