Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.gatherer.gui.metaaudit
Class Autofilter  view Autofilter download Autofilter.java

java.lang.Object
  extended byorg.greenstone.gatherer.gui.metaaudit.Autofilter

public class Autofilter
extends java.lang.Object

An Autofilter object stores the filters set on a single column, and provides a method for determining if a certain value passes the filter.

Version:
2.3

Field Summary
 boolean active
          true if the filter should be applied, false to indicate the filter is turned off.
static boolean AND
          An element of the OPERATION_TYPE enumeration, indicates that both filter expressions must be met (conjunction).
static boolean ASCENDING
          An element of the SORT_TYPE enumeration, indicates lowest to highest value column ordering.
 boolean casesense_one
          true if the matching for the first expression should be case sensitive, false otherwise.
 boolean casesense_two
          true if the matching for the second expression should be case sensitive, false otherwise.
static boolean DESCENDING
          An element of the SORT_TYPE enumeration, indicates highest to lowest value column ordering.
private static int EQUAL
           
private static int ERROR
           
private static int GREATER_THAN
           
private static int LESS_THAN
           
static java.lang.String[] METHOD_LIST
          An enumeration of symbolic names of various matching methods.
 int method_one
          The method to be used for the first filter expression, set from the values of the METHOD_LIST enumeration.
 int method_two
          The method to be used for the second filter expression, set from the values of the METHOD_LIST enumeration.
 boolean operation
          Used to determine the operation intended when applying two filters, and set using the values of the OPERATION_TYPE enumeration.
static boolean OR
          An element of the OPERATION_TYPE enumeration, indicates that either (or both) filter expressions must be met (disjunction).
 boolean sort
          Used to determine how the column this filter is applied to should be sorted, and set using the values of the SORT_TYPE enumeration.
 java.lang.String value_one
          The value to be matched against for the first expression.
 java.lang.String value_two
          The value to be matched against for the second expression.
 
Constructor Summary
Autofilter()
          Default Constructor.
 
Method Summary
 boolean active()
          Determine if this filter is currently active.
static int compareToPattern(java.lang.String s, java.lang.String p)
          A String comparison which also recognises the WildCard character.
private static int compareToPattern(java.lang.String s, java.lang.String p, int s_index, int p_index, boolean wildcard_matching)
           
 boolean filter(java.util.ArrayList values)
          Determine if this list of values (for a certain cell) passes the filter.
 boolean filter(java.util.ArrayList values, int method, java.lang.String target, boolean casesense)
          Decide whether a row should be displayed or filtered.
static void main(java.lang.String[] args)
           
 void setActive(boolean active)
          Set the current activity state of this filter.
 void setFilter(int number, int method, java.lang.String value, boolean casesense)
          Set one of the filter expressions using the given information.
 void setOperation(boolean operation)
          Set the operation to be used to join the two filters (if a second filter is set).
 void setSort(boolean sort)
          Set the sort order of this column.
 java.lang.String toString()
          Produce a textual representation of this autofilter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LESS_THAN

private static final int LESS_THAN
See Also:
Constant Field Values

EQUAL

private static final int EQUAL
See Also:
Constant Field Values

GREATER_THAN

private static final int GREATER_THAN
See Also:
Constant Field Values

ERROR

private static final int ERROR
See Also:
Constant Field Values

active

public boolean active
true if the filter should be applied, false to indicate the filter is turned off.


casesense_one

public boolean casesense_one
true if the matching for the first expression should be case sensitive, false otherwise.


casesense_two

public boolean casesense_two
true if the matching for the second expression should be case sensitive, false otherwise.


operation

public boolean operation
Used to determine the operation intended when applying two filters, and set using the values of the OPERATION_TYPE enumeration.


sort

public boolean sort
Used to determine how the column this filter is applied to should be sorted, and set using the values of the SORT_TYPE enumeration.


method_one

