Grep (Java Functional Samples)
Date: 2020-08-07

simple

## Class Grep

- java.lang.Object
- - simple.Grep

-     public class Grep
      extends java.lang.Object

  Sample continuous (streaming) grep topology application. This Java application builds a simple topology that watches a directory for files, reads each file and output lines that contain the search term. Thus as each file is added to the directory, the application will read it and output matching lines.
  The application implements the typical pattern of code that declares a topology followed by submission of the topology to a Streams context `com.ibm.streamsx.topology.context.StreamsContext`.
  This demonstrates the a continuous application and use of utility classes that produce streams.

  This may be executed from the `samples/java/functional` directory as:

  - `java -cp functionalsamples.jar:../../../com.ibm.streamsx.topology/lib/com.ibm.streamsx.topology.jar:$STREAMS_INSTALL/lib/com.ibm.streams.operator.samples.jar simple.Grep CONTEXT_TYPE $HOME/books Elizabeth` - Run directly from the command line.
  CONTEXT_TYPE is one of:
  - `DISTRIBUTED` - Run as an IBM Streams distributed application.
  - `STANDALONE` - Run as an IBM Streams standalone application.
  - `EMBEDDED` - Run embedded within this JVM.
  - `BUNDLE` - Create an IBM Streams application bundle.
  - `TOOLKIT` - Create an IBM Streams application toolkit.
- An application execution within your IDE once you set the class path to include the correct jars.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Grep()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(java.lang.String[] args)` Sample continuous (streaming) grep topology application.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Grep

          public Grep()

  - ### Method Detail

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.lang.Exception

      Sample continuous (streaming) grep topology application. This Java application builds a simple topology that watches a directory for files, reads each file and output lines that contain the search term. Thus as each file is added to the directory, the application will read it and output matching lines.
      The application implements the typical pattern of code that declares a topology followed by submission of the topology to a Streams context `com.ibm.streamsx.topology.context.StreamsContext`.

      Three arguments are required:

      - `contextType` - The type of the context to execute the topology in, e.g. `EMBEDDED or STANDALONE`.
      - `directory` - Directory to watch for files.
      - `term` - Search term, if any line in a file contains `term` then it will be printed.
      For example (classpath omitted for brevity):
      `java simple.Grep EMBEDDED $HOME/books Elizabeth`
      Throws:
        `java.lang.Exception`