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 SqlDataCollection

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

All Implemented Interfaces:
  DataCollection, DataElement

public class SqlDataCollection
extends AbstractDataCollection

DataCollection which store all information in SQL DBMS.

See Also:
  `DataCollection`, `SqlTransformer`

Nested Class Summary
`protected class` | `SqlDataCollection.SQLIterator` Implement Iterator for iterate SqlDataCollection elements.

Field Summary
`static java.lang.String` | `JDBC_DRIVER_PROPERTY` Property for storing class of jdbc driver.
`static java.lang.String` | `JDBC_PASSWORD_PROPERTY` Property for storing user password for connecting to the DBMS.
`static java.lang.String` | `JDBC_URL_PROPERTY` Property for storing driver specific URL for connecting to the DBMS.
`static java.lang.String` | `JDBC_USER_PROPERTY` Property for storing user name for connecting to the DBMS.
`static java.lang.String` | `TRANSFORMER_CLASS_PROPERTY` Property for storing class of that should be used for converting DataElements to/from DBMS.

Fields inherited from class ru.biosoft.access.AbstractDataCollection
`cat, info, notificationEnabled, path, propagationEnabled, v_cache`

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
`SqlDataCollection(DataCollection parent, java.util.Properties properties)` Standart constructor for creating data collection.

Method Summary
`void` | `close()` Close connection to DBMS.
`boolean` | `contains(java.lang.String name)` Returns true if data collection contain element with the specified name.
`protected DataElement` | `doGet(java.lang.String name)` Extracts and returns DataElement with specified name from the data collection.
`protected void` | `doPut(DataElement de, boolean isNew)` Adds the specified data element to the collection.
`protected void` | `doRemove(java.lang.String name)` Remove DataElement from data collection.
`protected void` | `finalize()` Close collection if one not closed.
`java.sql.Connection` | `getConnection()` Return active connection.
`java.lang.Class` | `getDataElementType()` Return type of DataElement stored in this data collection.
`java.util.List` | `getNameList()` Gets list of all names in data collection.
`int` | `getSize()` Returns size of data collection.
`SqlTransformer` | `getTransformer()`
`boolean` | `isMutable()` Returns `true` if this data collection is mutable.
`java.util.Iterator` | `iterator()` Returns an iterator over the data elements in this collection.
`protected void` | `putInCache(DataElement de)` Put element in cache.

Methods inherited from class ru.biosoft.access.AbstractDataCollection
`addDataCollectionListener, cachePut, checkMutable, contains, doAddPostNotify, doAddPreNotify, doRemovePostNotify, doRemovePreNotify, fireElementAdded, fireElementChanged, fireElementRemoved, fireElementWillAdd, fireElementWillChange, fireElementWillRemove, get, getCompleteName, getDescription, getInfo, initLog, isNotificationEnabled, isPropagationEnabled, makeInfo, propagateElementChanged, propagateElementWillChange, put, registerRoot, release, remove, removeDataCollectionListener, setNotificationEnabled, setPropagationEnabled, toString`

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.DataElement
`getName, getOrigin`

Field Detail

### JDBC_DRIVER_PROPERTY

    public static final java.lang.String JDBC_DRIVER_PROPERTY

  Property for storing class of jdbc driver.

  See Also:
    Constant Field Values

### JDBC_URL_PROPERTY

    public static final java.lang.String JDBC_URL_PROPERTY

  Property for storing driver specific URL for connecting to the DBMS.

  See Also:
    Constant Field Values

### JDBC_USER_PROPERTY

    public static final java.lang.String JDBC_USER_PROPERTY

  Property for storing user name for connecting to the DBMS.

  See Also:
    Constant Field Values

### JDBC_PASSWORD_PROPERTY

    public static final java.lang.String JDBC_PASSWORD_PROPERTY

  Property for storing user password for connecting to the DBMS.

  See Also:
    Constant Field Values

### TRANSFORMER_CLASS_PROPERTY

    public static final java.lang.String TRANSFORMER_CLASS_PROPERTY

  Property for storing class of that should be used for converting DataElements to/from DBMS.

  See Also:
    Constant Field Values

Constructor Detail

### SqlDataCollection

    public SqlDataCollection(DataCollection parent,
                             java.util.Properties properties)
                      throws java.lang.ClassNotFoundException,
                             java.sql.SQLException,
                             java.lang.InstantiationException,
                             java.lang.IllegalAccessException

  Standart constructor for creating data collection. Used by CollectionFactory.
  Required properties:
  - `JDBC_DRIVER_PROPERTY`
  - `JDBC_URL_PROPERTY`
  - `JDBC_USER_PROPERTY`
  - `JDBC_PASSWORD_PROPERTY`
  - `TRANSFORMER_CLASS_PROPERTY`

