Package jahuwaldt.js.datareader
Interface DataReader
-
- All Superinterfaces:
java.lang.Comparable<DataReader>
- All Known Implementing Classes:
TabDataReader
,TREETOPSDataReader
public interface DataReader extends java.lang.Comparable<DataReader>
This class provides a standard interface for reading and writing data files of various formats. Sub-classes actually do the translation from the data file's format to the DataSet data structure in memory and vise versa.Modified by: Joseph A. Huwaldt
- Version:
- October 15, 2015
- Author:
- Joseph A. Huwaldt, Date: March 6, 2003
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAYBE
Constant indicating that a reader might be able to read a specified file stream, but can't determine for sure.static int
NO
Constant indicating that a reader can not read a specified file stream.static java.util.ResourceBundle
RESOURCES
The resource bundle for this package.static int
YES
Constant indicating that a reader can certainly read a specified file stream.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
canReadData(java.lang.String pathName, java.io.BufferedInputStream input)
Method that determines if this reader can read data from the specified input stream.boolean
canWriteData()
Returns true if this class can write at least some data in the format supported by this class.java.lang.String
getExtension()
Returns the preferred file extension (not including the ".") for files of this DataReader's type.java.util.List<DataSet>
read(java.lang.String pathName, java.io.InputStream input)
Interface for reading in data from an input stream and returning that data as a list ofDataSet
objects.java.util.List<DataSet>
selectDataForSaving(java.awt.Frame parent, java.util.List<DataSet> data)
Returns a data structure that contains the data in the input list filtered in whatever way is necessary to save it using a particular format.void
setDefaultSetName(java.lang.CharSequence name)
Sets the default set name to use for data formats that do not have named data sets.void
write(java.io.OutputStream output, java.util.List<DataSet> data)
Interface for writing out all the data stored in the specified list ofDataSet
objects to the specified output stream.
-
-
-
Field Detail
-
RESOURCES
static final java.util.ResourceBundle RESOURCES
The resource bundle for this package.
-
NO
static final int NO
Constant indicating that a reader can not read a specified file stream.- See Also:
- Constant Field Values
-
YES
static final int YES
Constant indicating that a reader can certainly read a specified file stream.- See Also:
- Constant Field Values
-
MAYBE
static final int MAYBE
Constant indicating that a reader might be able to read a specified file stream, but can't determine for sure.- See Also:
- Constant Field Values
-
-
Method Detail
-
read
java.util.List<DataSet> read(java.lang.String pathName, java.io.InputStream input) throws java.io.IOException
Interface for reading in data from an input stream and returning that data as a list ofDataSet
objects.- Parameters:
pathName
- The path to the file to be read.input
- An input stream containing the data to be read.- Returns:
- A list of DataSet objects that contain the data read in from the specified stream.
- Throws:
java.lang.Exception
- If there is a problem reading the specified stream.java.io.IOException
-
write
void write(java.io.OutputStream output, java.util.List<DataSet> data) throws java.io.IOException
Interface for writing out all the data stored in the specified list ofDataSet
objects to the specified output stream.- Parameters:
output
- The output stream to which the data is to be written.data
- The list of DataSet objects to be written out.- Throws:
java.io.IOException
- If there is a problem writing to the specified stream.
-
setDefaultSetName
void setDefaultSetName(java.lang.CharSequence name)
Sets the default set name to use for data formats that do not have named data sets.
-
canReadData
int canReadData(java.lang.String pathName, java.io.BufferedInputStream input) throws java.io.IOException
Method that determines if this reader can read data from the specified input stream.- Parameters:
pathName
- The path to the file to be read.input
- An input stream containing the data to be read. Any methods that read from this stream must first set a mark and then reset back to that mark before the method returns (even if it returns with an exception).- Returns:
- DataReader.NO if the file format is not recognized by this reader. DataReader.YES if the file format is definitely recognized by this reader. DataReader.MAYBE if the file format might be readable by this reader, but that can't easily be determined without actually reading the file.
- Throws:
java.io.IOException
-
canWriteData
boolean canWriteData()
Returns true if this class can write at least some data in the format supported by this class. Returns false if it can not.
-
selectDataForSaving
java.util.List<DataSet> selectDataForSaving(java.awt.Frame parent, java.util.List<DataSet> data)
Returns a data structure that contains the data in the input list filtered in whatever way is necessary to save it using a particular format. This is done by applying rules and/or by asking the user to choose what data should be saved. The requirements for what can be saved is specific to each format.- Parameters:
parent
- Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used.data
- The input data set that is to be selected for saving.- Returns:
- A list of DataSet objects containing the selected data to be saved. If this DataReader does not supporting saving, then null is returned.
-
getExtension
java.lang.String getExtension()
Returns the preferred file extension (not including the ".") for files of this DataReader's type.
-
-