Class VRML97FieldParser
- All Implemented Interfaces:
VRML97FieldParserConstants
The parser assumes that we have a raw field value that does not contain any surrounding values. For example, it expects MFField values to be stripped of surrounding brackets before being passed to these methods.
There are two ways of using this class: parsing a know field type, and parsing an unknown field type and getting the parser to return the appropriate (closest guess) value to you.
This parser has been continually evolving since first written for the VRML97 open source effort. The original contributor was Rick Goldberg of Sun Microsystems. Since then it has been through numerous tweaks and re-writes
The assumption of this parser is that each time you call the method it will have a non-zero length, non-empty string. There should be at least one non-whitespace character in the string. If not, a parse exception will be raised. You can see what JavaCC thinks the grammar is here
- Version:
- Grammar $Revision: 1.22 $
- Author:
- Justin Couch, Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionNext token.Current token.Generated Token Manager.Fields inherited from interface org.web3d.parser.vrml97.VRML97FieldParserConstants
COMMENT, DEFAULT, EOF, FALSE, LBRACKET, NUMBER_LITERAL, RBRACKET, STRING_LITERAL, tokenImage, TRUE
-
Constructor Summary
ConstructorsConstructorDescriptionVRML97FieldParser
(InputStream stream) Constructor with InputStream.VRML97FieldParser
(InputStream stream, String encoding) Constructor with InputStream and supplied encodingVRML97FieldParser
(Reader stream) Constructor.Constructor with generated Token Manager. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Disable tracing.final void
Enable tracing.Generate ParseException.Fetch the documentLocator used by this parser.final Token
Get the next Token.final Token
getToken
(int index) Get the specific Token.final boolean[]
MFBool()
Parse an MFBool value.final float[]
MFColor()
Parse an MFColor value.final float[]
MFFloat()
Parse an MFFloat value.final int[]
MFInt32()
Parse an MFInt32 value.final float[]
Parse an MFRotation value.final String[]
MFString()
Parse an MFString value.final double[]
MFTime()
Parse an MFTime value.final float[]
MFVec2f()
Parse an MFVec2f value.final float[]
MFVec3f()
Parse an MFVec3f value.final Object
parseUnknownField
(boolean useInt) This does not use the other methods to do the field parsing.void
ReInit
(InputStream stream) Reinitialise.void
ReInit
(InputStream stream, String encoding) Reinitialise.void
Reinitialise.void
Reinitialise.final boolean
SFBool()
Parse an SFBool value.final float[]
SFColor()
Parse an SFColor value.final float
SFFloat()
Parse an SFFloat value.final int[]
SFImage()
Parse an SFImage value.final int
SFInt32()
Parse an SFInt value.final float[]
Parse an SFRotation value.final String
SFString()
Parse an SFString value.final double
SFTime()
Parse an SFTime value.final float[]
SFVec2f()
Parse an SFVec2f value.final float[]
SFVec3f()
Parse an SFVec3f value.
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
VRML97FieldParser
Constructor with InputStream. -
VRML97FieldParser
Constructor with InputStream and supplied encoding -
VRML97FieldParser
Constructor. -
VRML97FieldParser
Constructor with generated Token Manager.
-
-
Method Details
-
getDocumentLocator
Fetch the documentLocator used by this parser. This is here so that the user of this parser can ask for it and set it before calling startDocument(). Once the scene has started parsing in this class it is too late for the documentLocator to be set. This parser does set it internally when asked for aVRML97RelaxedParser.Scene()
but there may be other times when it is not set.- Returns:
- The documentLocator used for syntax errors
-
parseUnknownField
This does not use the other methods to do the field parsing. Instead, it goes on the raw values that are presented and returns objects to represent that. We look for either single values or multiple values. For any of these we return a representative object. The return value could be one of these:- Boolean
- Integer
- Float
- String
- boolean[]
- int[]
- float[]
- String[]
- Parameters:
useInt
- A hint to use if this is a number field we are parsing to decide whether to parse number strings as an int or float for type checking. If expecting any other sort of field, has no effect.- Throws:
ParseException
-
SFInt32
Parse an SFInt value. If there is more than one int value in the string it will be ignored.- Throws:
ParseException
-
MFInt32
Parse an MFInt32 value.MFInt32 ::= "[" NUMBER_LITERAL* "]" | NUMBER_LITERAL*
- Throws:
ParseException
-
SFFloat
Parse an SFFloat value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFFloat
Parse an MFFloat value.MFInt32 ::= "[" NUMBER_LITERAL* "]" | NUMBER_LITERAL*
- Throws:
ParseException
-
SFBool
Parse an SFBool value. If there is more than one boolean value in the string it will be ignored.- Throws:
ParseException
-
MFBool
Parse an MFBool value.MFBool ::= "[" ("TRUE" | "FALSE")* "]" | ("TRUE" | "FALSE")*
- Throws:
ParseException
-
SFString
Parse an SFString value. We really shouldn't need this, but it is here for completeness.- Throws:
ParseException
-
MFString
Parse an MFString value.MFString ::= "[" ( STRING_LITERAL)* "]" | (STRING_LITERAL)*
- Throws:
ParseException
-
SFVec2f
Parse an SFVec2f value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFVec2f
Parse an MFVec2f value.MFVec2f ::= "[" (NUMBER_LITERAL NUMBER_LITERAL)* "]" | (NUMBER_LITERAL NUMBER_LITERAL)*
- Throws:
ParseException
-
SFVec3f
Parse an SFVec3f value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFVec3f
Parse an MFVec3f value.MFVec3f ::= "[" (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)* "]" | (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)*
- Throws:
ParseException
-
SFRotation
Parse an SFRotation value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFRotation
Parse an MFRotation value.MFRotation ::= "[" (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)* "]" | (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)*
- Throws:
ParseException
-
SFTime
Parse an SFTime value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFTime
Parse an MFTime value. In VRML97 MFTime are not legal field types. However, we provide it here for completeness and that it might be used by VRML 3.0.MFTime ::= "[" NUMBER_LITERAL* "]" | NUMBER_LITERAL*
- Throws:
ParseException
-
SFColor
Parse an SFColor value. If there is more than one float value in the string it will be ignored.- Throws:
ParseException
-
MFColor
Parse an MFColor value. The color differs from the float value by being clamped between 0 and 1.MFColor ::= "[" (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)* "]" | (NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL)*
- Throws:
ParseException
-
SFImage
Parse an SFImage value.SFImage ::= NUMBER_LITERAL NUMBER_LITERAL NUMBER_LITERAL (NUMBER_LITERAL)*
- Throws:
ParseException
-
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
generateParseException
Generate ParseException. -
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing.
-