Parameters:
  `parent` - Parent collection.
  `properties` - Properties for creating collection (cannot be null).
See Also:
  `JDBC_DRIVER_PROPERTY`, `JDBC_URL_PROPERTY`, `JDBC_USER_PROPERTY`, `JDBC_PASSWORD_PROPERTY`, `TRANSFORMER_CLASS_PROPERTY`

Method Detail

### getConnection

    public final java.sql.Connection getConnection()
                                            throws java.sql.SQLException

  Return active connection. Connect if necessary.

  Returns:
    Active connection.
  Throws:
    `java.sql.SQLException` - If operation on DBMS failed.

### getTransformer

    public SqlTransformer getTransformer()

### getDataElementType

    public java.lang.Class getDataElementType()

  Return type of DataElement stored in this data collection. Really ask transformer for extract template type.

  Specified by:
    `getDataElementType` in interface `DataCollection`
  Overrides:
    `getDataElementType` in class `AbstractDataCollection`
  Returns:
    Type of DataElement stored in this data collection.
  See Also:
    `SqlTransformer`

### isMutable

    public boolean isMutable()

  Returns `true` if this data collection is mutable. Check Connection is read only or not.

  Specified by:
    `isMutable` in interface `DataCollection`
  Overrides:
    `isMutable` in class `AbstractDataCollection`
  Returns:
    whether this collection is mutable.
  See Also:
    `Connection`

### getSize

    public int getSize()

  Returns size of data collection. This implementation execute SQL query for extract record count.

  Specified by:
    `getSize` in interface `DataCollection`
  Overrides:
    `getSize` in class `AbstractDataCollection`
  Returns:
    size of data collection.

### getNameList

    public java.util.List getNameList()

  Description copied from class: `AbstractDataCollection`
  Gets list of all names in data collection.

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

### contains

    public boolean contains(java.lang.String name)

  Returns true if data collection contain element with the specified name.

  Specified by:
    `contains` in interface `DataCollection`
  Overrides:
    `contains` in class `AbstractDataCollection`
  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:
    `AbstractDataCollection.contains(ru.biosoft.access.DataElement)`

### iterator

    public java.util.Iterator iterator()

  Returns an iterator over the data elements in this collection. There are no guarantees concerning the order in which the elements are returned. If the data collection is modified while an iteration over it is in progress, the results of the iteration are undefined.

  See Also:
    `SQLDataCollection.SQLIterator`

### close

    public void close()
               throws java.lang.Exception

  Close connection to DBMS. Invalidates SQLDataCollection instance.

  Specified by:
    `close` in interface `DataCollection`
  Overrides:
    `close` in class `AbstractDataCollection`
  Throws:
    `java.lang.Exception`

### putInCache

    protected void putInCache(DataElement de)

  Put element in cache. Make weak reference on the data element. Test is data element type equals to type that this collection returns.

  Parameters:
    `de` - DataElement that should be added into the cache.
  See Also:
    `AbstractDataCollection.put(DataElement)`

### doGet

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

  Extracts and returns DataElement with specified name from the data collection.

  Overrides:
    `doGet` in class `AbstractDataCollection`
  Parameters:
    `name` - Name of the data element (PK).
  Returns:
    DataElement with specified name or null, if data element not found.
  Throws:
    `java.sql.SQLException` - if cannot execute SELECT statement.
    `java.lang.Exception` - if transformer failed to create DataElement instance.
  See Also:
    `SqlTransformer.getElementQuery(String)`

### doRemove

    protected void doRemove(java.lang.String name)
                     throws java.sql.SQLException

  Remove DataElement from data collection.

  Overrides:
    `doRemove` in class `AbstractDataCollection`
  Throws:
    `java.sql.SQLException` - If cannot execute DELETE statement generated by transformer.
    If cannot create Statement.
  See Also:
    `ru.biosoft.access.SqlTransformer#getDeleteQuery(String)`

### doPut

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

  Adds the specified data element to the collection. If element is new then Insert query will be executed otherwise Update query from SqlTransformer will be used.

  Overrides:
    `doPut` in class `AbstractDataCollection`
  Throws:
    `java.sql.SQLException` - If cannot execute Insert or Update statement generated by transformer.
    If cannot create Statement.
    `java.lang.Exception`
  See Also:
    `ru.biosoft.access.SqlTransformer#getInsertQuery(DataElement)`, `ru.biosoft.access.SqlTransformer#getUpdateQuery(DataElement)`

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Close collection if one not closed.

  Overrides:
    `finalize` in class `AbstractDataCollection`
  Throws:
    `java.lang.Exception` - If error occured.
    `java.lang.Throwable` - the `Exception` raised by this method
  See Also:
    `close()`

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.