/* */ package com.sun.j3d.loaders.lw3d;
/* */
/* */ import com.sun.j3d.loaders.ParsingErrorException;
/* */ import java.io.IOException;
/* */ import java.io.StreamTokenizer;
/* */
/* */ class TextfileParser
/* */ {
/* 54 */ static int WORD = -3;
/* 55 */ static int NUMBER = -2;
/* 56 */ int currentLevel = 3;
/* */ static final int TRACE = 1;
/* */ static final int VALUES = 2;
/* */ static final int MISC = 4;
/* */ static final int LINE_TRACE = 8;
/* */ static final int NONE = 0;
/* */ static final int EXCEPTION = 16;
/* */ static final int TIME = 32;
/* */ protected DebugOutput debugPrinter;
/* 62 */ char lineSeparatorChar = '\000';
/* */
/* */ TextfileParser() {
/* 65 */ this.debugPrinter = new DebugOutput(16);
/* 66 */ String lineSeparator = System.getProperty("line.separator");
/* 67 */ this.lineSeparatorChar = lineSeparator.charAt(0);
/* 68 */ debugOutputLn(2, "lineSeparatorChar = " + this.lineSeparatorChar);
/* */ }
/* */
/* */ protected void debugOutputLn(int outputType, String theOutput)
/* */ {
/* 73 */ if (theOutput.equals(""))
/* 74 */ this.debugPrinter.println(outputType, theOutput);
/* */ else
/* 76 */ this.debugPrinter.println(outputType, getClass().getName() + "::" + theOutput);
/* */ }
/* */
/* */ protected void debugOutput(int outputType, String theOutput)
/* */ {
/* 82 */ this.debugPrinter.print(outputType, theOutput);
/* */ }
/* */
/* */ void skipUntilString(StreamTokenizer st, String theString)
/* */ throws ParsingErrorException
/* */ {
/* 92 */ boolean done = false;
/* */ try {
/* 94 */ while (!done) {
/* 95 */ st.nextToken();
/* 96 */ if ((st.ttype == WORD) && (st.sval.equals(theString)))
/* */ {
/* 98 */ done = true;
/* */ }
/* */ }
/* */ } catch (IOException e) {
/* 102 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* */ }
/* */
/* */ double getNumber(StreamTokenizer st)
/* */ throws ParsingErrorException, NumberFormatException
/* */ {
/* */ try
/* */ {
/* 116 */ token = st.nextToken();
/* */ }
/* */ catch (IOException e)
/* */ {
/* */ int token;
/* 119 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* 121 */ checkType(st, WORD);
/* 122 */ return Double.valueOf(st.sval).doubleValue();
/* */ }
/* */
/* */ String getString(StreamTokenizer st)
/* */ throws ParsingErrorException
/* */ {
/* */ try
/* */ {
/* 130 */ st.nextToken();
/* */ }
/* */ catch (IOException e) {
/* 133 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* 135 */ checkType(st, WORD);
/* 136 */ return st.sval;
/* */ }
/* */
/* */ String getName(StreamTokenizer st)
/* */ throws ParsingErrorException
/* */ {
/* 147 */ String theName = "";
/* 148 */ st.ordinaryChar(this.lineSeparatorChar);
/* 149 */ st.ordinaryChar(10);
/* 150 */ st.ordinaryChar(13);
/* */ try {
/* 152 */ st.nextToken();
/* */
/* 155 */ while ((st.ttype != this.lineSeparatorChar) && (st.ttype != 13) && (st.ttype != 10)) {
/* 156 */ if ((st.ttype != 40) && (st.ttype != 41))
/* */ {
/* 158 */ theName = theName + st.sval;
/* 159 */ }st.nextToken();
/* */ }
/* */ }
/* */ catch (IOException e) {
/* 163 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* 165 */ st.whitespaceChars(this.lineSeparatorChar, this.lineSeparatorChar);
/* 166 */ st.whitespaceChars(10, 10);
/* 167 */ st.whitespaceChars(13, 13);
/* 168 */ debugOutputLn(2, "name = " + theName);
/* 169 */ return theName;
/* */ }
/* */
/* */ void getAndCheckString(StreamTokenizer st, String expectedValue)
/* */ throws ParsingErrorException
/* */ {
/* */ try
/* */ {
/* 179 */ st.nextToken();
/* 180 */ checkString(st, expectedValue);
/* */ }
/* */ catch (IOException e) {
/* 183 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* */ }
/* */
/* */ void checkString(StreamTokenizer st, String theString)
/* */ throws ParsingErrorException
/* */ {
/* 193 */ if ((st.ttype != -3) || (!st.sval.equals(theString)))
/* */ {
/* 195 */ throw new ParsingErrorException("Bad String Token (wanted " + theString + ", got " + st.sval + ": " + st.toString());
/* */ }
/* */ }
/* */
/* */ void checkType(StreamTokenizer st, int theType)
/* */ throws ParsingErrorException
/* */ {
/* 206 */ if (st.ttype != theType)
/* 207 */ throw new ParsingErrorException("Bad Type Token, Expected " + theType + " and received" + st.ttype);
/* */ }
/* */
/* */ void skip(StreamTokenizer st, String tokenString, int skipVals)
/* */ throws ParsingErrorException
/* */ {
/* */ try
/* */ {
/* 220 */ st.nextToken();
/* 221 */ checkString(st, tokenString);
/* 222 */ for (int i = 0; i < skipVals; i++)
/* 223 */ st.nextToken();
/* */ }
/* */ catch (IOException e)
/* */ {
/* 227 */ throw new ParsingErrorException(e.getMessage());
/* */ }
/* */ }
/* */
/* */ boolean isCurrentToken(StreamTokenizer st, String tokenString)
/* */ {
/* 236 */ if (st.ttype == WORD)
/* 237 */ return st.sval.equals(tokenString);
/* 238 */ return false;
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name: com.sun.j3d.loaders.lw3d.TextfileParser
* JD-Core Version: 0.6.2
*/