net.sf.borg.model
Class CategoryModel

java.lang.Object
  extended by net.sf.borg.model.Model
      extended by net.sf.borg.model.CategoryModel

public class CategoryModel
extends Model

The Class CategoryModel manages Categories. Categories are not entities, they are plain text strings. Categories do not exist outside of other Entities. This class maintains a cache of category information in memory but does not persist it. It recreates this information from the category-aware models as needed.


Nested Class Summary
(package private) static interface CategoryModel.CategorySource
          interface implemented by Models whose entities contain categories
 
Nested classes/interfaces inherited from class net.sf.borg.model.Model
Model.Listener
 
Field Summary
(package private)  Collection<CategoryModel.CategorySource> sources
          The set of category source models
static String UNCATEGORIZED
          a non-null value to represent the lack of a category
 
Constructor Summary
CategoryModel()
           
 
Method Summary
 void addCategory(String cat)
          Add a category to the cache.
 void addSource(CategoryModel.CategorySource s)
          Add a category source.
 Collection<String> getCategories()
          Get all categories.
static CategoryModel getReference()
          Gets the singleton reference.
 Collection<String> getShownCategories()
          Get the shown categories.
 boolean isShown(String cat)
          Checks if a category is being shown.
 void remove()
          Removes the listeners.
 void setShownCategories(Collection<String> cats)
          Sets the set of shown categories.
 void showAll()
          Show all categories.
 void showCategory(String cat)
          Show a particular category.
 void syncCategories()
          Sync categories with the sources (clears the cache and re-reads the list of categories).
 
Methods inherited from class net.sf.borg.model.Model
addListener, refreshListeners, removeListener, removeListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNCATEGORIZED

public static final String UNCATEGORIZED
a non-null value to represent the lack of a category


sources

Collection<CategoryModel.CategorySource> sources
The set of category source models

Constructor Detail

CategoryModel

public CategoryModel()
Method Detail

getReference

public static CategoryModel getReference()
Gets the singleton reference.

Returns:
the reference

addCategory

public void addCategory(String cat)
Add a category to the cache.

Parameters:
cat - the categories

addSource

public void addSource(CategoryModel.CategorySource s)
Add a category source.

Parameters:
s - the source

getCategories

public Collection<String> getCategories()
                                 throws Exception
Get all categories.

Returns:
the categories
Throws:
Exception - the exception

getShownCategories

public Collection<String> getShownCategories()
Get the shown categories.

Returns:
the shown categories

isShown

public boolean isShown(String cat)
Checks if a category is being shown.

Parameters:
cat - the cat
Returns:
true, if is shown

remove

public void remove()
Description copied from class: Model
Removes the listeners.

Overrides:
remove in class Model

setShownCategories

public void setShownCategories(Collection<String> cats)
Sets the set of shown categories.

Parameters:
cats - the shown categories

showAll

public void showAll()
Show all categories.


showCategory

public void showCategory(String cat)
Show a particular category.

Parameters:
cat - the category to show

syncCategories

public void syncCategories()
                    throws Exception
Sync categories with the sources (clears the cache and re-reads the list of categories).

Throws:
Exception - the exception


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic