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

Quick Search    Search Deep

org.pqt.autorib.tokenizer
Class Tokenizer  view Tokenizer download Tokenizer.java

java.lang.Object
  extended byorg.pqt.autorib.tokenizer.Tokenizer

public class Tokenizer
extends java.lang.Object

Reads Characters from a given stream, ignoring comments . It recognises the following kinds of input (which can be stored in a Token object):

- a word;

- a number;

- a string (delimeted by "") comment characters are not recognized inside a string - but an error is raised if a newline is read

- an array of numbers (enclosed in [])

This class is not used directly - rather its subclasses RIBTokenizer and InstrTokenizer are used. The advantage of having this common superclass is that it makes it comparatively easy to read RIB from an instructions file.

A count of the current line number is maintained, to allow this to be used in error reporting

Version:
$Header: /home/CVSRepository/autoribnew/org/pqt/autorib/tokenizer/Tokenizer.java,v 1.5 2003/12/02 17:10:52 remote Exp $

Field Summary
 java.io.Reader f
          the reader for the file
 java.lang.String fileName
          the file name this tokenizer is attached to
protected  boolean pushedBack
          true if there is a token that has been pushed back into the buffer and is ready for reading (i.e is in the variable token)
 java.io.StreamTokenizer t
          a stream tokenizer to read the file
 Token token
          the most recently read Token
protected  int tokensRead
           
 
Constructor Summary
Tokenizer(java.io.InputStream is, java.lang.String name)
          attach a tokenizer to an existing (opened) stream, which is attached to a file of the given name
Tokenizer(java.io.StreamTokenizer st, java.lang.String name)
          Create a tokenizer based on a StringTokenizer, to read from the given file name
Tokenizer(java.lang.String name)
          set up a tokenizer to read the named file
 
Method Summary
 void getArray_()
          Used internally to read the remainder of an array after the initial [ has been read
 java.util.Vector getArray()
          read in an array, and return it.
 Token getArrayToken()
          read in an array, and return it as a token.
 float[] getFloatArray()
          read in an array of floating point numbers
 float getNumber()
          read in a float, and return it.
 org.pqt.autorib.util.Point getPoint()
          Get a single point from the input stream
 java.lang.String getRequest()
          Read in an RIB (or Instr) request name e.g Display
 float getSingleFloat()
          read and return a single float value - discarding any enclosing [ ]
 java.lang.String getSingleString()
          Get a single string, discarding any enclosing brackets
 java.lang.String getString()
          Read a string token
 int getToken()
          Get a token of any permissable kind
private  void init()
           
 int lineno()
          return the current line number in the instruction or rib file
 void pushBack()
          Push back the last token read, so that it will be read by the next read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pushedBack

protected boolean pushedBack
true if there is a token that has been pushed back into the buffer and is ready for reading (i.e is in the variable token)


tokensRead

protected int tokensRead

fileName

public java.lang.String fileName
the file name this tokenizer is attached to


f

public java.io.Reader f
the reader for the file


t

public java.io.StreamTokenizer t
a stream tokenizer to read the file


token

public Token token
the most recently read Token

Constructor Detail

Tokenizer

public Tokenizer(java.lang.String name)
          throws java.io.FileNotFoundException
set up a tokenizer to read the named file


Tokenizer

public Tokenizer(java.io.StreamTokenizer st,
                 java.lang.String name)
Create a tokenizer based on a StringTokenizer, to read from the given file name


Tokenizer

public Tokenizer(java.io.InputStream is,
                 java.lang.String name)
attach a tokenizer to an existing (opened) stream, which is attached to a file of the given name

Method Detail

init

private void init()

getToken

public int getToken()
             throws FormatException,
                    java.io.IOException
Get a token of any permissable kind


getString

public java.lang.String getString()
                           throws FormatException,
                                  java.io.IOException
Read a string token


getNumber

public float getNumber()
                throws FormatException,
                       java.io.IOException
read in a float, and return it. If no float is found raise an error


getArray_

public void getArray_()
               throws FormatException,
                      java.io.IOException
Used internally to read the remainder of an array after the initial [ has been read


getArray

public java.util.Vector getArray()
                          throws FormatException,
                                 java.io.IOException
read in an array, and return it. If no array is found raise an error


getArrayToken

public Token getArrayToken()
                    throws FormatException,
                           java.io.IOException
read in an array, and return it as a token. If no array is found raise an error


getRequest

public java.lang.String getRequest()
                            throws FormatException,
                                   java.io.IOException
Read in an RIB (or Instr) request name e.g Display


pushBack

public void pushBack()
Push back the last token read, so that it will be read by the next read. Multiple Pushbacks will be ignored, as will a call to pushBack at the beginning of the file.


lineno

public int lineno()
return the current line number in the instruction or rib file


getFloatArray

public float[] getFloatArray()
                      throws FormatException,
                             java.io.IOException
read in an array of floating point numbers


getSingleFloat

public float getSingleFloat()
                     throws FormatException,
                            java.io.IOException
read and return a single float value - discarding any enclosing [ ]


getSingleString

public java.lang.String getSingleString()
                                 throws FormatException,
                                        java.io.IOException
Get a single string, discarding any enclosing brackets


getPoint

public org.pqt.autorib.util.Point getPoint()
                                    throws FormatException,
                                           java.io.IOException
Get a single point from the input stream