de.hunsicker.io
Class Filters

java.lang.Object
  |
  +--de.hunsicker.io.Filters
All Implemented Interfaces:
java.io.FilenameFilter

public class Filters
extends java.lang.Object
implements java.io.FilenameFilter

Filters is used to build a filter list to apply for a search.

Version:
$Revision: 1.3.2.1 $
Author:
Marco Hunsicker

Field Summary
static int POLICY_LAZY
          If one filter accepts a file, the file will be accepted.
static int POLICY_STRICT
          Only if all filters accept a file, the file will be accepted.
 
Constructor Summary
Filters()
          Creates a new Filters object.
Filters(int policy)
          Creates a new Filters object.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Tests if a specified file should be included in a file list.
 void addFilter(java.io.FilenameFilter filter)
          Adds the given filter to the filter list.
 boolean contains(java.io.FilenameFilter filter)
          Indicates wheter the given filter is contained in the filter list.
 int getPolicy()
          Returns the policy currently being used.
 void removeFilter(java.io.FilenameFilter filter)
          Removes the given filter.
 void setPolicy(int policy)
          Sets the filter policy to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_LAZY

public static final int POLICY_LAZY
If one filter accepts a file, the file will be accepted.

See Also:
Constant Field Values

POLICY_STRICT

public static final int POLICY_STRICT
Only if all filters accept a file, the file will be accepted.

See Also:
Constant Field Values
Constructor Detail

Filters

public Filters()
Creates a new Filters object. Uses POLICY_STRICT as its policy.


Filters

public Filters(int policy)
Creates a new Filters object.

Parameters:
policy - policy to use. Either POLICY_STRICT or POLICY_LAZY.
Method Detail

setPolicy

public void setPolicy(int policy)
Sets the filter policy to use.

Parameters:
policy - policy to use. Either POLICY_STRICT or POLICY_LAZY.

getPolicy

public int getPolicy()
Returns the policy currently being used.

Returns:
used filter policy.
See Also:
setPolicy(int)

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Tests if a specified file should be included in a file list.

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - the directory in which the file was found.
name - the name of the file.
Returns:
true if and only if the name should be included in the file list.

addFilter

public void addFilter(java.io.FilenameFilter filter)
Adds the given filter to the filter list.

Parameters:
filter - filter to add.

contains

public boolean contains(java.io.FilenameFilter filter)
Indicates wheter the given filter is contained in the filter list.

Parameters:
filter - filter.
Returns:
true if the filter was registered.

removeFilter

public void removeFilter(java.io.FilenameFilter filter)
Removes the given filter.

Parameters:
filter - filter to remove.


Copyright © 1997-2005 Jalopy. All Rights Reserved.