Class dnx.lr.VRMLTokenizer
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class dnx.lr.VRMLTokenizer

java.lang.Object
   |
   +----dnx.lr.VRMLTokenizer

public class VRMLTokenizer
extends Object
This class is a dedicated VRML tokenizer (aka lexer). It behaves similarly to StreamTokenizer but breaks up its input (a .wrl file) into individual VRML tokens. The general idea is that you call nextToken() to retrieve the next token and return its type. The types defined are (some of these are actually states rather than types): ID == VRML token (word, basically) or special character STRING == string enclosed in quotes INTEGER == integer FLOAT == floating-point value EOF == no more tokens; end of file reached START == no tokens yet; at beginning of file Once you know the type of the current token, you call getIntegerValue(), getStringValue(), etc. to retrieve the value. Alternatively, you can call expect(), which reads the next token and throws an error if it's not of the specified type; or expectKeyword(), if you want to see a particular keyword (i.e. ID).

Variable Index

 o charno
 o EOF
 o FLOAT
 o ID
 o INTEGER
 o START
 o STRING

Constructor Index

 o VRMLTokenizer(InputStream)
Create a new VRMLTokenizer from an input stream.

Method Index

 o abortReading()
Indicate that reading should terminate as soon as possible.
 o expect(int)
Read the next token; if it not of the expected type, throw a VRMLSyntaxException.
 o expectKeyword(String)
Read the next token; if it is not a valid ID matching word, throw a VRMLSyntaxException.
 o getDoubleValue()
Return the value of a valid floating point token
 o getFloatValue()
Return the value of a valid floating point token
 o getIDValue()
Return the value of a valid ID token
 o getIntegerValue()
Return the value of a valid integer token.
 o getLineno()
Return the line number of the token that is about to be read.
 o getLinenoOfLastToken()
Return the line number of the token most recently read.
 o getStringValue()
Return the value of a valid string token
 o getTokenType()
Return the current token type.
 o nextToken()
Read another token and return its type.
 o pushBack()
Push back the last token read; this class supports only one token of pushback.
 o tryFloat()
Check to see if the next token is a float.
 o tryID()
Check to see if the next token is an identifier.
 o tryInteger()
Check to see if the next token is an integer.
 o tryKeyword(String)
Check to see if the type of the next token matches tryType.
 o tryString()
Check to see if the next token is a string.
 o tryType(int)
Check to see if the type of the next token matches tryType.

Variables

 o ID
  public final static int ID
 o STRING
  public final static int STRING
 o INTEGER
  public final static int INTEGER
 o FLOAT
  public final static int FLOAT
 o EOF
  public final static int EOF
 o START
  public final static int START
 o charno
  public int charno

Constructors

 o VRMLTokenizer
  public VRMLTokenizer(InputStream s)
Create a new VRMLTokenizer from an input stream.

Methods

 o abortReading
  public void abortReading()
Indicate that reading should terminate as soon as possible. A ReadAbortedException will be thrown.
 o getTokenType
  public int getTokenType()
Return the current token type.
 o getIntegerValue
  public int getIntegerValue() throws VRMLSyntaxException
Return the value of a valid integer token.
 o getFloatValue
  public float getFloatValue() throws VRMLSyntaxException
Return the value of a valid floating point token
 o getDoubleValue
  public double getDoubleValue() throws VRMLSyntaxException
Return the value of a valid floating point token
 o getStringValue
  public String getStringValue() throws VRMLSyntaxException
Return the value of a valid string token
 o getIDValue
  public String getIDValue() throws VRMLSyntaxException
Return the value of a valid ID token
 o pushBack
  public void pushBack()
Push back the last token read; this class supports only one token of pushback.
 o nextToken
  public int nextToken() throws IOException, VRMLSyntaxException
Read another token and return its type.
 o getLineno
  public int getLineno()
Return the line number of the token that is about to be read. Note that doing a pushBack() will cause the value returned by getLineno() to get bumped back, too.
 o getLinenoOfLastToken
  public int getLinenoOfLastToken()
Return the line number of the token most recently read. Note that doing a pushBack() will cause the value returned by getLinenoOfLastToken() to get bumped back, too.
 o tryType
  public boolean tryType(int tryType) throws IOException, VRMLSyntaxException
Check to see if the type of the next token matches tryType. If it does, the function returns true; otherwise it returns false and the current token is pushed back.
 o tryKeyword
  public boolean tryKeyword(String word) throws IOException, VRMLSyntaxException
Check to see if the type of the next token matches tryType. If it does, the function returns true; otherwise it returns false and the token just read is pushed back.
 o tryInteger
  public boolean tryInteger() throws IOException, VRMLSyntaxException
Check to see if the next token is an integer. If it is, the function returns true; otherwise it returns false and the token just read is pushed back.
 o tryFloat
  public boolean tryFloat() throws IOException, VRMLSyntaxException
Check to see if the next token is a float. If it is, the function returns true; otherwise it returns false and the token just read is pushed back.
 o tryID
  public boolean tryID() throws IOException, VRMLSyntaxException
Check to see if the next token is an identifier. If it is, the function returns true; otherwise it returns false and the token just read is pushed back.
 o tryString
  public boolean tryString() throws IOException, VRMLSyntaxException
Check to see if the next token is a string. If it is, the function returns true; otherwise it returns false and the token just read is pushed back.
 o expect
  public void expect(int expectedType) throws IOException, VRMLSyntaxException
Read the next token; if it not of the expected type, throw a VRMLSyntaxException.
 o expectKeyword
  public void expectKeyword(String word) throws IOException, VRMLSyntaxException
Read the next token; if it is not a valid ID matching word, throw a VRMLSyntaxException.

All Packages  Class Hierarchy  This Package  Previous  Next  Index