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.ChangeEvent, 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.
 void export(Writer fw)
          Export the models data to XML
 Collection<String> getCategories()
          Get all categories.
 String getExportName()
          get the root XML element name for this model's XML representation
 String getInfo()
          return user readable information about the model
static CategoryModel getReference()
          Gets the singleton reference.
 Collection<String> getShownCategories()
          Get the shown categories.
 void importXml(InputStream is)
          Import model data from XML
 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 sync()
          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, getExistingModels, refreshListeners, refreshListeners, removeListener, removeListeners, syncModels
 
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

sync

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

Overrides:
sync in class Model
Throws:
Exception - the exception

export

public void export(Writer fw)
            throws Exception
Description copied from class: Model
Export the models data to XML

Specified by:
export in class Model
Parameters:
fw - - writer to write the XML to
Throws:
Exception

importXml

public void importXml(InputStream is)
               throws Exception
Description copied from class: Model
Import model data from XML

Specified by:
importXml in class Model
Parameters:
is - input stream containing XML
Throws:
Exception

getExportName

public String getExportName()
Description copied from class: Model
get the root XML element name for this model's XML representation

Specified by:
getExportName in class Model
Returns:
the XML root element name

getInfo

public String getInfo()
               throws Exception
Description copied from class: Model
return user readable information about the model

Specified by:
getInfo in class Model
Returns:
user readable information String
Throws:
Exception


Generated December 30 2011 by mbb using Apache Ant(TM) version 1.8.2 compiled on December 20 2010 and Java version 1.6.0_30 from Sun Microsystems Inc. on Linux i386 3.0.0-14-generic-pae