com.elj.data.dataprovider.text
Class TextDataProvider

com.elj.data.dataprovider.text.TextDataProvider
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class TextDataProvider
implements java.io.Externalizable

This class encapsulates functionality of a text data provider.
It provides data in a format in which the row separator is new line
character, and the column separator is user-specified character.
And the first line contains the column names.
e.g.: The example with column separator ',' is as follows:
colName1,colName2,colName3
d11,d12,d13
d21,d22,d23

See Also:
Serialized Form

Field Summary
protected  java.beans.PropertyChangeSupport changes
           
static java.lang.String DEFAULT_COLUMN_SEPARATOR
           
 
Constructor Summary
TextDataProvider()
          Constructs an empty text data provider with no.
 
Method Summary
 void addDataListener(com.elj.data.dataprovider.text.DataListener listener)
          Not implemented.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
 void addRow(java.util.Vector vector)
          Method which adds a record to the end of existing records.
 int appendData(java.util.Vector rec)
          Method which appends the record at the end of existing records.
 void deleteRow()
          Method which deletes the current record.
 void filterData(java.lang.String filterCriteria)
          Not implemented.
 int find(java.lang.String condition, int startIndex, int endIndex)
          Not implemented.
 int findNext()
          Not implemented.
 void fireDataChanged(int eventId, java.util.Hashtable oldValue, java.util.Hashtable newValue)
          Not implemented.
 java.util.Vector firstRecord()
          Method which returns the first record.
 int getColumnCount()
          Method which returns the column count.
 int getColumnIndex(java.lang.String colName)
          Method which returns index of specified column name.
 java.util.Vector getColumnNames()
          Method which returns the vector of column names.
 java.lang.String[] getColumnsArray()
           
 java.lang.String getColumnSeparator()
          Method which returns the column separator for this text data provider.
 int getColumnType(int colIndex)
          Method which returns type of specified column index.
 int getCurrentIndex()
          Method which returns the current cursor position.
 java.util.Vector getCurrentRecord()
          Method which retrieves current record.
 java.util.Vector getData()
          Method which returns the data vector.
 java.util.Vector getDataAt(int recordIndex)
          Method which returns the record at specified index.
 java.lang.Object getDataAt(int recordIndex, int columnIndex)
          Method which returns the data at specified record and column index.
 int getDataCount()
          Method which returns total number of records.
 com.elj.data.dataprovider.text.DataProvider getDataProvider()
           
 int getDeletedCount()
          Not implemented.
 int getFilteredCount()
          Not implemented.
 int getModifiedCount()
          Not implemented.
 int getTableCount()
          Not implemented.
 java.util.Vector getTableNames()
          Not implemented.
 int insertDataAt(java.util.Vector rec, int position)
          Method which inserts specified record at specified position.
 boolean isFilterState()
          Not implemented.
 java.util.Vector lastRecord()
          Method which returns the last record.
 void modifyDataAt(java.util.Vector data, int position)
          Method which modifies the record at specified position with specified data.
 boolean nextData()
          Not implemented.
 java.util.Vector nextRecord()
          Method which returns the next record with respect to current cursor position.
 java.util.Vector previousRecord()
          Method which returns the previous record with respect to current cursor position.
 void readExternal(java.io.ObjectInput in)
           
 void refreshData()
          Not implemented.
 void removeAll()
          Method which removes all records.
 void removeAt(int position)
          Method which removes a record from specified position.
 void removeDataListener(com.elj.data.dataprovider.text.DataListener listener)
          Not implemented.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
 void removeRange(int startPos, int endPos)
          Method which removes a range of records.
 void retrieve()
          Not implemented.
 void retrieve(java.lang.String[] args)
          Not implemented.
 void retrieveData(java.io.InputStream is)
          Method which retrieves the data from any input stream.
 boolean rollbackModifications()
          Not implemented.
 void save()
          Not implemented.
 void saveData(java.io.OutputStream os)
          Method which saves the data of this text data provider to any output stream.
 boolean saveModifications()
          Not implemented.
 java.util.Vector scrollToRow(int index)
          Method which scrolls the current cursor position at the specified index.
 void setColumnNames(java.util.Vector columnVector)
          Method which sets the column names for this text data provider.
 void setColumnSeparator(java.lang.String colSep)
          Method which sets the column separator for this text data provider.
 void setCurrentIndex(int pos)
          Method which sets the current cursor position.
 void setData(java.util.Vector data)
          Method which set the data for this text data provider.
 void setDataArray(java.util.Vector[] arrayData)
          Method which copies the records of this text data provider into specified array.
 void setDataProvider(com.elj.data.dataprovider.text.DataProvider dp)
           
 void setFilterState(boolean filterState)
          Not implemented.
 void sortData(int[] colIndex)
           
 void sortData(int[] colIndex, boolean[] ordering)
          Method which sorts the data.
 void sortData(int[] colIndex, boolean[] ordering, int startIndex, int endIndex)
          Method which sorts the data in a specified range.
 void sortData(int[] colIndex, int startIndex, int endIndex)
           
 void sortData(java.lang.String[] colName)
           
 void sortData(java.lang.String[] colName, boolean[] ordering)
          Method which sorts the data.
 void sortData(java.lang.String[] colName, boolean[] ordering, int startIndex, int endIndex)
          Method which sorts the data in a specified range.
 void sortData(java.lang.String[] colName, int startIndex, int endIndex)
           
 void undo()
          Not implemented.
 void writeExternal(java.io.ObjectOutput out)
           
 

