Package noaa.coastwatch.io
Class SimpleParser
java.lang.Object
java.io.StreamTokenizer
noaa.coastwatch.io.SimpleParser
The simple parser class is a stream tokenizer with various methods
for simplifed parsing of text input streams.
- Since:
- 3.1.1
- Author:
- Peter Hollemans
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSimpleParser
(Reader reader) Creates a simple parser from a character stream. -
Method Summary
Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lineno, lowerCaseMode, nextToken, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars
-
Constructor Details
-
SimpleParser
Creates a simple parser from a character stream.- Parameters:
reader
- the reader object providing the input stream.
-
-
Method Details
-
getWord
Gets a word from the tokenizer.- Returns:
- the word token.
- Throws:
IOException
- if a word was not found at the next token.
-
getString
Gets a string from the tokenizer.- Returns:
- the string token.
- Throws:
IOException
- if a string was not found at the next token.
-
getNumber
Gets a number from the tokenizer.- Returns:
- the number token.
- Throws:
IOException
- if a number was not found at the next token.
-
getKey
Gets a key word from the tokenizer. The key/value pair equals sign is also parsed.- Parameters:
expected
- the expected key or null of no specific key is expected.- Returns:
- the word token.
- Throws:
IOException
- if no key was found or the the expected key was not found at the next token.
-
eof
Checks for the end-of-file token.- Returns:
- true if the next token is the end-of-file, or false otherwise. The state of the parser is not changed.
- Throws:
IOException
- if an error occurred reading the input stream.
-