HEADER

ru.biosoft.access
Class AbstractDataCollection

ru.biosoft.access.DataElementSupport
  |
  +--ru.biosoft.access.AbstractDataCollection
Direct Known Subclasses:
MglDataCollection, DummyRelationDataCollection, DataCollectionUnion, DerivedDataCollection, EntryCollection, SQLDataCollection, VectorDataCollection

public abstract class AbstractDataCollection
extends DataElementSupport
implements DataCollection

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(ru.biosoft.access.DataElement)
doRemove(ru.biosoft.access.DataElement)

Version: 1.0

Constructor Summary
AbstractDataCollection(DataCollection parent, Properties properties)
          Constructs data collection with parent.

Method Summary
 voidaddDataCollectionListener(DataCollectionListener listener)
          Adds listener to this data collection.
 voidclose()
          Do nothing.
 booleancontains(DataElement element)
          Check if this data collection contains the specified data element.
 booleancontains(String name)
          Returns true if this data collection contains the element with specified name.
 DataElementget(String name)
          Gets data element with specified name.
 StringgetCompleteName()
          Gets complete name of data collection.
 ClassgetDataElementType()
          Gets the type of DataElements stored in the data collection.
 DataCollectionInfogetInfo()
          Gets data collection info.
 ListgetNameList()
          Gets list of all names in data collection.
 intgetSize()
          Gets size of data collection.
 voidinit()
          Do nothing.
 booleanisMutable()
          Returns false.
 voidpropagateElementChanged(DataCollection source, DataCollectionEvent primaryEvent)
           
 voidpropagateElementWillChange(DataCollection source, DataCollectionEvent primaryEvent)
           
 DataElementput(DataElement element)
          Adds the specified data element to the collection.
 DataElementremove(String name)
          Removes the specified data element from the collection, if present.
 voidremoveDataCollectionListener(DataCollectionListener listener)
          Removes listener from this data collection.
 StringtoString()
          Returns a String representation of the data collection.

Methods inherited from class ru.biosoft.access.DataElementSupport
getName, getOrigin, registerConstructorWithBadEqual

Constructor Detail

AbstractDataCollection

public AbstractDataCollection(DataCollection parent, Properties properties)
Constructs data collection with parent. Makes info for this data collection.
Parameters:
parent - Parent data collection.
properties - Properties for creating data collection (may be changed).
todo low makeInfo(Properties) should be moved to collection that only appears in repository.
Method Detail

addDataCollectionListener

public void addDataCollectionListener(DataCollectionListener listener)
Adds listener to this data collection.
Parameters:
listener - Listener of this data collection.

close

public void close()
throws java.lang.Exception
Do nothing.

contains

public boolean contains(DataElement element)
Check if this data collection contains the specified data element.
Parameters:
element - tested data element.
Returns: true if this data collection contains the data element which name equals to specified data element, otherwise return false.
See Also:
contains(java.lang.String)
todo Check type of data element.

contains

public boolean contains(String name)
Returns true if this data collection contains the element with specified name.
Parameters:
name - name of element whose presence in this data collection is to be tested.
Returns: true if this data collection contains the element with specified name.
See Also:
contains(ru.biosoft.access.DataElement)

get

public DataElement get(String name)
throws java.lang.Exception
Gets data element with specified name. This implementation supports cache and for actual access use doGet(java.lang.String).
Parameters:
name - Name of the data element (cannot be null).
Returns: DataElement or null if data element not found in the data collection.
Throws:
java.lang.Exception - If error raised in doGet(java.lang.String)
See Also:
doGet(java.lang.String), v_cache
todo Check type of data element.

getCompleteName

public String getCompleteName()
Gets complete name of data collection.
Returns: full name of DataCollection in the tree hierarchy.

getDataElementType

public Class getDataElementType()
Gets the type of DataElements stored in the data collection. Should be overrided in derived collection.
Returns: Type of DataElements stored in the data collection.

getInfo

public DataCollectionInfo getInfo()
Gets data collection info.
Returns: Data collection info.
See Also:
DataCollectionInfo

getNameList

public List getNameList()
Gets list of all names in data collection.
Returns: Names of all elements in the data collection.

getSize

public int getSize()
Gets size of data collection. This method must be overrided for perfomance improving.
Returns: Number of data element in this data collection.

init

public void init()
Do nothing.

isMutable

public boolean isMutable()
Returns false. Override this method for return correct value.
Returns: Always return false.

propagateElementChanged

public void propagateElementChanged(DataCollection source, DataCollectionEvent primaryEvent)
todo comment

propagateElementWillChange

public void propagateElementWillChange(DataCollection source, DataCollectionEvent primaryEvent)
todo comment

put

public DataElement put(DataElement element)
throws java.lang.Exception
Adds the specified data element to the collection. Notifies all listeners if the data element was added or changed. doPut(ru.biosoft.access.DataElement) method is used to put the data element. If the data collection previously contained the specified element, the old value is replaced.
Note that this implementation slow enough!!!
Parameters:
element - Data element that will be putted in the data collection (Cannt be null).
Returns: previous version of the data element, or null if there was no one.
Throws:
java.util.UnsupportedOperationException - if the data collection is unmutable.
java.lang.Exception - If error occured.
See Also:
doPut(ru.biosoft.access.DataElement), isMutable()
todo should check DataElement type

remove

public DataElement remove(String name)
throws java.lang.Exception,
java.lang.UnsupportedOperationException
Removes the specified data element from the collection, if present. Notifies all listeners if the data element was removed. doRemove(ru.biosoft.access.DataElement) method is used to remove the data element.
Parameters:
name
Returns: the removed data element.
Throws:
UnsupportedOperationException - If the data collection is unmutable.
Exception - If any error.
See Also:
doRemove(ru.biosoft.access.DataElement), isMutable()

removeDataCollectionListener

public void removeDataCollectionListener(DataCollectionListener listener)
Removes listener from this data collection.
Parameters:
listener - Listener of this data collection.

toString

public String toString()
Returns a String representation of the data collection.
Returns: String representation of the data collection.

Association Links

to Class ru.biosoft.util.HashMapSoftValues

Cache for already accessed data elements.

to Class org.apache.log4j.Category

Log category

to Class java.lang.String

todo Document

to Class ru.biosoft.access.DataCollectionInfo

Data collection info for this data collection.

to Class javax.swing.event.EventListenerList

List of listeners.

FOOTER

BOTTOM