JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table.data
Class JCInputStreamDataSource

java.lang.Object
  |
  +--com.klg.jclass.table.data.AbstractDataSource
        |
        +--com.klg.jclass.table.data.AbstractVectorDataSource
              |
              +--com.klg.jclass.table.data.JCVectorDataSource
                    |
                    +--com.klg.jclass.table.data.JCInputStreamDataSource
All Implemented Interfaces:
JCTableDataModel, Serializable, TableDataModel
Direct Known Subclasses:
JCAppletDataSource, JCBeanFileDataSource, JCFileDataSource, JCURLDataSource

public class JCInputStreamDataSource
extends JCVectorDataSource
implements Serializable

This class is the base for any data source that relies on input from some stream, which includes files, URLs, large Strings, etc.

Since:
JClass 4.0K for Java 2. If you are using JClass 4.0J, which is based on JDK 1.1, some of the return types for this class' fields or methods are based on the corresponding com.sun.java.util class.
See Also:
TableDataModel, Serialized Form

Field Summary
protected  com.klg.jclass.table.data.JCFileFormatParser customParser
           
protected  int dataFormat
           
 
Fields inherited from class com.klg.jclass.table.data.JCVectorDataSource
cells, column_labels, columns, is_moving, row_labels, rows
 
Fields inherited from class com.klg.jclass.table.data.AbstractDataSource
listeners
 
Constructor Summary
protected JCInputStreamDataSource()
          Subclasses may need to set the stream up before they can call super(), so provide a default ctor and the ctor() function to replace the super() call (for example, JCAppletDataSource).
  JCInputStreamDataSource(InputStream i)
          The constructor takes the InputStream and reads in all the appropriate data.
  JCInputStreamDataSource(InputStream i, int newFormat)
          The constructor takes the InputStream and reads in all the appropriate data.
  JCInputStreamDataSource(InputStream i, com.klg.jclass.table.data.JCFileFormatParser prs)
          The constructor takes the InputStream and reads in all the appropriate data according to the specified parser.
 
Method Summary
static int detectFileFormat(Reader r)
          Global method for detecting the format of a file.
 com.klg.jclass.table.data.JCFileFormatParser getCustomParser()
          Gets the value of the CustomParser property.
 int getDataFormat()
          Gets the value of the DataFormat property.
protected  void read(Reader r)
          Reads and parses data from the reader, and places it inside the current data source.
protected  void readFromStream(InputStream i)
          Reads data from an InputStream.
 void setCustomParser(com.klg.jclass.table.data.JCFileFormatParser newParser)
          Sets the value of the CustomParser property.
 void setDataFormat(int newFormat)
          Sets the value of the DataFormat property.
 
Methods inherited from class com.klg.jclass.table.data.JCVectorDataSource
addColumn, addColumn, addRow, addRow, clearCells, deleteColumns, deleteColumns, deleteRows, deleteRows, getCells, getColumnLabels, getLabelValue, getNumColumns, getNumRows, getRowLabels, getTableColumnLabel, getTableDataItem, getTableRowLabel, isCell, isColumnLabel, isLabel, isRowLabel, isValidCell, isValidLabel, moveColumns, moveColumns, moveRows, moveRows, setCell, setCells, setCells, setColumnLabel, setColumnLabels, setColumnLabels, setDataChanged, setLabelValue, setNumColumns, setNumRows, setRowLabel, setRowLabels, setRowLabels
 
Methods inherited from class com.klg.jclass.table.data.AbstractVectorDataSource
createVector, createVector, createVector, createVector, createVector, removeElementsAt, setElementAt, strip
 
Methods inherited from class com.klg.jclass.table.data.AbstractDataSource
addTableDataListener, dispose, fireColumnChanged, fireColumnLabelChanged, fireColumnsAdded, fireColumnsDeleted, fireColumnsMoved, fireDataReset, fireNumColumnsChanged, fireNumRowsChanged, fireRowChanged, fireRowDeleted, fireRowLabelChanged, fireRowsAdded, fireRowsMoved, fireTableDataEvent, fireValueChanged, hasListeners, removeTableDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataFormat

protected int dataFormat

customParser

protected com.klg.jclass.table.data.JCFileFormatParser customParser
Constructor Detail

JCInputStreamDataSource

public JCInputStreamDataSource(InputStream i)
                        throws IOException
The constructor takes the InputStream and reads in all the appropriate data.

Parameters:
i -
Throws:
IOException - An IOException will be thrown if there are any errors while reading in the data.

JCInputStreamDataSource

public JCInputStreamDataSource(InputStream i,
                               int newFormat)
                        throws IOException
The constructor takes the InputStream and reads in all the appropriate data.

Parameters:
i - Open input stream
newFormat - Data format; one of STANDARD or CSV
Throws:
IOException - An IOException will be thrown if there are any errors while reading in the data.

JCInputStreamDataSource

public JCInputStreamDataSource(InputStream i,
                               com.klg.jclass.table.data.JCFileFormatParser prs)
                        throws IOException
The constructor takes the InputStream and reads in all the appropriate data according to the specified parser.

Parameters:
i - open input stream
prs - custom parser for this data format
Throws:
IOException - An IOException will be thrown if there are any errors while reading in the data.

JCInputStreamDataSource

protected JCInputStreamDataSource()
Subclasses may need to set the stream up before they can call super(), so provide a default ctor and the ctor() function to replace the super() call (for example, JCAppletDataSource).

Method Detail

getDataFormat

public int getDataFormat()
Gets the value of the DataFormat property. The DataFormat property determines how data will be parsed by this data source. Valid options include STANDARD (for table-style format), CSV (for comma-separated values), and CUSTOM (for custom formats parsed by a user provided parser).

Returns:
one of JCTableEnum.STANDARD, JCTableEnum.CSV, or JCTableEnum.CUSTOM

setDataFormat

public void setDataFormat(int newFormat)
Sets the value of the DataFormat property. The DataFormat property determines how data will be parsed by this data source. Valid options include STANDARD (for table-style format), CSV (for comma-separated values), and CUSTOM (for custom formats parsed by a user provided parser).

Parameters:
newFormat - one of JCTableEnum.STANDARD, JCTableEnum.CSV, or JCTableEnum.CUSTOM

getCustomParser

public com.klg.jclass.table.data.JCFileFormatParser getCustomParser()
Gets the value of the CustomParser property. The CustomParser property identifies the parser to be used when the DataFormat property has been set to CUSTOM. The value of this property must be a class that has implemented the JCFileFormatParser interface.

Returns:
the class implementing JCFileFormatParser that will be used to parse data

setCustomParser

public void setCustomParser(com.klg.jclass.table.data.JCFileFormatParser newParser)
Sets the value of the CustomParser property. The CustomParser property identifies the parser to be used when the DataFormat property has been set to CUSTOM. The value of this property must be a class that has implemented the JCFileFormatParser interface.

Parameters:
newParser - the class implementing JCFileFormatParser that will be used to parse data

readFromStream

protected void readFromStream(InputStream i)
                       throws IOException
Reads data from an InputStream.

Parameters:
i -
Throws:
IOException

read

protected void read(Reader r)
             throws IOException
Reads and parses data from the reader, and places it inside the current data source.

Parameters:
r -
Throws:
IOException

detectFileFormat

public static int detectFileFormat(Reader r)
Global method for detecting the format of a file.

Parameters:
r -
Returns:

Copyright © 2004 Quest Software Inc..
All rights reserved.