lt.monarch.data.binding
Class TextFileDataSource

java.lang.Object
  extended by lt.monarch.data.binding.DataSource
      extended by lt.monarch.data.binding.TextFileDataSource
All Implemented Interfaces:
Filterable

public class TextFileDataSource
extends DataSource
implements Filterable

Class used to retrieve data from text file and store it in the given DataModel object. Data in text file must be separated by delimiters.


Field Summary
Modifier and Type Field and Description
 
Fields inherited from class lt.monarch.data.binding.DataSource
order
 
Constructor Summary
Constructor and Description
TextFileDataSource(java.io.File dataFile, java.lang.String dataDelimeters)
          DataSource object with the data file.
TextFileDataSource(java.lang.String dataFilePath, java.lang.String dataDelimeters)
          DataSource object with the path to the data file.
TextFileDataSource(java.net.URL dataFileURL, java.lang.String dataDelimeters)
          DataSource object with the data file.
 
Method Summary
Modifier and Type Method and Description
 java.io.File getDataFile()
          Return data file, if was set File or file path
 java.lang.String getDataFilePath()
          Returns path to data file, if was set File or file path
 java.net.URL getDataFileURL()
          Return data file URL
 java.text.DateFormat getDateFormat()
          Return format of DATETIME type
 java.lang.String getDelimeters()
           
 java.lang.String getFilterCondition()
          Unused for TextFileDataSource
 java.lang.Integer getLimit()
          Returns result limit
 int getStartRecord()
          Return index of the first record.
 boolean isFirstRowAsLabels()
          Shows if the first row in data file is treated as a row with the column labels
 void setDataFile(java.io.File dataFile)
          Sets file that will be used as a data source.
 void setDataFilePath(java.lang.String dataFilePath)
          Sets path to data file that will be used as a data source.
 void setDataFileURL(java.net.URL dataFileURL)
          Sets file URL that will be used as a data source.
 void setDateFormat(java.text.DateFormat dateFormatter)
          Set format of DATETIME type (default: "dd-MM-yyyy")
 void setDelimeters(java.lang.String delimeters)
          Sets delimiters that indicate how data in text file is separated.
 void setFilterCondition(java.lang.String condition)
          Unused for TextFileDataSource
 void setFirstRowAsLabels(boolean b)
          Sets firstRowAsLabels attribute's value.
 void setLimit(java.lang.Integer size)
          Sets limit for results.
 void setStartRecord(int index)
          Sets index of the first record that should be retrieved.
 void updateDataModel(DataBinding binding, DataModel model)
          Retrieves data according to DataBinding object form data source and stores it in DataModel object.
 
Methods inherited from class lt.monarch.data.binding.DataSource
generateColumnTypesFromMappings, getOrder, setOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFileDataSource

public TextFileDataSource(java.lang.String dataFilePath,
                          java.lang.String dataDelimeters)
                   throws java.io.FileNotFoundException,
                          java.net.MalformedURLException
DataSource object with the path to the data file. This object is used to retrieve data from text file and store it in chart's DataModel object.

Parameters:
dataFilePath - Path to data file
dataDelimeters - Delimiters that are used to separate data fields in the given file
Throws:
java.io.FileNotFoundException
java.net.MalformedURLException

TextFileDataSource

public TextFileDataSource(java.io.File dataFile,
                          java.lang.String dataDelimeters)
                   throws java.io.FileNotFoundException,
                          java.net.MalformedURLException
DataSource object with the data file. This object is used to retrieve data from text file and store it in chart's DataModel object.

Parameters:
dataFile - Data file
dataDelimeters - Delimiters that are used to separate data fields in the given file
Throws:
java.io.FileNotFoundException
java.net.MalformedURLException

TextFileDataSource

public TextFileDataSource(java.net.URL dataFileURL,
                          java.lang.String dataDelimeters)
DataSource object with the data file. This object is used to retrieve data from text file and store it in chart's DataModel object.

Parameters:
dataFileURL - Data file URL
dataDelimeters - Delimiters that are used to separate data fields in the given file
Method Detail

