jimm.datavision.source.charsep
Class CharSepSource

java.lang.Object
  extended by jimm.datavision.source.DataSource
      extended by jimm.datavision.source.charsep.CharSepSource
All Implemented Interfaces:
Writeable

public class CharSepSource
extends DataSource

A data source for files whose lines are rows and columns are separated by a character.

Author:
Jim Menard, jimm@io.com

Field Summary
protected  java.util.ArrayList columns
           
protected static char DEFAULT_SEP_CHAR
           
protected  java.io.BufferedReader reader
           
protected  char sepChar
           
protected  java.lang.String sourceFilePath
           
 
Fields inherited from class jimm.datavision.source.DataSource
metadataURL, query, report
 
Constructor Summary
CharSepSource(Report report)
           
 
Method Summary
 void addColumn(Column col)
          This override not only remembers the column but also hands it to the query for cacheing.
 boolean alreadyUsedSourceFile()
          Returns true if this data source uses a file to retrieve data and and has already done so.
 boolean areRecordsSelectable()
          Used to enable/disable the "Select Records" menu item.
 boolean areRecordsSortable()
          Used to enable/disable the "Sort By" menu item.
 boolean canGroupRecords()
          Used to enable/disable the "Group By" menu item.
 boolean canJoinTables()
          Used to enable/disable the "Table Linker" menu item.
(package private)  void closeReader()
           
 java.util.Iterator columns()
          Returns an iterator over all columns.
protected  void doWriteXML(XMLWriter out)
          Writes this database and all its tables as an XML tag.
 DataCursor execute()
           
 Column findColumn(java.lang.Object id)
          Given an id (a column name), returns the column that has that id.
(package private)  java.io.BufferedReader getReader()
           
 char getSepChar()
           
 java.lang.String getSourceFile()
          Gets the path to a data source file.
 int indexOfSelectable(Selectable sel)
          Returns the index of the specified selectable.
 boolean isConnectionEditable()
          Used to enable/disable the "Connection" menu item.
 boolean isSQLGenerated()
          Used to enable/disable the "SQL Query Text" menu item.
 boolean needsSourceFile()
          Returns true if this data source uses a file to retrieve data and does not yet have one.
 void reuseSourceFile()
          Tells this data source to re-use (perhaps re-open) the current data source file.
 void setInput(java.io.InputStreamReader inputStreamReader)
           
 void setInput(java.io.Reader reader)
           
 void setInput(java.lang.String fileName)
           
 void setSepChar(char c)
           
 void setSourceFile(java.lang.String filePath)
          Accepts the path to a data source file.
 java.util.Iterator tables()
          Returns an iterator over all tables, or null if the data source does not have tables (for example, a character-separated file data source).
 java.util.Iterator tablesUsedInReport()
          Returns an iterator over all tables actually used in the report, or null if the data source does not have tables (for example, a character-separated file data source).
 boolean usesSourceFile()
          Returns true if this data source uses a file to retrieve data.
 
Methods inherited from class jimm.datavision.source.DataSource
canRunReports, columnsInTablesUsedInReport, containsReferenceTo, getQuery, getReport, readMetadataFrom, reloadColumns, removeSort, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEP_CHAR

protected static final char DEFAULT_SEP_CHAR
See Also:
Constant Field Values

columns

protected java.util.ArrayList columns

sepChar

protected char sepChar

reader

protected java.io.BufferedReader reader

sourceFilePath

protected java.lang.String sourceFilePath
Constructor Detail

CharSepSource

public CharSepSource(Report report)
Method Detail

canJoinTables

public boolean canJoinTables()
Description copied from class: DataSource
Used to enable/disable the "Table Linker" menu item.

Specified by:
canJoinTables in class DataSource
Returns:
true if the "Table Linker" menu item should be enabled.

isSQLGenerated

public boolean isSQLGenerated()
Description copied from class: DataSource
Used to enable/disable the "SQL Query Text" menu item.

Specified by:
isSQLGenerated in class DataSource
Returns:
true if the "SQL Query Text" menu item should be enabled.

isConnectionEditable

public boolean isConnectionEditable()
Description copied from class: DataSource
Used to enable/disable the "Connection" menu item.

Specified by:
isConnectionEditable in class DataSource
Returns:
true if the "Connection" menu item should be enabled.

areRecordsSelectable

public boolean areRecordsSelectable()
Description copied from class: DataSource
Used to enable/disable the "Select Records" menu item.

