com.hardcode.gdbms.engine.data.object
Class AlphanumericObjectDataSourceAdapter

java.lang.Object
  extended by com.hardcode.gdbms.engine.data.object.AlphanumericObjectDataSourceAdapter
All Implemented Interfaces:
AlphanumericDataSource, DataSource, ReadAccess, EditableDataSource

public class AlphanumericObjectDataSourceAdapter
extends java.lang.Object
implements AlphanumericDataSource, EditableDataSource


Field Summary
 
Fields inherited from interface com.hardcode.gdbms.engine.data.DataSource
COHERENT_ROW_ORDER, DIRECT_MODE, DISPATCH, IGNORE, STORE
 
Fields inherited from interface com.hardcode.gdbms.engine.data.DataSource
COHERENT_ROW_ORDER, DIRECT_MODE, DISPATCH, IGNORE, STORE
 
Constructor Summary
AlphanumericObjectDataSourceAdapter(java.lang.String name, java.lang.String alias, AlphanumericObjectDriver driver)
           
 
Method Summary
 void addEditionListener(EditionListener listener)
          Adds an EditionListener to the DataSource
 void addField(java.lang.String name, java.lang.String type)
          Adds a field to the DataSource
 void addField(java.lang.String name, java.lang.String type, 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.
 void deleteRow(long rowId)
          Deletes the ith row of the DataSource
 void endUndoRedoAction()
          Notifies this DataSource that the next edition operations no longer are caused by an undo or redo operation
 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
 AlphanumericObjectDriver getDriver()
          Gets the driver which this DataSource is over.
 DriverMetadata getDriverMetadata()
          Gets the driver metadata
 int getFieldCount()
           
 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 getFieldName(int fieldId)
           
 java.lang.String[] getFieldNames()
          Gets the field names array
 int getFieldType(int i)
           
 Value getFieldValue(long rowIndex, int fieldId)
          Obtiene el valor que se encuentra en la fila y columna indicada
 Memento getMemento()
          Gets a memento object with the current status of the DataSource
 java.lang.String getName()
          Devuelve el nombre del DataSource
 DriverMetadata getOriginalDriverMetadata()
          Gets the driver specific metadata from the driver directly without the new, modified or deleted fields
 int getOriginalFieldCount()
          Gets the number of field this DataSource had before edition started
 Value getOriginalFieldValue(long rowIndex, int fieldId)
          Gets the value of the DataSource field before the edition started
 Metadata getOriginalMetadata()
          Gets the Metadata from the driver without taking care of added, removed or modified fields.
 Value[] getRow(long rowIndex)
          Gets the value of all fields at the specified row
 long getRowCount()
          Obtiene el número de registros del DataSource
 int[] getSelectedRows()
          Gets the row selection
 int getType(java.lang.String driverType)
          Returns the suitable GDBMS type for the given driver specific type
 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 insertEmptyRowAt(long index)
          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
 void insertFilledRowAt(long index, 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 setAlias(java.lang.String alias)
           
 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 setDriver(ReadAccess driver)
           
 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 setName(java.lang.String name)
           
 void setSelectedRows(int[] sel)
          Sets the row selection
 void start()
          Opens the DataSource to access the data it contains.
 void startUndoRedoAction()
          Notifies this DataSource that the next edition operations are caused by an undo or redo operation
 void stop()
          Closes the DataSource.
 void undo()
          Undoes the last edition action
 void undoDeletion(int index)
           
 void undoDeletion(int index, Value[] deletedRow)
          Notifies the adapter that the specified index deletion is being undone
 void undoInsert(long row)
           
 void undoSet(long row, int field, Value value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlphanumericObjectDataSourceAdapter

public AlphanumericObjectDataSourceAdapter(java.lang.String name,
                                           java.lang.String alias,
                                           AlphanumericObjectDriver driver)
Method Detail

getAlias

public java.lang.String getAlias()
Description copied from interface: DataSource
Returns the alias used in this DataSource

Specified by:
getAlias in interface DataSource
Returns:
String

getAsString

public java.lang.String getAsString()
                             throws DriverException
Description copied from interface: DataSource
Gets the string representation of this DataSource

Specified by:
getAsString in interface DataSource
Returns:
String
Throws:
DriverException

getDataSourceFactory

public DataSourceFactory getDataSourceFactory()
Description copied from interface: DataSource
gets a reference to the factory object that created the DataSource

Specified by:
getDataSourceFactory in interface DataSource
Returns:
DataSourceFactory

getFieldNames

public java.lang.String[] getFieldNames()
                                 throws DriverException
Description copied from interface: DataSource
Gets the field names array

Specified by:
getFieldNames in interface DataSource
Returns:
String[]
Throws:
DriverException - if the access fails

getMemento

public Memento getMemento()
                   throws MementoException
Description copied from interface: DataSource
Gets a memento object with the current status of the DataSource

Specified by:
getMemento in interface DataSource
Returns:
DataSourceMemento
Throws:
MementoException - If the state cannot be obtained

getName

public java.lang.String getName()
Description copied from interface: DataSource
Devuelve el nombre del DataSource

Specified by:
getName in interface DataSource
Returns:
nombre de la tabla

getRow

public Value[] getRow(long rowIndex)
               throws DriverException
Description copied from interface: DataSource
Gets the value of all fields at the specified row

Specified by:
getRow in interface DataSource
Parameters:
rowIndex - index of the row to be retrieved
Returns:
Value[]
Throws:
DriverException - If the access fails

getWhereFilter

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

Specified by:
getWhereFilter in interface 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

remove

public void remove()
            throws DriverException
Description copied from interface: DataSource
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.

Specified by:
remove in interface DataSource
Throws:
DriverException - if the DataSource original system could not be cleaned properly

setAlias

public void setAlias(java.lang.String alias)

setDataSourceFactory

public void setDataSourceFactory(DataSourceFactory dsf)
Description copied from interface: DataSource
Sets the DataSourceFactory that created the DataSource instance

Specified by:
setDataSourceFactory in interface DataSource
Parameters:
dsf - DataSourceFactory

setName

public void setName(java.lang.String name)

getFieldCount

public int getFieldCount()
                  throws DriverException
Specified by:
getFieldCount in interface EditableDataSource
Throws:
DriverException

getFieldIndexByName

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

Specified by:
getFieldIndexByName in interface DataSource
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

beginTrans

public void beginTrans()
                throws DriverException
Description copied from interface: DataSource
Begins a transaction

Specified by:
beginTrans in interface DataSource
Throws:
DriverException - If the transaction could not be started

commitTrans

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

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

deleteRow

public void deleteRow(long rowId)
               throws DriverException
Description copied from interface: AlphanumericDataSource
Deletes the ith row of the DataSource

Specified by:
deleteRow in interface AlphanumericDataSource
Parameters:
rowId - index of the row to be deleted
Throws:
DriverException - if the row could not be deleted

getFieldValue

public Value getFieldValue(long rowIndex,
                           int fieldId)
                    throws DriverException
Description copied from interface: ReadAccess
Obtiene el valor que se encuentra en la fila y columna indicada

Specified by:
getFieldValue in interface ReadAccess
Parameters:
rowIndex - fila
fieldId - columna
Returns:
subclase de Value con el valor del origen de datos. Never null (use ValueFactory.createNullValue() instead)
Throws:
DriverException - Si se produce un error accediendo al DataSource

getOriginalFieldValue

public Value getOriginalFieldValue(long rowIndex,
                                   int fieldId)
                            throws DriverException
Description copied from interface: EditableDataSource
Gets the value of the DataSource field before the edition started

Specified by:
getOriginalFieldValue in interface EditableDataSource
Returns:
Throws:
DriverException

getRowCount

public long getRowCount()
                 throws DriverException
Description copied from interface: ReadAccess
Obtiene el número de registros del DataSource

Specified by:
getRowCount in interface ReadAccess
Returns:
Throws:
DriverException - Si se produce algún error accediendo al DataSource

insertEmptyRow

public void insertEmptyRow()
                    throws DriverException
Description copied from interface: DataSource
Inserts a row at the end of the dataware

Specified by:
insertEmptyRow in interface DataSource
Throws:
DriverException - if the row could not be inserted

insertEmptyRowAt

public void insertEmptyRowAt(long index)
                      throws DriverException
Description copied from interface: AlphanumericDataSource
Inserts a row at the end of the dataware

Specified by:
insertEmptyRowAt in interface AlphanumericDataSource
Parameters:
index - index where the row will be inserted. No data is lost.
Throws:
DriverException - if the row could not be inserted

insertFilledRow

public void insertFilledRow(Value[] values)
                     throws DriverException
Description copied from interface: DataSource
Inserts a row at the end of the dataware with the specified values

Specified by:
insertFilledRow in interface DataSource
Parameters:
values - Values of the inserted row fields in the field order
Throws:
DriverException - if the row could not be inserted

insertFilledRowAt

public void insertFilledRowAt(long index,
                              Value[] values)
                       throws DriverException
Description copied from interface: AlphanumericDataSource
Inserts a row at the end of the dataware with the specified values

Specified by:
insertFilledRowAt in interface AlphanumericDataSource
Parameters:
index - index where the row will be inserted. No data is lost.
values - Values of the inserted row fields in the field order
Throws:
DriverException - if the row could not be inserted

rollBackTrans

public void rollBackTrans()
                   throws DriverException
Description copied from interface: DataSource
Cancels the changes made during the transaction

Specified by:
rollBackTrans in interface DataSource
Throws:
DriverException - If the transaction could not be cancelled

setDriver

public void setDriver(ReadAccess driver)

setFieldValue

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

Specified by:
setFieldValue in interface DataSource
Parameters:
row - row to update
fieldId - field to update
value - Value to update
Throws:
DriverException - If the operation failed

start

public void start()
           throws DriverException
Description copied from interface: DataSource
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

Specified by:
start in interface DataSource
Throws:
DriverException - if the operation fails

stop

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

Specified by:
stop in interface DataSource
Throws:
DriverException - If the operation fails
AlreadyClosedException

saveData

public void saveData(DataSource ds)
              throws DriverException
Description copied from interface: DataSource
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

Specified by:
saveData in interface DataSource
Parameters:
ds - DataSource with the data
Throws:
DriverException - if the operation fails

getFieldName

public java.lang.String getFieldName(int fieldId)
                              throws DriverException
Specified by:
getFieldName in interface EditableDataSource
Throws:
DriverException

getFieldType

public int getFieldType(int i)
                 throws DriverException
Specified by:
getFieldType in interface EditableDataSource
Throws:
DriverException

canRedo

public boolean canRedo()
Specified by:
canRedo in interface DataSource
Returns:
true if there is an edition action to redo

canUndo

public boolean canUndo()
Specified by:
canUndo in interface DataSource
Returns:
true if there is an edition action to undo

redo

public void redo()
          throws DriverException
Description copied from interface: DataSource
Redoes the last undone edition action

Specified by:
redo in interface DataSource
Throws:
DriverException

undo

public void undo()
          throws DriverException
Description copied from interface: DataSource
Undoes the last edition action

Specified by:
undo in interface DataSource
Throws:
DriverException

addEditionListener

public void addEditionListener(EditionListener listener)
Description copied from interface: DataSource
Adds an EditionListener to the DataSource

Specified by:
addEditionListener in interface DataSource

removeEditionListener

public void removeEditionListener(EditionListener listener)
Description copied from interface: DataSource
Removes an EditionListener from the DataSource

Specified by:
removeEditionListener in interface DataSource

setDispatchingMode

public void setDispatchingMode(int dispatchingMode)
Description copied from interface: DataSource
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

Specified by:
setDispatchingMode in interface DataSource

getDispatchingMode

public int getDispatchingMode()
Description copied from interface: DataSource
Gets the dispatchingMode property

Specified by:
getDispatchingMode in interface DataSource

addMetadataEditionListener

public void addMetadataEditionListener(MetadataEditionListener listener)
Description copied from interface: DataSource
Adds a listener for the Metadata edition events

Specified by:
addMetadataEditionListener in interface DataSource

addField

public void addField(java.lang.String name,
                     java.lang.String type)
              throws DriverException
Description copied from interface: DataSource
Adds a field to the DataSource

Specified by:
addField in interface DataSource
Parameters:
name - name of the field
type - driver specific type name
Throws:
DriverException

addField

public void addField(java.lang.String name,
                     java.lang.String type,
                     java.lang.String[] paramNames,
                     java.lang.String[] paramValues)
              throws DriverException
Description copied from interface: DataSource
Adds a field to the DataSource

Specified by:
addField in interface DataSource
Parameters:
name - name of the field
type - driver specific type name
Throws:
DriverException

getDataSourceMetadata

public Metadata getDataSourceMetadata()
Description copied from interface: DataSource
Gets the meta data about the source of this DataSource

Specified by:
getDataSourceMetadata in interface DataSource
Returns:
DataSourceMetadata

removeMetadataEditionListener

public void removeMetadataEditionListener(MetadataEditionListener listener)
Description copied from interface: DataSource
Removes a listener for the Metadata edition events

Specified by:
removeMetadataEditionListener in interface DataSource

removeField

public void removeField(int index)
                 throws DriverException
Description copied from interface: DataSource
Removes the field at the indexth position

Specified by:
removeField in interface DataSource
Throws:
DriverException

setFieldName

public void setFieldName(int index,
                         java.lang.String name)
                  throws DriverException
Description copied from interface: DataSource
Sets the name of the field at the indexth position

Specified by:
setFieldName in interface DataSource
Throws:
DriverException

getOriginalFieldCount

public int getOriginalFieldCount()
                          throws DriverException
Description copied from interface: EditableDataSource
Gets the number of field this DataSource had before edition started

Specified by:
getOriginalFieldCount in interface EditableDataSource
Returns:
Throws:
DriverException

getOriginalMetadata

public Metadata getOriginalMetadata()
                             throws DriverException
Description copied from interface: EditableDataSource
Gets the Metadata from the driver without taking care of added, removed or modified fields.

Specified by:
getOriginalMetadata in interface EditableDataSource
Returns:
Throws:
DriverException

getDriverMetadata

public DriverMetadata getDriverMetadata()
                                 throws DriverException
Description copied from interface: DataSource
Gets the driver metadata

Specified by:
getDriverMetadata in interface DataSource
Returns:
Throws:
DriverException

getType

public int getType(java.lang.String driverType)
Description copied from interface: EditableDataSource
Returns the suitable GDBMS type for the given driver specific type

Specified by:
getType in interface EditableDataSource
Returns:

getOriginalDriverMetadata

public DriverMetadata getOriginalDriverMetadata()
                                         throws DriverException
Description copied from interface: EditableDataSource
Gets the driver specific metadata from the driver directly without the new, modified or deleted fields

Specified by:
getOriginalDriverMetadata in interface EditableDataSource
Returns:
Throws:
DriverException

check

public java.lang.String check(int fieldId,
                              Value value)
                       throws DriverException
Description copied from interface: DataSource
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

Specified by:
check in interface DataSource
Returns:
Throws:
DriverException

getDriver

public AlphanumericObjectDriver getDriver()
Description copied from interface: DataSource
Gets the driver which this DataSource is over. Can be null

Specified by:
getDriver in interface DataSource
Returns:

endUndoRedoAction

public void endUndoRedoAction()
Description copied from interface: EditableDataSource
Notifies this DataSource that the next edition operations no longer are caused by an undo or redo operation

Specified by:
endUndoRedoAction in interface EditableDataSource

startUndoRedoAction

public void startUndoRedoAction()
Description copied from interface: EditableDataSource
Notifies this DataSource that the next edition operations are caused by an undo or redo operation

Specified by:
startUndoRedoAction in interface EditableDataSource

isModified

public boolean isModified()
Description copied from interface: DataSource
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

Specified by:
isModified in interface DataSource
Returns:

getSelectedRows

public int[] getSelectedRows()
Description copied from interface: DataSource
Gets the row selection

Specified by:
getSelectedRows in interface DataSource
Returns:

setSelectedRows

public void setSelectedRows(int[] sel)
Description copied from interface: DataSource
Sets the row selection

Specified by:
setSelectedRows in interface DataSource

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Description copied from interface: DataSource
Adds an SelectionListener to the DataSource

Specified by:
addSelectionListener in interface DataSource

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Description copied from interface: DataSource
Removes an SelectionListener from the DataSource

Specified by:
removeSelectionListener in interface DataSource

undoDeletion

public void undoDeletion(int index)

undoDeletion

public void undoDeletion(int index,
                         Value[] deletedRow)
                  throws DriverException
Description copied from interface: EditableDataSource
Notifies the adapter that the specified index deletion is being undone

Specified by:
undoDeletion in interface EditableDataSource
Throws:
DriverException

undoSet

public void undoSet(long row,
                    int field,
                    Value value)
             throws DriverException
Specified by:
undoSet in interface EditableDataSource
Throws:
DriverException

undoInsert

public void undoInsert(long row)
                throws DriverException
Specified by:
undoInsert in interface EditableDataSource
Throws:
DriverException


Copyright © 2005-2006 . All Rights Reserved.