Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.stanford.genetics.treeview.model
Class FlatFileStreamTokenizer  view FlatFileStreamTokenizer download FlatFileStreamTokenizer.java

java.lang.Object
  extended byjava.io.StreamTokenizer
      extended byedu.stanford.genetics.treeview.model.FlatFileStreamTokenizer

public class FlatFileStreamTokenizer
extends java.io.StreamTokenizer

implements the "lexical structure" of flat files basically, calling nextToken returns a series of words, nulls and newlines, and finally an EOF. Note that numbers are not parsed by the tokenizer. Also, there is no enforcement of the correct number of tokens per line. it will, however, filter out blank lines.

Version:
$Revision: 1.1 $ $Date: 2003/09/23 17:43:47 $

Field Summary
private  boolean lastSep
           
private  int lines
           
static boolean printTokens
          Constant used for debugging
private  boolean pushedEOL
           
private  int saved
           
private  char sep
           
static int TT_NULL
          Constant signifying a null token
 
Fields inherited from class java.io.StreamTokenizer
nval, sval, TT_EOF, TT_EOL, TT_NUMBER, TT_WORD, ttype
 
Constructor Summary
FlatFileStreamTokenizer(java.io.Reader reader)
          Constructor for the FlatFileStreamTokenizer object.
FlatFileStreamTokenizer(java.io.Reader reader, char ch)
          Constructor for the FlatFileStreamTokenizer object
 
Method Summary
 int lineno()
          This method returns the current line number.
 int lines()
           
static void main(java.lang.String[] astring)
           
 int nextToken()
          Returns next token.
 void printToken()
          prints current token to System.out
 void pushBack()
          Pushes back current token to be read again.
 void setSeparator(char ch)
          Sets the separator attribute of the FlatFileStreamTokenizer object
 java.lang.String toString()
          This method returns the current token value as a String in the form "Token[x], line n", where 'n' is the current line numbers and 'x' is determined as follows.
 
Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lowerCaseMode, ordinaryChar, ordinaryChars, parseNumbers, quoteChar, resetSyntax, slashSlashComments, slashStarComments, whitespaceChars, wordChars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lines

private int lines

sep

private char sep

lastSep

private boolean lastSep

pushedEOL

private boolean pushedEOL

TT_NULL

public static final int TT_NULL
Constant signifying a null token

See Also:
Constant Field Values

printTokens

public static boolean printTokens
Constant used for debugging


saved

private int saved
Constructor Detail

FlatFileStreamTokenizer

public FlatFileStreamTokenizer(java.io.Reader reader,
                               char ch)
Constructor for the FlatFileStreamTokenizer object


FlatFileStreamTokenizer

public FlatFileStreamTokenizer(java.io.Reader reader)
Constructor for the FlatFileStreamTokenizer object. Defaults to tab-delimitted.

Method Detail

main

public static void main(java.lang.String[] astring)

setSeparator

public void setSeparator(char ch)
Sets the separator attribute of the FlatFileStreamTokenizer object


toString

public java.lang.String toString()
Description copied from class: java.io.StreamTokenizer
This method returns the current token value as a String in the form "Token[x], line n", where 'n' is the current line numbers and 'x' is determined as follows.

  • If no token has been read, then 'x' is "NOTHING" and 'n' is 0
  • If ttype is TT_EOF, then 'x' is "EOF"
  • If ttype is TT_EOL, then 'x' is "EOL"
  • If ttype is TT_WORD, then 'x' is sval
  • If ttype is TT_NUMBER, then 'x' is "n=strnval" where 'strnval' is String.valueOf(nval).
  • If ttype is a quote character, then 'x' is sval
  • For all other cases, 'x' is ttype


printToken

public void printToken()
prints current token to System.out


nextToken

public int nextToken()
              throws java.io.IOException
Returns next token. Multiple separators generate null tokens. So do ones at ends of lines.


pushBack

public void pushBack()
Pushes back current token to be read again.


lineno

public int lineno()
Description copied from class: java.io.StreamTokenizer
This method returns the current line number. Note that if the pushBack() method is called, it has no effect on the line number returned by this method.


lines

public int lines()