public int method_one
The method to be used for the first filter expression, set from the values of the METHOD_LIST enumeration.


method_two

public int method_two
The method to be used for the second filter expression, set from the values of the METHOD_LIST enumeration.


value_one

public java.lang.String value_one
The value to be matched against for the first expression.


value_two

public java.lang.String value_two
The value to be matched against for the second expression.


ASCENDING

public static final boolean ASCENDING
An element of the SORT_TYPE enumeration, indicates lowest to highest value column ordering.

See Also:
Constant Field Values

AND

public static final boolean AND
An element of the OPERATION_TYPE enumeration, indicates that both filter expressions must be met (conjunction).

See Also:
Constant Field Values

DESCENDING

public static final boolean DESCENDING
An element of the SORT_TYPE enumeration, indicates highest to lowest value column ordering.

See Also:
Constant Field Values

OR

public static final boolean OR
An element of the OPERATION_TYPE enumeration, indicates that either (or both) filter expressions must be met (disjunction).

See Also:
Constant Field Values

METHOD_LIST

public static final java.lang.String[] METHOD_LIST
An enumeration of symbolic names of various matching methods.

Constructor Detail

Autofilter

public Autofilter()
Default Constructor.

Method Detail

main

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

compareToPattern

public static int compareToPattern(java.lang.String s,
                                   java.lang.String p)
A String comparison which also recognises the WildCard character. The basic idea is that '*' matches zero or more of any characters, and if we limited patterns to be like "a*" then as soon as we hit the star we could return a match. The problem is that we want patterns like "b*y" which would match "boy" but not "bee" nor "bus" (but should return less than or greater than for each of these respectively). Thus our testing has to become non-deterministic so the matches are conducted like so: Given p = [ b * y ] Test s = [ b e e ] Result: p0=s0,{(p2>s1=>ERROR),(p1=s1,{(p1>s2=>ERROR),(p2>s2=>LESS_THAN)})} => LESS_THAN Test s = [ b o y ] Result: p0=s0,{(p2>s1=>ERROR),(p1=s1,{(p1>s2=>ERROR),(p2=s2=>EQUAL)})} => EQUAL Test s = [ b u s ] Result: p0=s0,{(p2>s1=>ERROR),(p1=s1,{(p1>s2=>ERROR),(p2GREATER_THAN)})} => GREATER_THAN where the two () phrases within a {} represent two different 'threads' of processing. Errors are generated when one string runs out of characters before the other. Only non-error results are propogated. I've decided to implement this non-deterministic matching as a recursive function call. If you analyse it you can see there are three possible actions when a '*' is detected. 1. * is an empty string, ignore it in pattern and try to compare the next character in p with the current character in s. This case only occurs if there are more characters in p (otherwise apple would be greater than a*) 2. * matches exactly the current character in s, try to match the next character in p with the next character in s 3. * matches some string of characters including the current character in s, try to match '*' against the next character in s


compareToPattern

private static int compareToPattern(java.lang.String s,
                                    java.lang.String p,
                                    int s_index,
                                    int p_index,
                                    boolean wildcard_matching)

active

public boolean active()
Determine if this filter is currently active.


filter

public boolean filter(java.util.ArrayList values)
Determine if this list of values (for a certain cell) passes the filter.


setActive

public void setActive(boolean active)
Set the current activity state of this filter.


setFilter

public void setFilter(int number,
                      int method,
                      java.lang.String value,
                      boolean casesense)
Set one of the filter expressions using the given information.


setOperation

public void setOperation(boolean operation)
Set the operation to be used to join the two filters (if a second filter is set).


setSort

public void setSort(boolean sort)
Set the sort order of this column.


filter

public boolean filter(java.util.ArrayList values,
                      int method,
                      java.lang.String target,
                      boolean casesense)
Decide whether a row should be displayed or filtered. The result depends on the selector set with setFilterType.


toString

public java.lang.String toString()
Produce a textual representation of this autofilter.