public final class CategoryFactory extends Object implements CatFactory
Constructor and Description |
---|
CategoryFactory(org.springframework.core.io.Resource resource)
Constructor for CategoryFactory.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addCategory(String groupname,
Category cat)
Add category to a categorygroup.
|
void |
addCategoryGroup(CategoryGroup group)
Add a categorygroup.
|
boolean |
deleteCategory(String groupname,
Category cat)
Delete category from a categorygroup.
|
boolean |
deleteCategory(String groupname,
String catlabel)
Delete category from a categorygroup.
|
boolean |
deleteCategoryGroup(CategoryGroup group)
Delete a categorygroup.
|
boolean |
deleteCategoryGroup(String groupname)
Delete a categorygroup.
|
Category |
getCategory(String name)
getCategory
|
Catinfo |
getConfig()
Return the categories configuration.
|
String |
getEffectiveRule(String catlabel)
getEffectiveRule
|
static CatFactory |
getInstance()
Return the singleton instance of this factory.
|
double |
getNormal(String catlabel)
getNormal
|
Lock |
getReadLock() |
String |
getRule(String catlabel)
Return the rule for the specified category.
|
String[] |
getServices(String catlabel)
Return the services list for the specified category.
|
double |
getWarning(String catlabel)
getWarning
|
Lock |
getWriteLock() |
static void |
init()
Load the config from the default config file and create the singleton
instance of this factory.
|
static void |
reload()
Reload the config from the default config file
|
boolean |
replaceCategory(String groupname,
Category cat)
Replace category in a categorygroup.
|
boolean |
replaceCategoryGroup(CategoryGroup group)
Replace categorygroup.
|
static void |
setInstance(CatFactory singleton)
setInstance
|
public CategoryFactory(org.springframework.core.io.Resource resource) throws IOException
Constructor for CategoryFactory.
resource
- a Resource
object.IOException
- if any.public Lock getReadLock()
getReadLock
in interface CatFactory
public Lock getWriteLock()
getWriteLock
in interface CatFactory
public static void init() throws IOException
IOException
- Thrown if the specified config file cannot be readIOException
- if any.public static void reload() throws IOException
IOException
- Thrown if the specified config file cannot be read/loadedIOException
- if any.public static CatFactory getInstance()
IllegalStateException
- Thrown if the factory has not yet been initialized.public static void setInstance(CatFactory singleton)
setInstance
singleton
- a CatFactory
object.public Catinfo getConfig()
getConfig
in interface CatFactory
public void addCategoryGroup(CategoryGroup group)
group
- category group to be addedpublic boolean replaceCategoryGroup(CategoryGroup group)
group
- category group to be replacedpublic boolean deleteCategoryGroup(CategoryGroup group)
group
- category group to be removedpublic boolean deleteCategoryGroup(String groupname)
groupname
- category group to be removedpublic boolean addCategory(String groupname, Category cat)
groupname
- category group to which category is to be addedcat
- category to be addedpublic boolean replaceCategory(String groupname, Category cat)
groupname
- category group to which category is to be addedcat
- category to be replacedpublic boolean deleteCategory(String groupname, Category cat)
groupname
- category group from which category is to be removedcat
- category to be deletedpublic boolean deleteCategory(String groupname, String catlabel)
groupname
- category group from which category is to be removedcatlabel
- label of the category to be deletedpublic Category getCategory(String name)
getCategory
Return the category specified by name.getCategory
in interface CatFactory
name
- a String
object.Category
object.public double getNormal(String catlabel)
getNormal
Return the normal value for the specified category.getNormal
in interface CatFactory
catlabel
- a String
object.public double getWarning(String catlabel)
getWarning
Return the warning value for the specified category.getWarning
in interface CatFactory
catlabel
- a String
object.public String[] getServices(String catlabel)
catlabel
- the label for the category whose services list is neededpublic String getRule(String catlabel)
catlabel
- the label for the category whose services list is neededpublic String getEffectiveRule(String catlabel)
getEffectiveRule
Return the effective rule for the specified category. The category rule ANDed with the rule of the category group that the category belongs to.getEffectiveRule
in interface CatFactory
catlabel
- a String
object.String
object.Copyright © 2020. All rights reserved.