Class Puffin

java.lang.Object
org.apache.calcite.util.Puffin

public class Puffin extends Object
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.
  • 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 processing
      F - Type of state that is created when we start processing a file
      Parameters:
      fileStateFactory - Creates the state for each file
      Returns:
      Builder
    • builder

      public static Puffin.Builder<Unit,Unit> builder()
      Creates a Builder with no state.