From: <ssk...@vh...> - 2005-11-30 13:24:12
|
Author: sskracic Date: 2005-11-30 14:21:46 +0100 (Wed, 30 Nov 2005) New Revision: 1017 Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java Log: CategoryFilter can now accept additional parameter, instructing the filter to look the membership of children categories as well. Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-11-30 12:05:40 UTC (rev 1016) +++ trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-11-30 13:21:46 UTC (rev 1017) @@ -27,18 +27,29 @@ * to the category membership filter type */ public class CategoryFilterSpecification extends FilterSpecification { - + public static final String CATEGORIES = "categories"; + public static final String DESCEND = "descend"; /** * Creates a new category filter spec * @param cats the categories to check membership of */ public CategoryFilterSpecification(Category[] cats) { - super(new Object[] { CATEGORIES, cats }, + this(cats, false); + } + + /** + * Creates a new category filter spec + * @param cats the categories to check membership of + * @param descend whether the membership of specified categories' children + * also satisfies the filter + */ + public CategoryFilterSpecification(Category[] cats, boolean descend) { + super(new Object[] { CATEGORIES, cats, DESCEND, new Boolean(descend) }, new CategoryFilterType()); } - + /** * Returns the list of categories to check * @return the list of categories @@ -46,4 +57,11 @@ public Category[] getCategories() { return (Category[])get(CATEGORIES); } + + /** + * @return the flag indicating whether the category children are included in match + */ + public boolean shouldDescend() { + return Boolean.TRUE.equals(get(DESCEND)); + } } |