Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ru.biosoft.access
Class AbstractDataCollection

    java.lang.Object
      ru.biosoft.access.DataElementSupport
          ru.biosoft.access.AbstractDataCollection

All Implemented Interfaces:
  DataCollection, DataElement

Direct Known Subclasses:
  DataCollectionUnion, DerivedDataCollection, EntryCollection, SqlDataCollection, VectorDataCollection, VisiblePlugin

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(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.

Fields inherited from interface ru.biosoft.access.DataCollection
`CHILDREN_NODE_IMAGE, CHILDREN_NODE_VISIBLE, CLASS_PROPERTY, CLASSPATH_JAR_PROPERTY, COMPARATOR_OBJECT, CONFIG_FILE_PROPERTY, CONFIG_PATH_PROPERTY, DATA_ELEMENT_CLASS_PROPERTY, DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_SUFFIX, DEFAULT_FILTER_CONFIG_SUFFIX, DEFAULT_FORMAT_CONFIG_SUFFIX, DEFAULT_NODE_CONFIG_SUFFIX, DEFAULT_REPOSITORY, DESCRIPTION_PROPERTY, DISPLAY_NAME_PROPERTY, FILE_PATH_PROPERTY, FILE_PROPERTY, FILTER_PROPERTY, ID_FORMAT, IS_ROOT, JOB_CONTROL_PROPERTY, LATE_CHILDREN_INITIALIZATION, MUTABLE, NAME_PROPERTY, NEXT_CONFIG, NODE_IMAGE, NODE_VISIBLE, PRIMARY_COLLECTION, REMOVE_CHILDREN, TRANSFORMER_CLASS`

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 ``#doPut(DataElement)`` operation.
`protected void` | `doAddPreNotify(java.lang.String dataElementName, boolean bNew)` Sends notification to the listeners before ``#doPut(DataElement)`` 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

### v_cache

    protected java.util.HashMap v_cache

  Cache for already accessed data elements.

### cat

    protected org.apache.log4j.Category cat

  Log category

### path

    protected java.lang.String path

To do:
  Document

### info

    protected DataCollectionInfo info

  Data collection info for this data collection.

### notificationEnabled

    protected boolean notificationEnabled

### propagationEnabled

    protected boolean propagationEnabled

Constructor Detail

### AbstractDataCollection

    public AbstractDataCollection(DataCollection parent,
                                  java.util.Properties properties)

  Constructor to be used by `CollectionFactory` to creata DataCollection. Makes info for this data collection.
  Required properties
  - `DataCollection.NAME_PROPERTY`
  Optional properties
  - `ru.biosoft.access.DataCollection#PATH_PROPERTY`
  - `DataCollection.NODE_IMAGE`
  - `DataCollection.CHILDREN_NODE_IMAGE`
  - `DataCollection.NODE_VISIBLE`
  - `DataCollection.CHILDREN_NODE_VISIBLE`

Parameters:
  `parent` - Parent data collection.
  `properties` - Properties for creating data collection (may be changed).
To do:
  low makeInfo(Properties) should be moved to collection that only appears in repository.

### AbstractDataCollection

    protected AbstractDataCollection(java.lang.String name,
                                     DataCollection parent,
                                     java.util.Properties properties)

  Constructs data collection with specified name and parent. This constructor can be used by subclasses if DataCollection is created without using `collectionFactory`.

Parameters:
  `parent` - Parent for this data collection.
  `properties` - Properties to initialise `DataCollectionInfo`. Can be null.

Method Detail

### registerRoot

    protected void registerRoot()

  Register this DataCollection as root in `CollectionFactory.registerRoot(ru.biosoft.access.DataCollection)` if `IS_ROOT` property is true;

### isMutable

    public boolean isMutable()

  Returns false. Override this method for return correct value.

  Specified by:
    `isMutable` in interface `DataCollection`
  Returns:
    Always return false.

### getDataElementType

    public java.lang.Class getDataElementType()

  Gets the type of DataElements stored in the data collection. The DataElement type should be specified using {&link DATA_ELEMENT_CLASS_PROPERTY} or should be specified in derived collections.

  Specified by:
    `getDataElementType` in interface `DataCollection`
  Returns:
    Type of DataElements stored in the data collection.

### getInfo

    public DataCollectionInfo getInfo()

  Gets data collection info.

  Specified by:
    `getInfo` in interface `DataCollection`
  Returns:
    Data collection info.
  See Also:
    `DataCollectionInfo`

### getSize

    public int getSize()

  Gets size of data collection. This method must be overrided for perfomance improving.

  Specified by:
    `getSize` in interface `DataCollection`
  Returns:
    Number of data element in this data collection.

### getDescription

    public java.lang.String getDescription()

  Utility method that returns data collection description.

### contains

    public boolean contains(DataElement element)

  Check if this data collection contains the specified data element.

  Specified by:
    `contains` in interface `DataCollection`
  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(String)`
  To do:
    Check type of data element.

### contains

    public boolean contains(java.lang.String name)

  Returns `true` if this data collection contains the element with specified name.

  Specified by:
    `contains` in interface `DataCollection`
  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(java.lang.String name)
                    throws java.lang.Exception

  Gets data element with specified name. This implementation supports cache and for actual access use `doGet(String)`.

  Specified by:
    `get` in interface `DataCollection`
  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(String)`
  See Also:
    `doGet(String)`, `v_cache`
  To do:
    Check type of data element.

### cachePut

    protected void cachePut(DataElement de)

  Puts to cache data element. Note. If data element is not equal to this DataCollection, then data element will not be putted to cache.

  See Also:
    `put(DataElement)`
  Pendung:
    previously we have skipped also instances of `DataCollection` or `MutableDataElement`s. Why???

### 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(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!!!

  Specified by:
    `put` in interface `DataCollection`
  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(DataElement)`, `isMutable()`
  To do:
    should check DataElement type

### doAddPreNotify

    protected void doAddPreNotify(java.lang.String dataElementName,
                                  boolean bNew)
                           throws java.lang.Exception,
                                  DataCollectionVetoException

  Sends notification to the listeners before ``#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

  Parameters:
    `dataElementName` - name of added/changed DataElement.
    `bNew` - is it new?
  Throws:
    `java.lang.Exception` - If any error
    `DataCollectionVetoException` - If listener does not want to continue change/put action.

### doAddPostNotify

    protected void doAddPostNotify(java.lang.String dataElementName,
                                   boolean bNew)
                            throws java.lang.Exception

  Sends notification to the listeners after ``#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

  Parameters:
    `dataElementName` - name of added/changed DataElement.
    `bNew` - is it new?
  Throws:
    `java.lang.Exception` - If any error

### remove

    public void remove(java.lang.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.

  Specified by:
    `remove` in interface `DataCollection`
  Parameters:
    `name` -
  Returns:
    the removed data element.
  Throws:
    `java.lang.UnsupportedOperationException` - If the data collection is unmutable.
    `java.lang.Exception` - If any error.
  See Also:
    `#doRemove(ru.biosoft.access.DataElement)`, `isMutable()`

### doRemovePreNotify

    protected void doRemovePreNotify(java.lang.String name)
                              throws java.lang.Exception,
                                     DataCollectionVetoException

  Throws:
    `java.lang.Exception`
    `DataCollectionVetoException`

### doRemovePostNotify

    protected void doRemovePostNotify(java.lang.String name)
                               throws java.lang.Exception,
                                      DataCollectionVetoException

  Throws:
    `java.lang.Exception`
    `DataCollectionVetoException`

### addDataCollectionListener

    public void addDataCollectionListener(DataCollectionListener listener)

  Adds listener to this data collection.

  Specified by:
    `addDataCollectionListener` in interface `DataCollection`
  Parameters:
    `listener` - Listener of this data collection.

### removeDataCollectionListener

    public void removeDataCollectionListener(DataCollectionListener listener)

  Removes listener from this data collection.

  Specified by:
    `removeDataCollectionListener` in interface `DataCollection`
  Parameters:
    `listener` - Listener of this data collection.

### getNameList

    public java.util.List getNameList()

  Gets list of all names in data collection.

  Specified by:
    `getNameList` in interface `DataCollection`
  Returns:
    Names of all elements in the data collection.

### getCompleteName

    public java.lang.String getCompleteName()

  Gets complete name of data collection.

  Specified by:
    `getCompleteName` in interface `DataCollection`
  Returns:
    full name of DataCollection in the tree hierarchy.

### toString

    public java.lang.String toString()

  Returns a String representation of the data collection.

  Overrides:
    `toString` in class `DataElementSupport`
  Returns:
    String representation of the data collection.

### initLog

    protected void initLog()

  Initialize logging.

  See Also:
    `Category`

### makeInfo

    protected void makeInfo(java.util.Properties properties)

  Makes data collection info.

  Parameters:
    `properties` - Properties with which collection created.

### isNotificationEnabled

    public boolean isNotificationEnabled()

  Specified by:
    `isNotificationEnabled` in interface `DataCollection`

### setNotificationEnabled

    public void setNotificationEnabled(boolean isEnabled)

  Specified by:
    `setNotificationEnabled` in interface `DataCollection`

### fireElementAdded

    protected void fireElementAdded(java.lang.Object source,
                                    java.lang.String dataElementName)
                             throws java.lang.Exception

  AbstractDataCollection subclasses must call this method after a data element is added to the collection.

  Parameters:
    `source` - the DataCollection that changed, typically "this".
  Throws:
    `java.lang.Exception`
  See Also:
    `DataCollectionEvent`

### fireElementWillChange

    protected void fireElementWillChange(java.lang.Object source,
                                         DataCollection owner,
                                         java.lang.String dataElementName,
                                         DataCollectionEvent primaryEvent)
                                  throws DataCollectionVetoException,
                                         java.lang.Exception

  Call `DataCollectionListener.elementWillChange(DataCollectionEvent)` for all listeners.

  Parameters:
    `source` - source of event
    `owner` - data collection whose element was changed.
    `dataElementName` - changed data element name.
  Throws:
    `DataCollectionVetoException` - If listener cancel change of data element.
    `java.lang.Exception` - If error occurs.

### fireElementWillAdd

    protected void fireElementWillAdd(java.lang.Object source,
                                      java.lang.String dataElementName)
                               throws DataCollectionVetoException,
                                      java.lang.Exception

  Call `DataCollectionListener.elementWillAdd(DataCollectionEvent)` for all listeners.

  Parameters:
    `source` - Source of event
    `dataElementName` - Data element which will be added.
  Throws:
    `DataCollectionVetoException` - If listener cancel adding of data element.
    `java.lang.Exception` - If error occurs.

### fireElementWillRemove

    protected void fireElementWillRemove(java.lang.Object source,
                                         java.lang.String dataElementName)
                                  throws DataCollectionVetoException,
                                         java.lang.Exception

  Call `DataCollectionListener.elementWillRemove(DataCollectionEvent)` for all listeners.

  Parameters:
    `source` - Source of event
  Throws:
    `DataCollectionVetoException` - If listener cancel removing of data element.
    `java.lang.Exception` - If error occurs.

### fireElementChanged

    protected void fireElementChanged(java.lang.Object source,
                                      DataCollection owner,
                                      java.lang.String dataElementName,
                                      DataCollectionEvent primaryEvent)
                               throws java.lang.Exception

  AbstractDataCollection subclasses must call this method after a data element of the collection change.

  Parameters:
    `source` - the DataCollection that changed, typically "this".
  Throws:
    `java.lang.Exception`
  See Also:
    `DataCollectionEvent`

### fireElementRemoved

    protected void fireElementRemoved(java.lang.Object source,
                                      java.lang.String dataElementName)
                               throws java.lang.Exception

  AbstractDataCollection subclasses must call this method after a data element is removed from the collection.

  Parameters:
    `source` - the DataCollection that changed, typically "this".
  Throws:
    `java.lang.Exception`
  See Also:
    `DataCollectionEvent`

### isPropagationEnabled

    public boolean isPropagationEnabled()

  Specified by:
    `isPropagationEnabled` in interface `DataCollection`

### setPropagationEnabled

    public void setPropagationEnabled(boolean propagationEnabled)

  Specified by:
    `setPropagationEnabled` in interface `DataCollection`

### propagateElementWillChange

    public void propagateElementWillChange(DataCollection source,
                                           DataCollectionEvent primaryEvent)

  Specified by:
    `propagateElementWillChange` in interface `DataCollection`
  To do:
    comment

### propagateElementChanged

    public void propagateElementChanged(DataCollection source,
                                        DataCollectionEvent primaryEvent)

  Specified by:
    `propagateElementChanged` in interface `DataCollection`
  To do:
    comment

### checkMutable

    protected void checkMutable()

  Check whether the data collection is mutable.

  Throws:
    `java.lang.UnsupportedOperationException` - if collection is immmutable.

### doGet

    protected DataElement doGet(java.lang.String name)
                         throws java.lang.Exception

  This method should be implemented in subclasses to get the specified data element from the collection. This implementation use iterator for finding needed data element.

  Parameters:
    `name` - Name of needed data element.
  Returns:
    Data element or null if data element with specified name not found.
  Throws:
    `java.util.UnsupportedOperationException` - If Iterator.next() throw this exception.
    `java.lang.Exception`
  See Also:
    `get(String)`, `DataCollection.iterator()`

### doPut

    protected void doPut(DataElement dataElement,
                         boolean isNew)
                  throws java.lang.Exception

  This method should be implemented in mutable subclasses to put the specified data element into the collection.

  Throws:
    `java.lang.UnsupportedOperationException` - Always throws.
    `java.lang.Exception`
  See Also:
    `put(DataElement)`

### doRemove

    protected void doRemove(java.lang.String name)
                     throws java.lang.Exception

  This method should be implemented in mutable subclasses to remove the specified data element from the collection.

  Throws:
    `java.lang.UnsupportedOperationException` - Always .
    `java.lang.Exception`
  See Also:
    `remove(String)`

### close

    public void close()
               throws java.lang.Exception

  Close the data collection and release all used resources. Default implementation provides following actions:
  - closing `DataCollectionInfo` that provides closing of `QuerySystem`

  Specified by:
    `close` in interface `DataCollection`
  Throws:
    `java.lang.Exception` - If error occured.
  Pendung:
    close all child DataCollections (registered in cache), clear the cache, release reference to this data collection in parent cache

### release

    public void release(java.lang.String name)

  Release the DataElement specified by its name from the cache.

  Specified by:
    `release` in interface `DataCollection`
  Pendung:
    whether this operation should be called by close operation.

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. Calls ``close()`` method

  Throws:
    `java.lang.Throwable` - the `Exception` raised by this method

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2003 Biosof.Ru. All Rights Reserved.