Package org.apache.calcite.util
Class Puffin
java.lang.Object
org.apache.calcite.util.Puffin
A text processor similar to Awk.
Example use:
File file; final Puffin.Program program = Puffin.builder() .add(line -> !line.startsWith("#"), line -> counter.incrementAndGet()) .after(context -> context.println("There were " + counter.get() + " uncommented lines")) .build(); program.execute(Source.of(file), System.out);
prints the following to stdout:
There were 3 uncommented lines.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Fluent interface for constructing a Program.static class
Context for executing a Puffin program within a given file.static interface
A line in a file.static interface
A Puffin program. -
Method Summary
Modifier and TypeMethodDescriptionstatic Puffin.Builder<Unit,
Unit> builder()
Creates a Builder with no state.static <G,
F> Puffin.Builder<G, F> Creates a Builder.
-
Method Details
-
builder
public static <G,F> Puffin.Builder<G,F> builder(Supplier<G> globalStateFactory, Function<G, F> fileStateFactory) Creates a Builder.- Type Parameters:
G
- Type of state that is created when we start processingF
- Type of state that is created when we start processing a file- Parameters:
fileStateFactory
- Creates the state for each file- Returns:
- Builder
-
builder
Creates a Builder with no state.
-