Field Detail

changes

protected java.beans.PropertyChangeSupport changes

DEFAULT_COLUMN_SEPARATOR

public static java.lang.String DEFAULT_COLUMN_SEPARATOR
Constructor Detail

TextDataProvider

public TextDataProvider()
Constructs an empty text data provider with no. of rows = no. of columns = 0 and with default column separator (,).
Method Detail

retrieveData

public void retrieveData(java.io.InputStream is)
Method which retrieves the data from any input stream. It also set the cursor position to zero.
Parameters:
is - The input stream from which to retrieve the data.

saveData

public void saveData(java.io.OutputStream os)
Method which saves the data of this text data provider to any output stream.
Parameters:
os - The output stream to save the data to.

addRow

public void addRow(java.util.Vector vector)
Method which adds a record to the end of existing records. This method also set the cursor position to the index of last record.
Parameters:
vector - The vector which contains the record data.

deleteRow

public void deleteRow()
Method which deletes the current record. This method also decrements current cursor position.
Parameters:
vector - The vector which contains the record data.

save

public void save()
Not implemented.

undo

public void undo()
Not implemented.

firstRecord

public java.util.Vector firstRecord()
Method which returns the first record.
Returns:
The vector containing the data for first record.

lastRecord

public java.util.Vector lastRecord()
Method which returns the last record.
Returns:
The vector containing the data for last record.

nextRecord

public java.util.Vector nextRecord()
Method which returns the next record with respect to current cursor position. This method also increments current cursor position.
Returns:
The vector containing the data for next record, or null if no data found.

previousRecord

public java.util.Vector previousRecord()
Method which returns the previous record with respect to current cursor position. This method also decrements current cursor position.
Returns:
The vector containing the data for previous record, or null if no data found.

scrollToRow

public java.util.Vector scrollToRow(int index)
Method which scrolls the current cursor position at the specified index.
Parameters:
index - The index at which to scroll current cursor position.
Returns:
The vector containing the data of record at scrolled position.

refreshData

public void refreshData()
Not implemented.

nextData

public boolean nextData()
Not implemented.

getData

public java.util.Vector getData()
Method which returns the data vector.
Returns:
The data vector containing the data of this text data provider.

getDataAt

public java.util.Vector getDataAt(int recordIndex)
Method which returns the record at specified index.
Parameters:
recordIndex - The index of the record to be retrieved.
Returns:
The record vector containing the data.

getDataAt

public java.lang.Object getDataAt(int recordIndex,
                                  int columnIndex)
Method which returns the data at specified record and column index.
Parameters:
recordIndex - The index of the record.
columnIndex - The index of column for specified record index.
Returns:
The data at specified record and column index.

getDataCount

public int getDataCount()
Method which returns total number of records.
Returns:
Total number of records.

appendData

public int appendData(java.util.Vector rec)
Method which appends the record at the end of existing records.
Returns:
The index of this record.

insertDataAt

public int insertDataAt(java.util.Vector rec,
                        int position)
Method which inserts specified record at specified position.
Parameters:
rec - The vector containing the record data.
position - The position at which to insert the record.

modifyDataAt

public void modifyDataAt(java.util.Vector data,
                         int position)
Method which modifies the record at specified position with specified data.
Parameters:
data - The vector containing the record data.
position - The position of the record to be modified.

setData

public void setData(java.util.Vector data)
Method which set the data for this text data provider.
Parameters:
data - The vector containing the vectors of records.

setDataArray

public void setDataArray(java.util.Vector[] arrayData)
Method which copies the records of this text data provider into specified array.
Parameters:
arrayData - The array of vector into which the records will be copied.

removeAll

public void removeAll()
Method which removes all records.

removeAt

public void removeAt(int position)
Method which removes a record from specified position.
Parameters:
position - The position from which to remove a record.

