Class SimpleParser

java.lang.Object
java.io.StreamTokenizer
noaa.coastwatch.io.SimpleParser

public class SimpleParser extends StreamTokenizer
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
  • Constructor Details

    • SimpleParser

      public SimpleParser(Reader reader)
      Creates a simple parser from a character stream.
      Parameters:
      reader - the reader object providing the input stream.
  • Method Details

    • getWord

      public String getWord() throws IOException
      Gets a word from the tokenizer.
      Returns:
      the word token.
      Throws:
      IOException - if a word was not found at the next token.
    • getString

      public String getString() throws IOException
      Gets a string from the tokenizer.
      Returns:
      the string token.
      Throws:
      IOException - if a string was not found at the next token.
    • getNumber

      public double getNumber() throws IOException
      Gets a number from the tokenizer.
      Returns:
      the number token.
      Throws:
      IOException - if a number was not found at the next token.
    • getKey

      public String getKey(String expected) throws IOException
      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

      public boolean eof() throws IOException
      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.