Class LineParser

java.lang.Object
com.sun.javatest.util.LineParser

public class LineParser extends Object
A class to parse lines of words in a stream. Words may be unquoted sequences of non-blank characters, or may be quoted strings. Comments can be introduced by '#' and extend to the next newline character. Lines may be terminated by newline, semicolon or a comment.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This exception is used to report problems while using a line parser.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a line parser, reading the data in a given file.
    Create a line parser, reading data from an anonymous stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the file being read, or null if it is not available.
    int
    Get the current line number within the stream being read.
    Read the next line of words from the input stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LineParser

      public LineParser(File file) throws FileNotFoundException, IOException
      Create a line parser, reading the data in a given file.
      Parameters:
      file - the file to be read
      Throws:
      FileNotFoundException - if the file was not found
      IOException - if there is some problem opening the file or reading the initial characters of the file
    • LineParser

      public LineParser(Reader in)
      Create a line parser, reading data from an anonymous stream.
      Parameters:
      in - the stream from which to read the data
  • Method Details

    • getFile

      public File getFile()
      Get the file being read, or null if it is not available.
      Returns:
      the file being read, or null if not available
    • getLineNumber

      public int getLineNumber()
      Get the current line number within the stream being read.
      Returns:
      the current line number within nthe stream being read
    • readLine

      public String[] readLine() throws LineParser.Fault
      Read the next line of words from the input stream.
      Returns:
      the next line of words from the input stream
      Throws:
      LineParser.Fault - if there is a problem reading the required data -- such as an unterminated string