Specified by:
areRecordsSelectable in class DataSource
Returns:
true if the "Select Records" menu item should be enabled.

areRecordsSortable

public boolean areRecordsSortable()
Description copied from class: DataSource
Used to enable/disable the "Sort By" menu item.

Specified by:
areRecordsSortable in class DataSource
Returns:
true if the "Sort By" menu item should be enabled.

canGroupRecords

public boolean canGroupRecords()
Description copied from class: DataSource
Used to enable/disable the "Group By" menu item.

Specified by:
canGroupRecords in class DataSource
Returns:
true if the "Group By" menu item should be enabled.

usesSourceFile

public boolean usesSourceFile()
Description copied from class: DataSource
Returns true if this data source uses a file to retrieve data. The default implementation returns false.

Overrides:
usesSourceFile in class DataSource
Returns:
true if this data source uses a file to retrieve data

needsSourceFile

public boolean needsSourceFile()
Description copied from class: DataSource
Returns true if this data source uses a file to retrieve data and does not yet have one. The default implementation returns false.

Overrides:
needsSourceFile in class DataSource
Returns:
true if this data source uses a file to retrieve data and doesn't yet have one

alreadyUsedSourceFile

public boolean alreadyUsedSourceFile()
Description copied from class: DataSource
Returns true if this data source uses a file to retrieve data and and has already done so. The default implementation returns false.

Overrides:
alreadyUsedSourceFile in class DataSource
Returns:
true if this data source uses a file to retrieve data

getSourceFile

public java.lang.String getSourceFile()
Description copied from class: DataSource
Gets the path to a data source file. The default implementation returns null.

Overrides:
getSourceFile in class DataSource
Returns:
The full path to a file

setSourceFile

public void setSourceFile(java.lang.String filePath)
                   throws java.io.FileNotFoundException
Description copied from class: DataSource
Accepts the path to a data source file. The default implementation does nothing.

Overrides:
setSourceFile in class DataSource
Parameters:
filePath - the full path to a file
Throws:
java.io.FileNotFoundException

reuseSourceFile

public void reuseSourceFile()
                     throws java.io.FileNotFoundException
Description copied from class: DataSource
Tells this data source to re-use (perhaps re-open) the current data source file. The default implementation does nothing.

Overrides:
reuseSourceFile in class DataSource
Throws:
java.io.FileNotFoundException

setInput

public void setInput(java.io.Reader reader)

setInput

public void setInput(java.io.InputStreamReader inputStreamReader)

setInput

public void setInput(java.lang.String fileName)
              throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

getSepChar

public char getSepChar()

setSepChar

public void setSepChar(char c)

addColumn

public void addColumn(Column col)
This override not only remembers the column but also hands it to the query for cacheing.

Overrides:
addColumn in class DataSource
Parameters:
col - a column

findColumn

public Column findColumn(java.lang.Object id)
Given an id (a column name), returns the column that has that id. If no column with the specified id exists, returns null. Uses Table.findColumn.

Specified by:
findColumn in class DataSource
Parameters:
id - a column id
Returns:
a column, or null if no column with the specified id exists
See Also:
Table.findColumn(java.lang.Object)

indexOfSelectable

public int indexOfSelectable(Selectable sel)
Description copied from class: DataSource
Returns the index of the specified selectable.

Overrides:
indexOfSelectable in class DataSource
Parameters:
sel - a selectable

tables

public java.util.Iterator tables()
Description copied from class: DataSource
Returns an iterator over all tables, or null if the data source does not have tables (for example, a character-separated file data source).

Specified by:
tables in class DataSource
Returns:
a possibly null iterator over all tables

tablesUsedInReport

public java.util.Iterator tablesUsedInReport()
Description copied from class: DataSource
Returns an iterator over all tables actually used in the report, or null if the data source does not have tables (for example, a character-separated file data source).

Specified by:
tablesUsedInReport in class DataSource
Returns:
a possibly null iterator over all tables used in the report

columns

public java.util.Iterator columns()
Description copied from class: DataSource
Returns an iterator over all columns.

Specified by:
columns in class DataSource
Returns:
an iterator over all columns

execute

public DataCursor execute()
Specified by:
execute in class DataSource

getReader

java.io.BufferedReader getReader()

closeReader

void closeReader()

doWriteXML

protected void doWriteXML(XMLWriter out)
Writes this database and all its tables as an XML tag.

Specified by:
doWriteXML in class DataSource
Parameters:
out - a writer that knows how to write XML