de.fh_mannheim.mm.dms.framework
Class CategoryManager

java.lang.Object
  extended byde.fh_mannheim.mm.dms.framework.CategoryManager
All Implemented Interfaces:
IElement, IProducer

public class CategoryManager
extends java.lang.Object
implements IProducer

This class organizes all categories.

Version:
$Revision: 1.13 $
Author:
Jan Löffler, mail@jlsoft.de

Constructor Summary
CategoryManager(Config cfg)
          Constructor.
 
Method Summary
 boolean addCategory(Category cat)
          Add a new category.
 boolean deleteCategory(int nID)
          Delete category.
 boolean existsCategory(int nCategoryID)
          Check if category exists.
 boolean existsCategory(java.lang.String strCategory)
          Check if category exists.
 boolean exportCategories(java.lang.String strFilename)
          Export categories to xml file.
 CategoryList getAllCategories()
          Get all names of categories.
 Category getCategory(int nCategoryID)
          Get a category by id.
 Category getCategory(java.lang.String strCategory)
          Get a category by name.
 int getCategoryNum()
          Count all categories.
 int importCategories(java.lang.String strFilename)
          Import categories from xml file..
 org.w3c.dom.Document produceReport()
          Generate xml document.
 org.w3c.dom.Element toElement(org.w3c.dom.Document doc)
          Write information of categories in a xml element.
 org.w3c.dom.Element toElement(org.w3c.dom.Element element, org.w3c.dom.Document doc)
          Write information of categories in a xml element.
 boolean updateCategory(Category editedCategory)
          Update an existing category.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.fh_mannheim.mm.dms.framework.IElement
toString
 

Constructor Detail

CategoryManager

public CategoryManager(Config cfg)
Constructor.

Parameters:
cfg - Config
Method Detail

addCategory

public boolean addCategory(Category cat)
                    throws DuplicateCategoryException
Add a new category.

Parameters:
cat - Category
Returns:
true, if successful
Throws:
DuplicateCategoryException - if category already exists

deleteCategory

public boolean deleteCategory(int nID)
Delete category.

Parameters:
nID - ID of category
Returns:
true, if successful

existsCategory

public boolean existsCategory(int nCategoryID)
Check if category exists.

Parameters:
nCategoryID - ID of category
Returns:
true, if successful

existsCategory

public boolean existsCategory(java.lang.String strCategory)
Check if category exists.

Parameters:
strCategory - Name of category
Returns:
true, if successful

exportCategories

public boolean exportCategories(java.lang.String strFilename)
                         throws java.io.IOException
Export categories to xml file.

Parameters:
strFilename - Filename of xml file
Returns:
true, if successful
Throws:
java.io.IOException - When file could not be saved

getAllCategories

public CategoryList getAllCategories()
Get all names of categories.

Returns:
CategoryList with names

getCategory

public Category getCategory(int nCategoryID)
Get a category by id.

Parameters:
nCategoryID - ID of category

getCategory

public Category getCategory(java.lang.String strCategory)
Get a category by name.

Parameters:
strCategory - Name of category

getCategoryNum

public int getCategoryNum()
Count all categories.

Returns:
number of found categories

importCategories

public int importCategories(java.lang.String strFilename)
Import categories from xml file..

Parameters:
strFilename - Filename of xmlfile
Returns:
Number of imported categories

produceReport

public org.w3c.dom.Document produceReport()
Generate xml document.

Specified by:
produceReport in interface IProducer
Returns:
xml document

toElement

public org.w3c.dom.Element toElement(org.w3c.dom.Document doc)
Write information of categories in a xml element.

Specified by:
toElement in interface IElement
Parameters:
doc - XML Document
Returns:
element

toElement

public org.w3c.dom.Element toElement(org.w3c.dom.Element element,
                                     org.w3c.dom.Document doc)
Write information of categories in a xml element.

Specified by:
toElement in interface IElement
Parameters:
element - Root element
doc - XML Document
Returns:
element

updateCategory

public boolean updateCategory(Category editedCategory)
Update an existing category.

Parameters:
editedCategory - Category, which should be edited
Returns:
true, if successful