com.hardcode.gdbms.engine.data
Interface DataSource

All Superinterfaces:
ReadAccess
All Known Subinterfaces:
AlphanumericDataSource, EditableDataSource, PKEditableDataSource, SpatialDataSource
All Known Implementing Classes:
AbstractDataSource, AggregateDataSource, AlphanumericFileDataSourceAdapter, AlphanumericObjectDataSourceAdapter, AutomaticDataSource, DBSpatialDataSourceAdapter, DBTableDataSourceAdapter, DistinctDataSource, FilteredDataSource, OperationDataSource, OrderedDataSource, PDataSource, ProjectionDataSource, SpatialFileDataSourceAdapter, SpatialObjectDataSourceAdapter, UndoableAlphanumericDataSource, UndoableSpatialDataSource, UnionDataSource

public interface DataSource
extends ReadAccess

Interfaz que define los origenes de datos para operaciones internas del motor de base de datos

Author:
Fernando González Cortés

Field Summary
static int COHERENT_ROW_ORDER
           
static int DIRECT_MODE
           
static int DISPATCH
          All edition events will be notified to the listeners
static int IGNORE
          None of the edition events will be notified to the listeners
static int STORE
          The edition events will be stored but not notified.
 
Method Summary
 void addEditionListener(EditionListener listener)
          Adds an EditionListener to the DataSource
 void addField(java.lang.String name, java.lang.String driverType)
          Adds a field to the DataSource
 void addField(java.lang.String name, java.lang.String driverType, java.lang.String[] paramNames, java.lang.String[] paramValues)
          Adds a field to the DataSource
 void addMetadataEditionListener(MetadataEditionListener listener)
          Adds a listener for the Metadata edition events
 void addSelectionListener(SelectionListener listener)
          Adds an SelectionListener to the DataSource
 void beginTrans()
          Begins a transaction
 boolean canRedo()
           
 boolean canUndo()
           
 java.lang.String check(int fieldId, Value value)
          Checks if this value is a valid one for the specified field.
 void commitTrans()
          Commits the changes made during the transaction.
 java.lang.String getAlias()
          Returns the alias used in this DataSource
 java.lang.String getAsString()
          Gets the string representation of this DataSource
 DataSourceFactory getDataSourceFactory()
          gets a reference to the factory object that created the DataSource
 Metadata getDataSourceMetadata()
          Gets the meta data about the source of this DataSource
 int getDispatchingMode()
          Gets the dispatchingMode property
 GDBMSDriver getDriver()
          Gets the driver which this DataSource is over.
 DriverMetadata getDriverMetadata()
          Gets the driver metadata
 int getFieldIndexByName(java.lang.String fieldName)
          Obtiene el indice de un campo a partir de su nombre o -1 si no existe un campo con ese nombre
 java.lang.String[] getFieldNames()
          Gets the field names array
 Memento getMemento()
          Gets a memento object with the current status of the DataSource
 java.lang.String getName()
          Devuelve el nombre del DataSource
 Value[] getRow(long rowIndex)
          Gets the value of all fields at the specified row
 int[] getSelectedRows()
          Gets the row selection
 long[] getWhereFilter()
          Devuelve el filtro que resultó de la cláusula where de la instrucción que dió como resultado este DataSource.
 void insertEmptyRow()
          Inserts a row at the end of the dataware
 void insertFilledRow(Value[] values)
          Inserts a row at the end of the dataware with the specified values
 boolean isModified()
          Returns true if the DataSource has been modified since it was created.
 void redo()
          Redoes the last undone edition action
 void remove()
          Removes from the system the data source this DataSource instance represents.
 void removeEditionListener(EditionListener listener)
          Removes an EditionListener from the DataSource
 void removeField(int index)
          Removes the field at the indexth position
 void removeMetadataEditionListener(MetadataEditionListener listener)
          Removes a listener for the Metadata edition events
 void removeSelectionListener(SelectionListener listener)
          Removes an SelectionListener from the DataSource
 void rollBackTrans()
          Cancels the changes made during the transaction
 void saveData(DataSource ds)
          Saves the data in the parameter DataSource in the source of this DataSource.
 void setDataSourceFactory(DataSourceFactory dsf)
          Sets the DataSourceFactory that created the DataSource instance
 void setDispatchingMode(int dispatchingMode)
          Defines the behaviour of the DataSource when an edition event happens.
 void setFieldName(int index, java.lang.String name)
          Sets the name of the field at the indexth position
 void setFieldValue(long row, int fieldId, Value value)
          Sets the value of a cell of the table.
 void setSelectedRows(int[] sel)
          Sets the row selection
 void start()
          Opens the DataSource to access the data it contains.
 void stop()
          Closes the DataSource.
 void undo()
          Undoes the last edition action
 
