|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectru.biosoft.access.DataElementSupport
ru.biosoft.access.AbstractDataCollection
This abstract class provides default implementations for most of
the methods in the DataCollection interface. It takes care of
the management of listeners and provides some conveniences for generating
DataCollectionEvents and dispatching them to the listeners.
To create a concrete DataCollection as a sublcass of
AbstractDataCollection you need only provide implementations for the
following methods:
DataCollection.iterator()
if concrete DataColection mutable, then next methods should be implemented
#doPut(DataElement)
#doRemove(DataElement)
| Field Summary | |
protected org.apache.log4j.Category |
cat
Log category |
protected DataCollectionInfo |
info
Data collection info for this data collection. |
protected boolean |
notificationEnabled
|
protected java.lang.String |
path
|
protected boolean |
propagationEnabled
|
protected java.util.HashMap |
v_cache
Cache for already accessed data elements. |
| Constructor Summary | |
|
AbstractDataCollection(DataCollection parent,
java.util.Properties properties)
Constructor to be used by CollectionFactory to creata DataCollection.
|
protected |
AbstractDataCollection(java.lang.String name,
DataCollection parent,
java.util.Properties properties)
Constructs data collection with specified name and parent. |
| Method Summary | |
void |
addDataCollectionListener(DataCollectionListener listener)
Adds listener to this data collection. |
protected void |
cachePut(DataElement de)
Puts to cache data element. |
protected void |
checkMutable()
Check whether the data collection is mutable. |
void |
close()
Close the data collection and release all used resources. |
boolean |
contains(DataElement element)
Check if this data collection contains the specified data element. |
boolean |
contains(java.lang.String name)
Returns true if this data collection contains the element with specified name. |
protected void |
doAddPostNotify(java.lang.String dataElementName,
boolean bNew)
Sends notification to the listeners after operation.
|
protected void |
doAddPreNotify(java.lang.String dataElementName,
boolean bNew)
Sends notification to the listeners before operation.
|
protected DataElement |
doGet(java.lang.String name)
This method should be implemented in subclasses to get the specified data element from the collection. |
protected void |
doPut(DataElement dataElement,
boolean isNew)
This method should be implemented in mutable subclasses to put the specified data element into the collection. |
protected void |
doRemove(java.lang.String name)
This method should be implemented in mutable subclasses to remove the specified data element from the collection. |
protected void |
doRemovePostNotify(java.lang.String name)
|
protected void |
doRemovePreNotify(java.lang.String name)
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
protected void |
fireElementAdded(java.lang.Object source,
java.lang.String dataElementName)
AbstractDataCollection subclasses must call this method after a data element is added to the collection. |
protected void |
fireElementChanged(java.lang.Object source,
DataCollection owner,
java.lang.String dataElementName,
DataCollectionEvent primaryEvent)
AbstractDataCollection subclasses must call this method after a data element of the collection change. |
protected void |
fireElementRemoved(java.lang.Object source,
java.lang.String dataElementName)
AbstractDataCollection subclasses must call this method after a data element is removed from the collection. |
protected void |
fireElementWillAdd(java.lang.Object source,
java.lang.String dataElementName)
Call DataCollectionListener.elementWillAdd(DataCollectionEvent) for all listeners. |
protected void |
fireElementWillChange(java.lang.Object source,
DataCollection owner,
java.lang.String dataElementName,
DataCollectionEvent primaryEvent)
Call DataCollectionListener.elementWillChange(DataCollectionEvent) for all listeners. |
protected void |
fireElementWillRemove(java.lang.Object source,
java.lang.String dataElementName)
Call DataCollectionListener.elementWillRemove(DataCollectionEvent) for all listeners. |
DataElement |
get(java.lang.String name)
Gets data element with specified name. |
java.lang.String |
getCompleteName()
Gets complete name of data collection. |
java.lang.Class |
getDataElementType()
Gets the type of DataElements stored in the data collection. |
java.lang.String |
getDescription()
Utility method that returns data collection description. |
DataCollectionInfo |
getInfo()
Gets data collection info. |
java.util.List |
getNameList()
Gets list of all names in data collection. |
int |
getSize()
Gets size of data collection. |
protected void |
initLog()
Initialize logging. |
boolean |
isMutable()
Returns false. |
boolean |
isNotificationEnabled()
|
boolean |
isPropagationEnabled()
|
protected void |
makeInfo(java.util.Properties properties)
Makes data collection info. |
void |
propagateElementChanged(DataCollection source,
DataCollectionEvent primaryEvent)
|
void |
propagateElementWillChange(DataCollection source,
DataCollectionEvent primaryEvent)
|
DataElement |
put(DataElement element)
Adds the specified data element to the collection. |
protected void |
registerRoot()
Register this DataCollection as root in CollectionFactory.registerRoot(ru.biosoft.access.DataCollection)
if IS_ROOT property is true; |
void |
release(java.lang.String name)
Release the DataElement specified by its name from the cache. |
void |
remove(java.lang.String name)
Removes the specified data element from the collection, if present. |
void |
removeDataCollectionListener(DataCollectionListener listener)
Removes listener from this data collection. |
void |
setNotificationEnabled(boolean isEnabled)
|
void |
setPropagationEnabled(boolean propagationEnabled)
|
java.lang.String |
toString()
Returns a String representation of the data collection. |
| Methods inherited from class ru.biosoft.access.DataElementSupport |
getName, getOrigin, registerConstructorWithBadEqual |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ru.biosoft.access.DataCollection |
iterator |
| Methods inherited from interface ru.biosoft.access.DataElement |
getName, getOrigin |
| Field Detail |
protected java.util.HashMap v_cache
protected org.apache.log4j.Category cat
protected java.lang.String path
protected DataCollectionInfo info
protected boolean notificationEnabled
protected boolean propagationEnabled
| Constructor Detail |
public AbstractDataCollection(DataCollection parent,
java.util.Properties properties)
CollectionFactory to creata DataCollection.
Makes info for this data collection.
DataCollection.NAME_PROPERTYru.biosoft.access.DataCollection#PATH_PROPERTYDataCollection.NODE_IMAGEDataCollection.CHILDREN_NODE_IMAGEDataCollection.NODE_VISIBLEDataCollection.CHILDREN_NODE_VISIBLE
parent - Parent data collection.properties - Properties for creating data collection (may be changed).
protected AbstractDataCollection(java.lang.String name,
DataCollection parent,
java.util.Properties properties)
collectionFactory.
parent - Parent for this data collection.properties - Properties to initialise DataCollectionInfo. Can be null.| Method Detail |
protected void registerRoot()
CollectionFactory.registerRoot(ru.biosoft.access.DataCollection)
if IS_ROOT property is true;
public boolean isMutable()
isMutable in interface DataCollectionpublic java.lang.Class getDataElementType()
getDataElementType in interface DataCollectionpublic DataCollectionInfo getInfo()
getInfo in interface DataCollectionDataCollectionInfopublic int getSize()
getSize in interface DataCollectionpublic java.lang.String getDescription()
public boolean contains(DataElement element)
contains in interface DataCollectionelement - tested data element.
contains(String)public boolean contains(java.lang.String name)
contains in interface DataCollectionname - name of element whose presence in this data collection is to be tested.
contains(ru.biosoft.access.DataElement)
public DataElement get(java.lang.String name)
throws java.lang.Exception
doGet(String).
get in interface DataCollectionname - Name of the data element (cannot be null).
java.lang.Exception - If error raised in doGet(String)doGet(String),
v_cacheprotected void cachePut(DataElement de)
put(DataElement)DataCollection
or MutableDataElements. Why???
public DataElement put(DataElement element)
throws java.lang.Exception
#doPut(DataElement) method is used to put the data element.
If the data collection previously contained the specified element,
the old value is replaced.
put in interface DataCollectionelement - Data element that will be putted in the data collection (Cannt be null).
java.util.UnsupportedOperationException - if the data collection is unmutable.
java.lang.Exception - If error occured.#doPut(DataElement),
isMutable()
protected void doAddPreNotify(java.lang.String dataElementName,
boolean bNew)
throws java.lang.Exception,
DataCollectionVetoException
#doPut(DataElement) operation.
If data collection contains the data element with specified name, DataCollectionListener.elementWillChange(DataCollectionEvent )
of listeners is called, or DataCollectionListener.elementWillAdd(DataCollectionEvent ) otherwise
dataElementName - name of added/changed DataElement.bNew - is it new?
java.lang.Exception - If any error
DataCollectionVetoException - If listener does not want to continue change/put action.
protected void doAddPostNotify(java.lang.String dataElementName,
boolean bNew)
throws java.lang.Exception
#doPut(DataElement) operation.
If data collection contains the data element with specified name, DataCollectionListener.elementChanged(DataCollectionEvent )
of listeners is called, or DataCollectionListener.elementAdded(DataCollectionEvent ) otherwise
dataElementName - name of added/changed DataElement.bNew - is it new?
java.lang.Exception - If any error
public void remove(java.lang.String name)
throws java.lang.Exception,
java.lang.UnsupportedOperationException
#doRemove(ru.biosoft.access.DataElement) method is used to remove the data element.
remove in interface DataCollectionname -
java.lang.UnsupportedOperationException - If the data collection is unmutable.
java.lang.Exception - If any error.#doRemove(ru.biosoft.access.DataElement),
isMutable()
protected void doRemovePreNotify(java.lang.String name)
throws java.lang.Exception,
DataCollectionVetoException
java.lang.Exception
DataCollectionVetoException
protected void doRemovePostNotify(java.lang.String name)
throws java.lang.Exception,
DataCollectionVetoException
java.lang.Exception
DataCollectionVetoExceptionpublic void addDataCollectionListener(DataCollectionListener listener)
addDataCollectionListener in interface DataCollectionlistener - Listener of this data collection.public void removeDataCollectionListener(DataCollectionListener listener)
removeDataCollectionListener in interface DataCollectionlistener - Listener of this data collection.public java.util.List getNameList()
getNameList in interface DataCollectionpublic java.lang.String getCompleteName()
getCompleteName in interface DataCollectionpublic java.lang.String toString()
toString in class DataElementSupportprotected void initLog()
Categoryprotected void makeInfo(java.util.Properties properties)
properties - Properties with which collection created.public boolean isNotificationEnabled()
isNotificationEnabled in interface DataCollectionpublic void setNotificationEnabled(boolean isEnabled)
setNotificationEnabled in interface DataCollection
protected void fireElementAdded(java.lang.Object source,
java.lang.String dataElementName)
throws java.lang.Exception
source - the DataCollection that changed, typically "this".
java.lang.ExceptionDataCollectionEvent
protected void fireElementWillChange(java.lang.Object source,
DataCollection owner,
java.lang.String dataElementName,
DataCollectionEvent primaryEvent)
throws DataCollectionVetoException,
java.lang.Exception
DataCollectionListener.elementWillChange(DataCollectionEvent) for all listeners.
source - source of eventowner - data collection whose element was changed.dataElementName - changed data element name.
DataCollectionVetoException - If listener cancel change of data element.
java.lang.Exception - If error occurs.
protected void fireElementWillAdd(java.lang.Object source,
java.lang.String dataElementName)
throws DataCollectionVetoException,
java.lang.Exception
DataCollectionListener.elementWillAdd(DataCollectionEvent) for all listeners.
source - Source of eventdataElementName - Data element which will be added.
DataCollectionVetoException - If listener cancel adding of data element.
java.lang.Exception - If error occurs.
protected void fireElementWillRemove(java.lang.Object source,
java.lang.String dataElementName)
throws DataCollectionVetoException,
java.lang.Exception
DataCollectionListener.elementWillRemove(DataCollectionEvent) for all listeners.
source - Source of event
DataCollectionVetoException - If listener cancel removing of data element.
java.lang.Exception - If error occurs.
protected void fireElementChanged(java.lang.Object source,
DataCollection owner,
java.lang.String dataElementName,
DataCollectionEvent primaryEvent)
throws java.lang.Exception
source - the DataCollection that changed, typically "this".
java.lang.ExceptionDataCollectionEvent
protected void fireElementRemoved(java.lang.Object source,
java.lang.String dataElementName)
throws java.lang.Exception
source - the DataCollection that changed, typically "this".
java.lang.ExceptionDataCollectionEventpublic boolean isPropagationEnabled()
isPropagationEnabled in interface DataCollectionpublic void setPropagationEnabled(boolean propagationEnabled)
setPropagationEnabled in interface DataCollection
public void propagateElementWillChange(DataCollection source,
DataCollectionEvent primaryEvent)
propagateElementWillChange in interface DataCollection
public void propagateElementChanged(DataCollection source,
DataCollectionEvent primaryEvent)
propagateElementChanged in interface DataCollectionprotected void checkMutable()
java.lang.UnsupportedOperationException - if collection is immmutable.
protected DataElement doGet(java.lang.String name)
throws java.lang.Exception
name - Name of needed data element.
java.util.UnsupportedOperationException - If Iterator.next() throw this exception.
java.lang.Exceptionget(String),
DataCollection.iterator()
protected void doPut(DataElement dataElement,
boolean isNew)
throws java.lang.Exception
java.lang.UnsupportedOperationException - Always throws.
java.lang.Exceptionput(DataElement)
protected void doRemove(java.lang.String name)
throws java.lang.Exception
java.lang.UnsupportedOperationException - Always .
java.lang.Exceptionremove(String)
public void close()
throws java.lang.Exception
DataCollectionInfo that provides closing of QuerySystem
close in interface DataCollectionjava.lang.Exception - If error occured.public void release(java.lang.String name)
release in interface DataCollection
protected void finalize()
throws java.lang.Throwable
close() method
java.lang.Throwable - the Exception raised by this method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||