JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table.data
Class JCStandardFormatParser

java.lang.Object
  |
  +--com.klg.jclass.table.data.JCStandardFormatParser
All Implemented Interfaces:
JCFileFormatParser

public class JCStandardFormatParser
extends Object
implements JCFileFormatParser

This class takes in a stream of data and parses it under the assumption it is in "standard" LiveTable format. It then puts the data into a JCVectorDataSource instance.

The standard LiveTable format looks like this:

 TABLE 2 4 NOLABEL # 2 rows, 4 columns
 1 2 3 4           # row 1
 1 2 3 4           # row 2
Or, with row and column labels,
 TABLE 2 4
         'Column 1' 'Column 2' 'Column 3' 'Column 4'
 'Row 1' 1          2          3          4
 'Row 2' 1          4          9          16
 'Row 3' 1          16         81         256
 


Field Summary
protected  boolean isDebug
          Flag indicating whether parsing is in debug mode, which turns on error messages on error out.
protected  boolean isLabels
          Flag indicating whether data source has labels.
static int PARSE_ERR_COLUMN_LABEL
          Enum representing a parsing error involving column labels.
static int PARSE_ERR_DATA_STYLE
          Enum representing a parsing error involving data.
static int PARSE_ERR_ROW_LABEL
          Enum representing a parsing error involving row labels.
static int PARSE_ERR_VALUE
          Enum representing a parsing error involving data values.
protected  StreamTokenizer tokenizer
          Stream tokenizer used to parse input stream.
 
Constructor Summary
JCStandardFormatParser()
           
 
Method Summary
protected static void displayErrorMessage(StreamTokenizer tokenizer, int nErrorIndex)
          A method to display a parsing error message based on an enum value.
protected static double getNextDouble(StreamTokenizer tokenizer)
          Reads the next double value.
protected  void initTokenizer(Reader r)
          Creates and sets up a valid tokenizer active on the provided stream.
 void readAndParse(Reader r, com.klg.jclass.table.data.JCVectorDataSource ds)
          Reads and parses data in standard format and places it inside a LiveTable data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenizer

protected StreamTokenizer tokenizer
Stream tokenizer used to parse input stream.


PARSE_ERR_DATA_STYLE

public static final int PARSE_ERR_DATA_STYLE
Enum representing a parsing error involving data.

See Also:
Constant Field Values

PARSE_ERR_VALUE

public static final int PARSE_ERR_VALUE
Enum representing a parsing error involving data values.

See Also:
Constant Field Values

PARSE_ERR_COLUMN_LABEL

public static final int PARSE_ERR_COLUMN_LABEL
Enum representing a parsing error involving column labels.

See Also:
Constant Field Values

PARSE_ERR_ROW_LABEL

public static final int PARSE_ERR_ROW_LABEL
Enum representing a parsing error involving row labels.

See Also:
Constant Field Values

isDebug

protected boolean isDebug
Flag indicating whether parsing is in debug mode, which turns on error messages on error out.


isLabels

protected boolean isLabels
Flag indicating whether data source has labels.

Constructor Detail

JCStandardFormatParser

public JCStandardFormatParser()
Method Detail

initTokenizer

protected void initTokenizer(Reader r)
Creates and sets up a valid tokenizer active on the provided stream.

Parameters:
r - reader open on an active stream

readAndParse

public void readAndParse(Reader r,
                         com.klg.jclass.table.data.JCVectorDataSource ds)
                  throws IOException
Reads and parses data in standard format and places it inside a LiveTable data source.

Specified by:
readAndParse in interface JCFileFormatParser
Parameters:
r - reader open on an active stream
ds - JCVectorDataSource instance to act as a container for the data read in from r
Throws:
IOException

getNextDouble

protected static double getNextDouble(StreamTokenizer tokenizer)
                               throws IOException
Reads the next double value.

Parameters:
tokenizer -
Returns:
Throws:
IOException

displayErrorMessage

protected static void displayErrorMessage(StreamTokenizer tokenizer,
                                          int nErrorIndex)
A method to display a parsing error message based on an enum value.

Parameters:
tokenizer -
nErrorIndex -
See Also:
JCFormatParserUtil.displayErrorMessage(java.io.StreamTokenizer, java.lang.String)

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