updateDataModel

public void updateDataModel(DataBinding binding,
                            DataModel model)
Description copied from class: DataSource
Retrieves data according to DataBinding object form data source and stores it in DataModel object.

Specified by:
updateDataModel in class DataSource
Parameters:
binding - DataBinding describes the data that should be taken form data source
model - DataModel which values should be updated

getLimit

public java.lang.Integer getLimit()
Description copied from interface: Filterable
Returns result limit

Specified by:
getLimit in interface Filterable
Returns:

getStartRecord

public int getStartRecord()
Description copied from interface: Filterable
Return index of the first record. Default is 0.

Specified by:
getStartRecord in interface Filterable
Returns:
Index of the first record in data source.

setLimit

public void setLimit(java.lang.Integer size)
Description copied from interface: Filterable
Sets limit for results. Default value is null - this means that all values from data source should be retrieved. If the concrete value is set then DataSource will retrieve not more than the given amount of data. For example, if limit is set to 4 then DataSource will retrieve maximum 4 result rows.

Specified by:
setLimit in interface Filterable

setStartRecord

public void setStartRecord(int index)
Description copied from interface: Filterable
Sets index of the first record that should be retrieved. For example, if startRecord=3 then DataSource will skip rows with the index 0, 1 or 2 and will start reading from the row with the index 3.

Specified by:
setStartRecord in interface Filterable
Parameters:
index - first record index

getFilterCondition

public java.lang.String getFilterCondition()
Unused for TextFileDataSource

Specified by:
getFilterCondition in interface Filterable
Returns:
String value showing additional conditions to the filter

setFilterCondition

public void setFilterCondition(java.lang.String condition)
Unused for TextFileDataSource

Specified by:
setFilterCondition in interface Filterable
Parameters:
condition - Filter conditions

setFirstRowAsLabels

public void setFirstRowAsLabels(boolean b)
Sets firstRowAsLabels attribute's value. If firstRowAsLabels is set to true than first data row is read as data set's column labels.

Parameters:
b - boolean value

isFirstRowAsLabels

public boolean isFirstRowAsLabels()
Shows if the first row in data file is treated as a row with the column labels

Returns:
Boolean value indicating first row as a labels row

getDataFile

public java.io.File getDataFile()
Return data file, if was set File or file path

Returns:
File that is used as a data source

setDataFile

public void setDataFile(java.io.File dataFile)
                 throws java.io.FileNotFoundException,
                        java.net.MalformedURLException
Sets file that will be used as a data source.

Parameters:
dataFile -
Throws:
java.io.FileNotFoundException
java.net.MalformedURLException

getDataFilePath

public java.lang.String getDataFilePath()
Returns path to data file, if was set File or file path

Returns:
Path to data file

setDataFilePath

public void setDataFilePath(java.lang.String dataFilePath)
                     throws java.io.FileNotFoundException,
                            java.net.MalformedURLException
Sets path to data file that will be used as a data source.

Parameters:
dataFilePath - String path to data file
Throws:
java.io.FileNotFoundException
java.net.MalformedURLException

getDelimeters

public java.lang.String getDelimeters()

setDelimeters

public void setDelimeters(java.lang.String delimeters)
Sets delimiters that indicate how data in text file is separated. For example, ",;" will separated text row ";foo,boo;mpp" into columns String[]{"", "foo", "boo", "moo"}.

Parameters:
delimeters -

getDateFormat

public java.text.DateFormat getDateFormat()
Return format of DATETIME type

Returns:
the dateFormat

setDateFormat

public void setDateFormat(java.text.DateFormat dateFormatter)
Set format of DATETIME type (default: "dd-MM-yyyy")

Parameters:
dateFormat - the dateFormat to set

getDataFileURL

public java.net.URL getDataFileURL()
Return data file URL

Returns:
URL that is used as a data source

setDataFileURL

public void setDataFileURL(java.net.URL dataFileURL)
Sets file URL that will be used as a data source.

Parameters:
dataFileURL -