removeRange

public void removeRange(int startPos,
                        int endPos)
Method which removes a range of records.
Parameters:
startPos - The start position.
endPos - The end position.

getTableCount

public int getTableCount()
Not implemented.

getTableNames

public java.util.Vector getTableNames()
Not implemented.

getColumnCount

public int getColumnCount()
Method which returns the column count.
Returns:
The column count.

getColumnNames

public java.util.Vector getColumnNames()
Method which returns the vector of column names.
Returns:
The vector of column names.

setColumnNames

public void setColumnNames(java.util.Vector columnVector)
Method which sets the column names for this text data provider.
Parameters:
columnVector - The vector of column names.

getColumnIndex

public int getColumnIndex(java.lang.String colName)
Method which returns index of specified column name.
Parameters:
colName - The column name whose index is to be returned.
Returns:
The index of specified column name.

getColumnType

public int getColumnType(int colIndex)
Method which returns type of specified column index.
Parameters:
colIndex - The column index whose type is to be returned.
Returns:
The type of specified column index.

getCurrentIndex

public int getCurrentIndex()
Method which returns the current cursor position.
Returns:
The current cursor position.

setCurrentIndex

public void setCurrentIndex(int pos)
Method which sets the current cursor position.
Parameters:
pos - The position to be set as current cursor position.

getCurrentRecord

public java.util.Vector getCurrentRecord()
Method which retrieves current record.
Returns:
The vector containing the data of current record.

retrieve

public void retrieve()
Not implemented.

retrieve

public void retrieve(java.lang.String[] args)
Not implemented.

setFilterState

public void setFilterState(boolean filterState)
Not implemented.

isFilterState

public boolean isFilterState()
Not implemented.

sortData

public void sortData(int[] colIndex)

sortData

public void sortData(java.lang.String[] colName)

sortData

public void sortData(int[] colIndex,
                     boolean[] ordering)
Method which sorts the data.
Parameters:
colIndex - The array containing indexes of columns to be sorted.
ordering - The array containing the order of sorting.

sortData

public void sortData(java.lang.String[] colName,
                     boolean[] ordering)
Method which sorts the data.
Parameters:
colName - The array containing names of columns to be sorted.
ordering - The array containing the order of sorting.

sortData

public void sortData(int[] colIndex,
                     int startIndex,
                     int endIndex)

sortData

public void sortData(int[] colIndex,
                     boolean[] ordering,
                     int startIndex,
                     int endIndex)
Method which sorts the data in a specified range.
Parameters:
colIndex - The array containing indexes of columns to be sorted.
ordering - The array containing the order of sorting.
startIndex - The start index.
endIndex - The end index

sortData

public void sortData(java.lang.String[] colName,
                     int startIndex,
                     int endIndex)

sortData

public void sortData(java.lang.String[] colName,
                     boolean[] ordering,
                     int startIndex,
                     int endIndex)
Method which sorts the data in a specified range.
Parameters:
colName - The array containing names of columns to be sorted.
ordering - The array containing the order of sorting.
startIndex - The start index.
endIndex - The end index

filterData

public void filterData(java.lang.String filterCriteria)
Not implemented.

find

public int find(java.lang.String condition,
                int startIndex,
                int endIndex)
Not implemented.

findNext

public int findNext()
Not implemented.

getModifiedCount

public int getModifiedCount()
Not implemented.

getFilteredCount

public int getFilteredCount()
Not implemented.

getDeletedCount

public int getDeletedCount()
Not implemented.

rollbackModifications

public boolean rollbackModifications()
Not implemented.

saveModifications

public boolean saveModifications()
Not implemented.

getColumnsArray

public java.lang.String[] getColumnsArray()

addDataListener

public void addDataListener(com.elj.data.dataprovider.text.DataListener listener)
Not implemented.

removeDataListener

public void removeDataListener(com.elj.data.dataprovider.text.DataListener listener)
Not implemented.

fireDataChanged

public void fireDataChanged(int eventId,
                            java.util.Hashtable oldValue,
                            java.util.Hashtable newValue)
Not implemented.

setColumnSeparator

public void setColumnSeparator(java.lang.String colSep)
Method which sets the column separator for this text data provider.
Parameters:
colSep - The column separator for this text data provider.

getColumnSeparator

public java.lang.String getColumnSeparator()
Method which returns the column separator for this text data provider.
Returns:
The column separator for this text data provider.

setDataProvider

public void setDataProvider(com.elj.data.dataprovider.text.DataProvider dp)

getDataProvider

public com.elj.data.dataprovider.text.DataProvider getDataProvider()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)