|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.util.transforms.CSVStreamToTableModelTransform
public class CSVStreamToTableModelTransform
The CSVStreamToTableModelTransform allows a CSV stream (from a file or other source) to be read in and converted into a model for JTable (or any other viewer which uses a TableModel as its model).
The current implementation reads the entire contents of the CSV stream and creates a DefaultTableModel with the data.
CSVStreamToTableModelTransform transform = new CSVStreamToTableModelTransform(); TableModel model = transform.transform( new FileInputStream( "c:\\file.csv" ) ); TableView tableView = new TableView(); tableView.setCellSpacing(0); tableView.setCellPadding(2); tableView.setBorderWidth(1); tableView.setColumnHeaderVisible(true); tableView.setModel( model ); tableView.write( writer );
| Field Summary | |
|---|---|
protected java.lang.String[] |
columnHeaders
|
protected java.lang.String |
delimiters
|
protected java.lang.String |
encoding
|
protected static java.lang.String |
localeDefaultDelimiter
|
| Constructor Summary | |
|---|---|
CSVStreamToTableModelTransform()
Default constructor which uses the default comma delimiter. |
|
CSVStreamToTableModelTransform(java.lang.String delimiters)
Constructor which allows the delimiters to be specified. |
|
CSVStreamToTableModelTransform(java.lang.String[] columnHeaders,
java.lang.String delimiters,
java.lang.String encoding)
Constructor which allows the column headersm, delimiters and encoding to be specified. |
|
CSVStreamToTableModelTransform(java.lang.String delimiters,
java.lang.String encoding)
Constructor which allows the delimiters to be specified. |
|
| Method Summary | |
|---|---|
protected java.lang.String[] |
parseLineToArray(java.lang.String line)
Parse a single delimited line into an array of Strings. |
java.lang.Object |
transform(java.lang.Object input)
Creates a DefaultTableModel which contains the contents of the CSV stream. |
| Field Detail |
|---|
protected static final java.lang.String localeDefaultDelimiter
protected java.lang.String delimiters
protected java.lang.String encoding
protected java.lang.String[] columnHeaders
| Constructor Detail |
|---|
public CSVStreamToTableModelTransform()
public CSVStreamToTableModelTransform(java.lang.String delimiters)
delimiters - A string containing the characters used to delimit values on each line. null
indicates that the default delimiters will be used.
public CSVStreamToTableModelTransform(java.lang.String delimiters,
java.lang.String encoding)
delimiters - A string containing the characters used to delimit values on each line. null
indicates that the default delimiters will be used.encoding - The encoding to use with the InputStreamReader when reading the stream. null
indicates that the default encoding for the JRE will be used.
public CSVStreamToTableModelTransform(java.lang.String[] columnHeaders,
java.lang.String delimiters,
java.lang.String encoding)
columnHeaders - The text to use for each of the column headings. If null, the
first line of the CSV stream will be used as the column headers.delimiters - A string containing the characters used to delimit values on each line. null
indicates that the default delimiters will be used.encoding - The encoding to use with the InputStreamReader when reading the stream. null
indicates that the default encoding for the JRE will be used.| Method Detail |
|---|
public java.lang.Object transform(java.lang.Object input)
throws com.sas.util.transforms.TransformException
transform in interface com.sas.util.transforms.TransformInterfacecom.sas.util.transforms.TransformExceptionprotected java.lang.String[] parseLineToArray(java.lang.String line)
line - The line of text to parse the row of values from.
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||