|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.miginfocom.calendar.category.CategoryDepository
public class CategoryDepository
A class that keeps track of all categories in the application. Used for fast getting categories, and if objects has been
overridden. Adding categories is done on the Category object itself.
This class is not thread safe.
| Constructor Summary | |
|---|---|
CategoryDepository()
|
|
| Method Summary | |
|---|---|
static void |
addBrokedCategories(java.util.Collection c,
java.lang.Object source,
int eventType)
Adds a number of activities to the list. |
static void |
addBrokedCategory(Category c,
java.lang.Object source,
int eventType)
Adds an category to the list. |
static void |
addCategoryStructureListener(CategoryStructureListener l)
Adds a listener to changes in the category tree structure. |
static void |
addCategoryStructureListener(CategoryStructureListener l,
boolean asWeakRef)
Adds a listener to changes in the category tree structure. |
static void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a listener that listens to all handeled categories of type Category and subclasses. |
static void |
addPropertyChangeListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
Adds a listener that listens to all handeled categories of type Category and subclasses. |
static void |
attachParent(java.lang.Object catId,
java.lang.Object parentID,
java.lang.Object source)
Adds a parent to a category. |
static boolean |
containsCategories(java.lang.Object[] ids)
Return the if all nodes with exists in the node map |
static boolean |
containsCategory(java.lang.Object id)
Return the if an node with the id exists in the node map |
static java.util.List |
getBrokedCategories()
Returns a new list with all Category objects that are currently beeing broked (i.e. |
static int |
getBrokedCategoryCount()
Returns the number of broked categories in the depository. |
static Category |
getCategory(java.lang.Object id)
Return the node. |
static CategoryResolver |
getCategoryResolver()
Returns the current resolver. |
static CategoryResolver |
getCurrentCategoryResolver()
Returns the current resolver. |
static java.lang.Class |
getEnforceIDClass()
Returns the id class type that always should be used as id for the categories. |
static java.lang.Object |
getFirstOverriddenObject(java.lang.Object[] catIDs,
java.lang.String targetName,
PropertyKey property,
java.lang.Object def)
Calls getOverriddenObject(Object, String, PropertyKey, Object) for every category in catIDs. |
static java.util.logging.Logger |
getLogger()
Returns the current logger or null if none is set. |
static java.lang.Object |
getOverriddenObject(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property,
java.lang.Object def)
Returns another object if there is an override registered for propName property for category catID. |
static Category |
getRoot()
Returns the single root node. |
static void |
removeBrokedCategories(java.util.Collection c,
java.lang.Object source,
int eventType)
Remove Categorys from the depository anre unregisters them from all their parents. |
static boolean |
removeBrokedCategory(Category c,
java.lang.Object source,
int eventType)
Remove an category from the list. |
static Category |
removeBrokedCategoryById(java.lang.Object catID,
java.lang.Object source,
int eventType)
Remove a category from the list. |
static Category |
removeBrokedCategoryByIdDeep(java.lang.Object id,
java.lang.Object source,
int eventType)
Remove a category from the list including all child categories. |
static void |
removeCategoriesBelow(java.lang.Object id)
Deprecated. use removeBrokedCategoryByIdDeep(Object, Object, int). |
static Category |
removeCategory(java.lang.Object id)
Deprecated. Use removeBrokedCategoryById(Object, Object, int) instead. Name has changed to be more similar to ActivityDepository. |
static void |
removeCategoryStructureListener(CategoryStructureListener l)
Adds a listener to changes in the category tree structure. |
static void |
removeOverride(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property)
Removes an override for a property in a category. |
static void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes the listener. |
static void |
setCategoryResolver(CategoryResolver resolver)
Sets the resolver. |
static void |
setEnforceIDClass(java.lang.Class enforceIDClass)
Sets the id class type that always should be used as id for the categories. |
static void |
setLogger(java.util.logging.Logger l)
Set the current logger. |
static void |
setOverride(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property,
java.lang.Object o)
Sets an override for a property in a category. |
static int |
size()
Returns the total number of categories in the depository. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CategoryDepository()
| Method Detail |
|---|
public static int size()
public static java.lang.Class getEnforceIDClass()
null if no check.public static void setEnforceIDClass(java.lang.Class enforceIDClass)
enforceIDClass - The class type. null will turn of the ID class type check.public static java.util.logging.Logger getLogger()
null if none is set.
null if none is set.public static void setLogger(java.util.logging.Logger l)
null to diable logging (default)
l - The new logger or null to disable logging (default)public static Category getRoot()
null. id for root is always null.public static Category getCategory(java.lang.Object id)
HashMap so the lookup should be really fast.
id - The id to look for. null returns the root node.
null if not found.public static boolean containsCategory(java.lang.Object id)
public static boolean containsCategories(java.lang.Object[] ids)
public static void addBrokedCategories(java.util.Collection c,
java.lang.Object source,
int eventType)
addBrokedCategory(Category, Object, int) for every category since they
have to be checked so that there are no category with the same ID. If there is the resolver have to deal with that
problem.
c - The collection of Category objects to add to the depository and parents.source - The source object that is adding the category.eventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.ADDED_CREATED
public static void addBrokedCategory(Category c,
java.lang.Object source,
int eventType)
The parentIDs (Category.PROP_PARENT_IDS must already be set and the categories they denote
must be in the depository already or a IllegalStateException will be thrown.
Note that if an category with the same ID already exist the registered category resolver will be invoked. The old one can be removed and the new added or nothing will happen depending on the resolver.
c - The category to add to the depository and parents.source - The source object that is adding the category.eventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.ADDED_CREATED
public static void attachParent(java.lang.Object catId,
java.lang.Object parentID,
java.lang.Object source)
catId have another parent. If this parent already
exist it will not be added.
Note that both catId and parentID must exist in the Depository before a call to this method.
catId - The if of the category to set a new parent for. Not null.parentID - The parent to add. May be null which means the root will be added as parent.source - The source. Will be used as source in the event that is fired.public static Category removeCategory(java.lang.Object id)
removeBrokedCategoryById(Object, Object, int) instead. Name has changed to be more similar to ActivityDepository.
id - The id to remove. Not null.
null if not found.
public static boolean removeBrokedCategory(Category c,
java.lang.Object source,
int eventType)
source - The source that is removing the categoryc - The category to remove. Not null and not the root node.eventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.REMOVED_DELETED
true if foind in the depositior and removed. false otherwise.
public static Category removeBrokedCategoryById(java.lang.Object catID,
java.lang.Object source,
int eventType)
id from their child list.
catID - The category to remove.source - The source that is removing the categoryeventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.REMOVED_DELETED
null if not found.public static void removeCategoriesBelow(java.lang.Object id)
removeBrokedCategoryByIdDeep(Object, Object, int).
public static Category removeBrokedCategoryByIdDeep(java.lang.Object id,
java.lang.Object source,
int eventType)
id from their child list.
The removes will start from the leaves.
id - The category to remove.source - The source that is removing the categoryeventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.REMOVED_DELETED
null if not found.
public static void removeBrokedCategories(java.util.Collection c,
java.lang.Object source,
int eventType)
Categorys from the depository anre unregisters them from all their parents.
source - The source that is removing the categoryc - The Category objects to remove.eventType - The type of add/remove. Indicated for data providers and synchronizers. E.g. CategoryStructureEvent.REMOVED_DELETEDpublic static java.util.List getBrokedCategories()
Category objects that are currently beeing broked (i.e. handled) by this depository.
Changes in the depository will not be reflected in the list after its creation.
null but can be empty.Arrays.asList(T...)public static int getBrokedCategoryCount()
public static CategoryResolver getCategoryResolver()
null this object
(which is a CategoryResolver) will just choose the newest one (modification date wise).
null.public static void setCategoryResolver(CategoryResolver resolver)
null this object (which is a CategoryResolver) will just choose the newest one
(modification date wise).
resolver - The new resolver. Can be null.public static CategoryResolver getCurrentCategoryResolver()
null as getCategoryResolver() might. This methods returns
this if not other resolver is returned.
null.public static void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Category and subclasses. Note that classes
that only implement Category have to call Category.fireStaticPropertyChangeEvent(java.beans.PropertyChangeEvent)
to fire the static notification.
See PROP_xxx in the Category class.
l - The listener
public static void addPropertyChangeListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
Category and subclasses. Note that classes
that only implement Category have to call Category.fireStaticPropertyChangeEvent(java.beans.PropertyChangeEvent)
to fire the static notification.
See PROP_xxx in the Category class.
l - The listenerasWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since
the garbage collector can collect the listener if it is only referenced from this list.public static void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l - The listener to remove.public static void addCategoryStructureListener(CategoryStructureListener l)
l - The listener to remove.
public static void addCategoryStructureListener(CategoryStructureListener l,
boolean asWeakRef)
l - The listener to remove.asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since
the garbage collector can collect the listener if it is only referenced from this list.public static void removeCategoryStructureListener(CategoryStructureListener l)
l - The listener to remove.
public static final java.lang.Object getFirstOverriddenObject(java.lang.Object[] catIDs,
java.lang.String targetName,
PropertyKey property,
java.lang.Object def)
getOverriddenObject(Object, String, PropertyKey, Object) for every category in catIDs.
public static final java.lang.Object getOverriddenObject(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property,
java.lang.Object def)
propName property for category catID.
catID - The is for tha category. IF null the def will always be returned since the root id can not be set override on.targetName - Then name of the target. Not null.property - The property key to return the object for. E.g. AShape.A_PAINT. Not null.def - The object to return if no override is active/on
def if there in no override. Can be null since this might be the new value.
public static final void setOverride(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property,
java.lang.Object o)
catID - The is for tha category. Not null.targetName - Then name of the target. Not null.property - The property key to return the object for. E.g. AShape.A_PAINT. Not null.o - The new object that will be returned by getOverriddenObject(Object, String, PropertyKey, Object). May be null.
public static final void removeOverride(java.lang.Object catID,
java.lang.String targetName,
PropertyKey property)
catID - The is for tha category. Not null.targetName - Then name of the target. Not null.property - The property key. E.g. AShape.A_PAINT. Not null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||