// Assignment 4 - Pipe-and-Filter KWIC Indexing.
// Concurrent Programming, CS 498-598
// Summer 2002
//
// This code is unmaintained and may be obsolete (as well as being incorrect).
// See the answer to assignment 4 for possible updates.


class
RotateFilter 
extends FilterRunnableTemplate {


  protected boolean
  isMisbehavingObject(Object o) {
    return ((String) o).compareTo("rotate") == 0;
    }


  protected boolean
  isValidObject(Object o) {

    // The rotate filter expects to receive strings from the upstream
    // (input) filter.

    return o instanceof String;
    }


  protected void
  misbehave() {
    final int i = 1/0;
    }


  RotateFilter(String fn, buffer ib, buffer ob) {
    super(fn, ib, ob);
    }


  protected void
  process_input(Object o) {

    // Turn the input description into a KWIC index entry group and, if the
    // group's not empty, pass it downstream.

    o = KWICIndexEntry.entries((String) o);
    if (o != null)
      output_object(o);
    }
  }


syntax highlighted by Code2HTML, v. 0.9