org.cruxframework.crux.core.client.datasource
Interface DataSource<E>

All Known Subinterfaces:
LocalDataSource<E>, MeasurableDataSource<E>, MeasurablePagedDataSource<E>, MeasurableRemoteDataSource<E>, PagedDataSource<E>, RemoteDataSource<E>, StreamingDataSource<E>
All Known Implementing Classes:
LocalPagedDataSource, LocalScrollableDataSource, RemotePagedDataSource, RemoteStreamingDataSource

public interface DataSource<E>

A Datasource is used to provide information to widgets that implements HasDataSource interface, like Crux Grid.

Author:
Thiago da Rosa de Bustamante

Method Summary
 void clearChanges()
          Undo all changes
 E cloneDTO(DataSourceRecord<?> record)
          Clones the recordObject of a given DataSourceRecord
 void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> widget, String key, DataSourceRecord<?> dataSourceRecord)
          Copies the value from data record to the given widget
 void firstRecord()
          Points DataSource to first record
 E getBoundObject()
          Return a copy of the current record object.
 E getBoundObject(DataSourceRecord<E> record)
          Return a copy of the record object.
 ColumnDefinitions<E> getColumnDefinitions()
          Return the DataSource definitions object.
 DataSourceRecord<E>[] getNewRecords()
          Return all records inserted on DataSource
 DataSourceRecord<E> getRecord()
          Return the DataSourceRecord object, representing the current record
 DataSourceRecord<E>[] getRemovedRecords()
          Return all records removed from DataSource
 DataSourceRecord<E>[] getSelectedRecords()
          Return all records selected on DataSource
 DataSourceRecord<E>[] getUpdatedRecords()
          Return all records modified on DataSource
 Object getValue(String columnName)
          Return the column value
 Object getValue(String columnName, DataSourceRecord<?> record)
          Return the column value
 boolean hasNextRecord()
          Verify if DataSource has more records.
 boolean hasPreviousRecord()
          Verify if DataSource has previous records.
 DataSourceRecord<E> insertRecord(int beforeRecord)
          Insert a new record on DataSource
 void nextRecord()
          Points DataSource to next record
 void previousRecord()
          Points DataSource to previous record
 DataSourceRecord<E> removeRecord(int record)
          Remove a record from DataSource
 void reset()
          Reset DataSource, as if it was never loaded before.
 void setColumnDefinitions(ColumnDefinitions<E> columnDefinitions)
          Sets the DataSource definitions object.
 void setValue(Object value, String columnKey, DataSourceRecord<?> dataSourceRecord)
          Sets the value on the given column of the give record
 void sort(String columnName, boolean ascending)
          Sort dataSource records, based on column informed
 void sort(String columnName, boolean ascending, boolean caseSensitive)
          Sort dataSource records, based on column informed
 void updateState(DataSourceRecord<E> record, DataSourceRecord.DataSourceRecordState previousState)
          Update a record on DataSource
 

Method Detail

firstRecord

void firstRecord()
Points DataSource to first record


hasNextRecord

boolean hasNextRecord()
Verify if DataSource has more records.

Returns:
true if more records exist.

nextRecord

void nextRecord()
Points DataSource to next record


hasPreviousRecord

boolean hasPreviousRecord()
Verify if DataSource has previous records.

Returns:
true if previous records exist.

previousRecord

void previousRecord()
Points DataSource to previous record


sort

void sort(String columnName,
          boolean ascending)
Sort dataSource records, based on column informed

Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.

sort

void sort(String columnName,
          boolean ascending,
          boolean caseSensitive)
Sort dataSource records, based on column informed

Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.
caseSensitive - indicate if the columns sort are or not key sensitive

reset

void reset()
Reset DataSource, as if it was never loaded before.


getColumnDefinitions

ColumnDefinitions<E> getColumnDefinitions()
Return the DataSource definitions object.

Returns:
Definitions object

setColumnDefinitions

void setColumnDefinitions(ColumnDefinitions<E> columnDefinitions)
Sets the DataSource definitions object.

Parameters:
columnDefinitions -

getValue

Object getValue(String columnName)
Return the column value

Parameters:
columnName - name of the column
Returns:
value of the column

getValue

Object getValue(String columnName,
                DataSourceRecord<?> record)
Return the column value

Parameters:
columnName -
record -
Returns:

getRecord

DataSourceRecord<E> getRecord()
Return the DataSourceRecord object, representing the current record

Returns:
current DataSourceRecord object.

getBoundObject

E getBoundObject()
Return a copy of the current record object.

Returns:

getBoundObject

E getBoundObject(DataSourceRecord<E> record)
Return a copy of the record object.

Parameters:
record -
Returns:

insertRecord

DataSourceRecord<E> insertRecord(int beforeRecord)
Insert a new record on DataSource

Parameters:
beforeRecord -
Returns:

removeRecord

DataSourceRecord<E> removeRecord(int record)
Remove a record from DataSource

Parameters:
record -
Returns:

updateState

void updateState(DataSourceRecord<E> record,
                 DataSourceRecord.DataSourceRecordState previousState)
Update a record on DataSource

Parameters:
record -
previousState -

getNewRecords

DataSourceRecord<E>[] getNewRecords()
Return all records inserted on DataSource

Returns:
all new records

getRemovedRecords

DataSourceRecord<E>[] getRemovedRecords()
Return all records removed from DataSource

Returns:
all removed records

getUpdatedRecords

DataSourceRecord<E>[] getUpdatedRecords()
Return all records modified on DataSource

Returns:
all modified records

getSelectedRecords

DataSourceRecord<E>[] getSelectedRecords()
Return all records selected on DataSource

Returns:
all selected records

clearChanges

void clearChanges()
Undo all changes


copyValueToWidget

void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> widget,
                       String key,
                       DataSourceRecord<?> dataSourceRecord)
Copies the value from data record to the given widget

Parameters:
widget -
key -
dataSourceRecord -

setValue

void setValue(Object value,
              String columnKey,
              DataSourceRecord<?> dataSourceRecord)
Sets the value on the given column of the give record

Parameters:
value -
columnKey -
dataSourceRecord -

cloneDTO

E cloneDTO(DataSourceRecord<?> record)
Clones the recordObject of a given DataSourceRecord

Parameters:
record -
Returns:


Copyright © 2014. All rights reserved.