com.sun.j3d.loaders.lw3d
Class TextfileParser

java.lang.Object
  extended by com.sun.j3d.loaders.lw3d.TextfileParser
Direct Known Subclasses:
EnvelopeHandler, Lw3dLoader, LwsBackground, LwsCamera, LwsEnvelope, LwsEnvelopeFrame, LwsFog, LwsFrame, LwsLight, LwsMotion, LwsObject

 class TextfileParser
extends java.lang.Object

This class is a superclass for most of the Lws* Scene-file parsing classes. It provides some debugging utilities, as well as utilities for reading the types of data common to this loader.


Field Summary
(package private)  int currentLevel
           
protected  DebugOutput debugPrinter
           
(package private) static int EXCEPTION
           
(package private) static int LINE_TRACE
           
(package private)  char lineSeparatorChar
           
(package private) static int MISC
           
(package private) static int NONE
           
(package private) static int NUMBER
           
(package private) static int TIME
           
(package private) static int TRACE
           
(package private) static int VALUES
           
(package private) static int WORD
           
 
Constructor Summary
TextfileParser()
           
 
Method Summary
(package private)  void checkString(java.io.StreamTokenizer st, java.lang.String theString)
          Error checking routine - makes sure the current token is the string we were expecting
(package private)  void checkType(java.io.StreamTokenizer st, int theType)
          Error checking routine - makes sure the current token is of the right type
protected  void debugOutput(int outputType, java.lang.String theOutput)
           
protected  void debugOutputLn(int outputType, java.lang.String theOutput)
           
(package private)  void getAndCheckString(java.io.StreamTokenizer st, java.lang.String expectedValue)
          Gets the next token and ensures that it is the string we were expecting to see
(package private)  java.lang.String getName(java.io.StreamTokenizer st)
          Returns a "name" from the stream.
(package private)  double getNumber(java.io.StreamTokenizer st)
          Returns number from the tokenizer.
(package private)  java.lang.String getString(java.io.StreamTokenizer st)
          Returns String from the tokenizer
(package private)  boolean isCurrentToken(java.io.StreamTokenizer st, java.lang.String tokenString)
          Utility method- used to check whether the current token is equal to the given string
(package private)  void skip(java.io.StreamTokenizer st, java.lang.String tokenString, int skipVals)
          Utility routine - gets next token, checks it against our expectation, then skips a given number of tokens.
(package private)  void skipUntilString(java.io.StreamTokenizer st, java.lang.String theString)
          Utility method to advance the tokenizer until we see the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORD

static int WORD

NUMBER

static int NUMBER

currentLevel

int currentLevel

TRACE

static final int TRACE
See Also:
Constant Field Values

VALUES

static final int VALUES
See Also:
Constant Field Values

MISC

static final int MISC
See Also:
Constant Field Values

LINE_TRACE

static final int LINE_TRACE
See Also:
Constant Field Values

NONE

static final int NONE
See Also:
Constant Field Values

EXCEPTION

static final int EXCEPTION
See Also:
Constant Field Values

TIME

static final int TIME
See Also:
Constant Field Values

debugPrinter

protected DebugOutput debugPrinter

lineSeparatorChar

char lineSeparatorChar
Constructor Detail

TextfileParser

TextfileParser()
Method Detail

debugOutputLn

protected void debugOutputLn(int outputType,
                             java.lang.String theOutput)

debugOutput

protected void debugOutput(int outputType,
                           java.lang.String theOutput)

skipUntilString

void skipUntilString(java.io.StreamTokenizer st,
                     java.lang.String theString)
               throws ParsingErrorException
Utility method to advance the tokenizer until we see the given string. This is used to skip by various parameters that we currently ignore in the loader.

Throws:
ParsingErrorException

getNumber

double getNumber(java.io.StreamTokenizer st)
           throws ParsingErrorException,
                  java.lang.NumberFormatException
Returns number from the tokenizer. Note that we don't recognize numbers in the tokenizer automatically because numbers might be in scientific notation, which isn't processed correctly by StreamTokenizer

Throws:
ParsingErrorException
java.lang.NumberFormatException

getString

java.lang.String getString(java.io.StreamTokenizer st)
                     throws ParsingErrorException
Returns String from the tokenizer

Throws:
ParsingErrorException

getName

java.lang.String getName(java.io.StreamTokenizer st)
                   throws ParsingErrorException
Returns a "name" from the stream. This is different from simply a String because the name could contain whitespace characters (such as "object 1" or "objectname (sequence)") that would confuse the string parser. So we just grab all characters until EOL and concatenate them together to form the name

Throws:
ParsingErrorException

getAndCheckString

void getAndCheckString(java.io.StreamTokenizer st,
                       java.lang.String expectedValue)
                 throws ParsingErrorException
Gets the next token and ensures that it is the string we were expecting to see

Throws:
ParsingErrorException

checkString

void checkString(java.io.StreamTokenizer st,
                 java.lang.String theString)
           throws ParsingErrorException
Error checking routine - makes sure the current token is the string we were expecting

Throws:
ParsingErrorException

checkType

void checkType(java.io.StreamTokenizer st,
               int theType)
         throws ParsingErrorException
Error checking routine - makes sure the current token is of the right type

Throws:
ParsingErrorException

skip

void skip(java.io.StreamTokenizer st,
          java.lang.String tokenString,
          int skipVals)
    throws ParsingErrorException
Utility routine - gets next token, checks it against our expectation, then skips a given number of tokens. This can be used to parse through (and ignore) certain parameter/value sets in the files

Throws:
ParsingErrorException

isCurrentToken

boolean isCurrentToken(java.io.StreamTokenizer st,
                       java.lang.String tokenString)
Utility method- used to check whether the current token is equal to the given string



Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.