com.miginfocom.calendar.category
Class CategoryFilter

java.lang.Object
  extended by com.miginfocom.calendar.category.CategoryFilter
All Implemented Interfaces:
Filter, java.io.Serializable

public class CategoryFilter
extends java.lang.Object
implements Filter

A filter that can be used in a GridRow to exclude unwanted ActivityViews.

This filter has "OR" logic wich means it will accept a categorizable object as long as at least one of its categories is in the list of categories for this filter.

See Also:
Serialized Form

Constructor Summary
CategoryFilter(Category category, boolean includeSubCategories, boolean acceptUncategorized)
          Constructor.
CategoryFilter(Category category, boolean includeSubCategories, boolean acceptUncategorized, Filter subFilter)
          Constructor.
CategoryFilter(Filter subCatFilter)
          Constructor for accepting all categories but filtering them with subCatFilter.
CategoryFilter(java.lang.String name, Category[] cats, boolean includeSubCategories, boolean acceptUncategorized)
          Constructor.
CategoryFilter(java.lang.String name, Category[] cats, boolean includeSubCategories, boolean acceptUncategorized, Filter subCatFilter)
          Constructor.
 
Method Summary
 boolean accept(java.lang.Object categorizable)
          Returns if the categorizable is approved by the filter.
static CategoryFilter[] createFilterRowsDeep(Category root, boolean acceptUncategorized)
          Creates one CategoryFilter row for every sub category under root.
 Category[] getCategories()
           
 java.lang.String getName()
          Returns a human readable name for the filter.
 boolean isOrLogic()
          Returns true if OR-logic, which means that only one category needs to be equal for this filter to return true.
 void setOrLogic(boolean isOr)
          Set to true if OR-logic, which means that only one category needs to be equal for this filter to return true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CategoryFilter

public CategoryFilter(Category category,
                      boolean includeSubCategories,
                      boolean acceptUncategorized)
Constructor. Name will be set to the name of the category.

Parameters:
category - The category that this filter represents. Not null.
includeSubCategories - If categories below category should also be accepted.
acceptUncategorized - If true Categorizable object that doesn't have a category id will be accepted anyway.
See Also:
Category.getProperty(com.miginfocom.util.PropertyKey)

CategoryFilter

public CategoryFilter(Category category,
                      boolean includeSubCategories,
                      boolean acceptUncategorized,
                      Filter subFilter)
Constructor. Name will be set to the name of the category.

Parameters:
category - The category that this filter represents. Not null.
includeSubCategories - If categories below category should also be accepted.
acceptUncategorized - If true Categorizable object that doesn't have a category id will be accepted anyway.
subFilter - A filter that also have to be evaluated to true for the category that matches. This can normally not be done with a CompositeFilter since you can not with a composite filter know the category that was accepted.

If null no subfilter will be applied.

See Also:
Category.getProperty(com.miginfocom.util.PropertyKey)

CategoryFilter

public CategoryFilter(java.lang.String name,
                      Category[] cats,
                      boolean includeSubCategories,
                      boolean acceptUncategorized)
Constructor.

Parameters:
name - The name of this filter.
cats - The categories that this filter represents, if any. Not null.
includeSubCategories - If categories below cats should also be accepted.
acceptUncategorized - If true Categorizable object that doesn't have a category id will be accepted anyway.
See Also:
Category.getProperty(com.miginfocom.util.PropertyKey)

CategoryFilter

public CategoryFilter(Filter subCatFilter)
Constructor for accepting all categories but filtering them with subCatFilter.

Parameters:
subCatFilter - A filter that have to be evaluated to true for at least one category that matches. This can normally not be done with a CompositeFilter since you can not with a composite filter know the category that was accepted. The filter will be sent the Category as the PropertyProvider to its accept method.
See Also:
Category.getProperty(com.miginfocom.util.PropertyKey)

CategoryFilter

public CategoryFilter(java.lang.String name,
                      Category[] cats,
                      boolean includeSubCategories,
                      boolean acceptUncategorized,
                      Filter subCatFilter)
Constructor.

Parameters:
cats - The categories that this filter represents, if any. Not null.
includeSubCategories - If categories below cats should also be accepted.
subCatFilter - A filter that also have to be evaluated to true for the category that matches. This can normally not be done with a CompositeFilter since you can not with a composite filter know the category that was accepted. The filter will be sent the Category as the PropertyProvider to its accept method.

If null no subfilter will be applied.

See Also:
Category.getProperty(com.miginfocom.util.PropertyKey)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Filter
Returns a human readable name for the filter.

Specified by:
getName in interface Filter
Returns:
A human readable name for the filter.

getCategories

public Category[] getCategories()

isOrLogic

public boolean isOrLogic()
Returns true if OR-logic, which means that only one category needs to be equal for this filter to return true.

If set to false AND logic is used.

NOT IMPLEMENTED YET!

Returns:
true is OR logic. false if AND logic.

setOrLogic

public void setOrLogic(boolean isOr)
Set to true if OR-logic, which means that only one category needs to be equal for this filter to return true.

If set to false AND logic is used.

NOT IMPLEMENTED YET!

Parameters:
isOr - true is OR logic. false if AND logic.

accept

public boolean accept(java.lang.Object categorizable)
Returns if the categorizable is approved by the filter.

Specified by:
accept in interface Filter
Parameters:
categorizable - The categorizable to approve. Not null and must be of type Categorizable.
Returns:
If the categorizable is approved.

createFilterRowsDeep

public static CategoryFilter[] createFilterRowsDeep(Category root,
                                                    boolean acceptUncategorized)
Creates one CategoryFilter row for every sub category under root. Depth first.

Parameters:
root - The root category to start from. Will be the first one returned.
acceptUncategorized - If true Categorizable object that doesn't have a
Returns:
One CategoryFilter row for every sub category under root. Depth first.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.