gishur.graph.core
Class NameFilter

java.lang.Object
  |
  +--gishur.core.Filter
        |
        +--gishur.graph.core.NameFilter

public class NameFilter
extends Filter

A Filter class which stores Strings. It can only be used for filtering GraphElements whose name string must be stored in the properties. One can switch between two working modes: either the stored names can be defined as the allowed names, i.e. a GraphElement with one of these names will not be filtered out, or the name strings represent the forbidden names (see acceptMode().

Version:
1.0
Author:
Christoph Sachse & Thomas Wolf

Constructor Summary
NameFilter()
          Empty constructor.
NameFilter(java.lang.String n)
          Constructor accepting n as allowed name string.
NameFilter(java.lang.String[] sa)
          Constructor accepting an array of strings as allowed name strings.
NameFilter(java.lang.String n1, java.lang.String n2)
          Constructor accepting 2 given names as allowed name strings.
NameFilter(java.lang.String n1, java.lang.String n2, java.lang.String n3)
          Constructor accepting 3 given names as allowed name strings.
NameFilter(java.lang.String n1, java.lang.String n2, java.lang.String n3, java.lang.String n4)
          Constructor accepting 4 given names as allowed name strings.
NameFilter(java.lang.String n1, java.lang.String n2, java.lang.String n3, java.lang.String n4, java.lang.String n5)
          Constructor accepting 5 given names as allowed name strings.
 
Method Summary
 boolean acceptMode()
          If the returned value is true, the filter accepts Objects that are instances of at least one class stored at this filter.
 void add(java.util.Enumeration enum)
          Adds an Enumeration of Strings to the list of strings accepted / rejected by this filter (depends on acceptMode()).
 void add(java.lang.String name)
          Adds a String object to the list of strings accepted / rejected by this filter (depends on acceptMode()).
 void add(java.lang.String[] names)
          Adds an array of Strings to the list of strings accepted / rejected by this filter (depends on acceptMode()).
 boolean check(java.lang.Object obj)
          Performs the filtering operation.
 void remove(java.util.Enumeration enum)
          Removes an Enumeration of Strings off the list of strings accepted / rejected by this filter (depends on acceptMode()).
 void remove(java.lang.String name)
          Removes a name String of the list off strings accepted / rejected by this filter (depends on acceptMode()).
 void remove(java.lang.String[] names)
          Removes an array of name Strings off the list of strings accepted / rejected by this filter (depends on acceptMode()).
 void setAcceptMode(boolean mode)
          Sets the mode of the NameFilter; if the given value is true, the filter accepts GraphElements that have names that are stored at this filter.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 
Methods inherited from class gishur.core.Filter
addFilter, nextFilter, removeFilter, valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameFilter

public NameFilter()
Empty constructor. Per default, the filter accepts no name strings as allowed names.

NameFilter

public NameFilter(java.lang.String n)
Constructor accepting n as allowed name string.

NameFilter

public NameFilter(java.lang.String n1,
                  java.lang.String n2)
Constructor accepting 2 given names as allowed name strings.

NameFilter

public NameFilter(java.lang.String n1,
                  java.lang.String n2,
                  java.lang.String n3)
Constructor accepting 3 given names as allowed name strings.

NameFilter

public NameFilter(java.lang.String n1,
                  java.lang.String n2,
                  java.lang.String n3,
                  java.lang.String n4)
Constructor accepting 4 given names as allowed name strings.

NameFilter

public NameFilter(java.lang.String n1,
                  java.lang.String n2,
                  java.lang.String n3,
                  java.lang.String n4,
                  java.lang.String n5)
Constructor accepting 5 given names as allowed name strings.

NameFilter

public NameFilter(java.lang.String[] sa)
Constructor accepting an array of strings as allowed name strings.
Method Detail

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

add

public void add(java.lang.String name)
Adds a String object to the list of strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
name - String to add.

add

public void add(java.lang.String[] names)
Adds an array of Strings to the list of strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
names - array of strings to add.

add

public void add(java.util.Enumeration enum)
Adds an Enumeration of Strings to the list of strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
enum - Enumeration of strings to add.

remove

public void remove(java.lang.String name)
Removes a name String of the list off strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
name - name to remove

remove

public void remove(java.lang.String[] names)
Removes an array of name Strings off the list of strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
names - array of names to remove

remove

public void remove(java.util.Enumeration enum)
Removes an Enumeration of Strings off the list of strings accepted / rejected by this filter (depends on acceptMode()).
Parameters:
enum - Enumeration of strings to remove

setAcceptMode

public void setAcceptMode(boolean mode)
Sets the mode of the NameFilter; if the given value is true, the filter accepts GraphElements that have names that are stored at this filter. If the given value is false, the filter accepts GraphElements that have names that are not stored at this filter.
Parameters:
mode - the mode to set
See Also:
acceptMode()

acceptMode

public boolean acceptMode()
If the returned value is true, the filter accepts Objects that are instances of at least one class stored at this filter. If the returned value is false, the filter accepts Objects that are not instances of any of the classes stored at this filter. If the returned value is true, the filter accepts GraphElements that have names that are stored at this filter. If the returned value is false, the filter accepts GraphElements that have names that are not stored at this filter.
Returns:
the actual accept mode.
See Also:
setAcceptMode(boolean)

check

public boolean check(java.lang.Object obj)
Performs the filtering operation. If obj is a GraphElement, its name will be compared to the stored name strings, and if an identical String is found, true or false will be returned (the result depends on the acceptMode()). The GraphElement's name must be stored in its properties with key string name, if no name is defined for the given GraphElement, false will be returned anyway. If obj is not a GraphElement, false will be returned.
Overrides:
check in class Filter
Parameters:
obj - the object to check
Returns:
true if obj hass an allowed name string, false otherwise