Methods inherited from interface com.hardcode.gdbms.engine.data.driver.ReadAccess
getFieldValue, getRowCount
 

Field Detail

DIRECT_MODE

static final int DIRECT_MODE
See Also:
Constant Field Values

COHERENT_ROW_ORDER

static final int COHERENT_ROW_ORDER
See Also:
Constant Field Values

DISPATCH

static final int DISPATCH
All edition events will be notified to the listeners

See Also:
Constant Field Values

IGNORE

static final int IGNORE
None of the edition events will be notified to the listeners

See Also:
Constant Field Values

STORE

static final int STORE
The edition events will be stored but not notified. When the status changes a multipleModification event will be sent to the listeners

See Also:
Constant Field Values
Method Detail

start

void start()
           throws DriverException
Opens the DataSource to access the data it contains. If the data is accessed without a previous opening a ClosedDataSourceException is thrown. If this method is invoked twice then only the second call to stop will close the DataSource.
If the DataSource was obtained with an AUTOMATIC_OPENING mode, there's no need to open the DataSource. Indeed start calls are ignored. It's possible to close the DataSource by a single call to the close method

Throws:
DriverException - if the operation fails

stop

void stop()
          throws DriverException,
                 AlreadyClosedException
Closes the DataSource. After a DataSource is closed it's data cannot be retrieved. Any attempt to do so will result in a DataSourceClosedException

Throws:
DriverException - If the operation fails
AlreadyClosedException

getName

java.lang.String getName()
Devuelve el nombre del DataSource

Returns:
nombre de la tabla

getAlias

java.lang.String getAlias()
Returns the alias used in this DataSource

Returns:
String

getWhereFilter

long[] getWhereFilter()
                      throws java.io.IOException
Devuelve el filtro que resultó de la cláusula where de la instrucción que dió como resultado este DataSource.

Returns:
Filtro de la cláusula where o null si el DataSource no es resultado de una instrucción con cláusula where
Throws:
java.io.IOException - Si se produce un error accediendo a las estructuras de datos internas

getDataSourceFactory

DataSourceFactory getDataSourceFactory()
gets a reference to the factory object that created the DataSource

Returns:
DataSourceFactory

getMemento

Memento getMemento()
                   throws MementoException
Gets a memento object with the current status of the DataSource

Returns:
DataSourceMemento
Throws:
MementoException - If the state cannot be obtained

setDataSourceFactory

void setDataSourceFactory(DataSourceFactory dsf)
Sets the DataSourceFactory that created the DataSource instance

Parameters:
dsf - DataSourceFactory

getAsString

java.lang.String getAsString()
                             throws DriverException
Gets the string representation of this DataSource

Returns:
String
Throws:
DriverException

remove

void remove()
            throws DriverException
Removes from the system the data source this DataSource instance represents. No method can be called and no DataSource instance can be obtained from the system after calling this method.

Throws:
DriverException - if the DataSource original system could not be cleaned properly

getRow

Value[] getRow(long rowIndex)
               throws DriverException
Gets the value of all fields at the specified row

Parameters:
rowIndex - index of the row to be retrieved
Returns:
Value[]
Throws:
DriverException - If the access fails

getFieldNames

java.lang.String[] getFieldNames()
                                 throws DriverException
Gets the field names array

Returns:
String[]
Throws:
DriverException - if the access fails

getFieldIndexByName

int getFieldIndexByName(java.lang.String fieldName)
                        throws DriverException
Obtiene el indice de un campo a partir de su nombre o -1 si no existe un campo con ese nombre

Parameters:
fieldName - Nombre del campo
Returns:
Indice del campo con el nombre dado o -1 si el campo no existe
Throws:
DriverException - Si se produce un error accediendo a los datos

insertFilledRow

void insertFilledRow(Value[] values)
                     throws DriverException
Inserts a row at the end of the dataware with the specified values

Parameters:
values - Values of the inserted row fields in the field order
Throws:
DriverException - if the row could not be inserted

insertEmptyRow

void insertEmptyRow()
                    throws DriverException
Inserts a row at the end of the dataware

Throws:
DriverException - if the row could not be inserted

beginTrans

void beginTrans()
                throws DriverException
Begins a transaction

Throws:
DriverException - If the transaction could not be started

commitTrans

void commitTrans()
                 throws DriverException,
                        FreeingResourcesException
