-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFilter.java
More file actions
51 lines (46 loc) · 1.17 KB
/
Copy pathFilter.java
File metadata and controls
51 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Filter is an abstract class that implements GenericFilter.
* It sets up the general outline for how a filter works:
* it processes an input, and returns the local output.
* @author gmh73
*
* @param <T> a type of object
*/
public abstract class Filter<T> implements GenericFilter<T>{
//The most recent/next output
private T output;
/**
* Returns the previous output.
* @return the previous output
*/
public final T getPrevOutput() {
return output;
}
/**
* Resets the output to r.
* Will have a different effect for different filters.
* @param r
*/
public abstract void reset(T r);
/**
* Set the output to the given parameter.
* @param prevOutput set the output to this value.
*/
protected final void setOutput(T prevOutput) {
this.output = prevOutput;
}
/**
* The filter function calls the abstract function
* processInput(), then returns the local output variable.
*/
public final T filter(T input){
processInput(input);
return output;
}
/**
* An abstract function that will alter the local output
* to control the next output.
* @param input the current input
*/
protected abstract void processInput(T input);
}