Commits the changes made during the transaction. The DataSource is closed after the commit so any spatial or alphanumeric index will be cleared

Throws:
DriverException - If the transaction could not be commited
FreeingResourcesException - The commit was correctly done but a problem occured while freeing resources

rollBackTrans

void rollBackTrans()
                   throws DriverException
Cancels the changes made during the transaction

Throws:
DriverException - If the transaction could not be cancelled

setFieldValue

void setFieldValue(long row,
                   int fieldId,
                   Value value)
                   throws DriverException
Sets the value of a cell of the table. Cannot be called outside a beginTrans-commintTrans or beginTrans-rollBackTrans

Parameters:
row - row to update
fieldId - field to update
value - Value to update
Throws:
DriverException - If the operation failed

saveData

void saveData(DataSource ds)
              throws DriverException
Saves the data in the parameter DataSource in the source of this DataSource. Both DataSource's must have the same schema, the same metadata. This DataSource must be closed before any call to this method

Parameters:
ds - DataSource with the data
Throws:
DriverException - if the operation fails

getDataSourceMetadata

Metadata getDataSourceMetadata()
                               throws DriverException
Gets the meta data about the source of this DataSource

Returns:
DataSourceMetadata
Throws:
DriverException - If cannot get the DataSource metadata

redo

void redo()
          throws DriverException
Redoes the last undone edition action

Throws:
DriverException

undo

void undo()
          throws DriverException
Undoes the last edition action

Throws:
DriverException

canRedo

boolean canRedo()
Returns:
true if there is an edition action to redo

canUndo

boolean canUndo()
Returns:
true if there is an edition action to undo

addMetadataEditionListener

void addMetadataEditionListener(MetadataEditionListener listener)
Adds a listener for the Metadata edition events

Parameters:
listener -

removeMetadataEditionListener

void removeMetadataEditionListener(MetadataEditionListener listener)
Removes a listener for the Metadata edition events

Parameters:
listener -

addEditionListener

void addEditionListener(EditionListener listener)
Adds an EditionListener to the DataSource

Parameters:
listener -

removeEditionListener

void removeEditionListener(EditionListener listener)
Removes an EditionListener from the DataSource

Parameters:
listener -

addSelectionListener

void addSelectionListener(SelectionListener listener)
Adds an SelectionListener to the DataSource

Parameters:
listener -

removeSelectionListener

void removeSelectionListener(SelectionListener listener)
Removes an SelectionListener from the DataSource

Parameters:
listener -

setDispatchingMode

void setDispatchingMode(int dispatchingMode)
Defines the behaviour of the DataSource when an edition event happens. It can be set to DISPATCH, STORE, IGNORE. It's set to DISPATCH when the DataSource opens

Parameters:
dispatchingMode -

getDispatchingMode

int getDispatchingMode()
Gets the dispatchingMode property


addField

void addField(java.lang.String name,
              java.lang.String driverType)
              throws DriverException
Adds a field to the DataSource

Parameters:
name - name of the field
driverType - driver specific type name
Throws:
DriverException

addField

void addField(java.lang.String name,
              java.lang.String driverType,
              java.lang.String[] paramNames,
              java.lang.String[] paramValues)
              throws DriverException
Adds a field to the DataSource

Parameters:
name - name of the field
driverType - driver specific type name
Throws:
DriverException

removeField

void removeField(int index)
                 throws DriverException
Removes the field at the indexth position

Parameters:
i -
Throws:
DriverException

setFieldName

void setFieldName(int index,
                  java.lang.String name)
                  throws DriverException
Sets the name of the field at the indexth position

Parameters:
index -
name -
Throws:
DriverException

getDriverMetadata

DriverMetadata getDriverMetadata()
                                 throws DriverException
Gets the driver metadata

Returns:
Throws:
DriverException

check

java.lang.String check(int fieldId,
                       Value value)
                       throws DriverException
Checks if this value is a valid one for the specified field. Returns null if the field contains a valid value and returns a String with a message to the user if it is not

Parameters:
fieldId -
value -
Returns:
Throws:
DriverException

getDriver

GDBMSDriver getDriver()
Gets the driver which this DataSource is over. Can be null

Returns:

isModified

boolean isModified()
Returns true if the DataSource has been modified since it was created. Notice that it doesn't check the source and only checks wheter the source has been modified through this instance

Returns:

setSelectedRows

void setSelectedRows(int[] sel)
Sets the row selection

Parameters:
is -

getSelectedRows

int[] getSelectedRows()
Gets the row selection

Returns:


Copyright © 2005-2006 . All Rights Reserved.