gitzel.util

Class BasicScriptReader


public class BasicScriptReader
extends IniReader

This class can read small scripts from various streams, readers etc. There is no real parsing involved, rather the scripts consist of lines like this:

        command arg1 arg2 arg3 ...

The getEntry(int line) method will return a string array that has the command name in [0], and the args in the consecutive fields. getEntry(string) should not be used directly but can be - getEntry("1-3") for example gets you the 3rd argument of line 1. Note that a program starts with line 0. There are some commands that are hard-wired into this class:

These commands are automatically executed when the iterator is used.

Nested Class Summary

(package private) class
BasicScriptReader.BSRIterator
The iterator class for this class.

Field Summary

private int
LineNum
The highest line number parsed yet.

Fields inherited from class gitzel.util.IniReader

Data, IStream

Constructor Summary

BasicScriptReader(BufferedReader r)
Reads the script from a buffered reader
BasicScriptReader(InputStream in)
Reads the script from the InputStream.
BasicScriptReader(String data)
reads the script from the given string

Method Summary

String[]
getEntry(int line)
returns a line slashed into command, and arguments
int
getLineNumber()
Returns the number of lines this script has.
Iterator
iterator()
Returns an iterator over this object.
void
parse(String line)
The parsing of a line.

Methods inherited from class gitzel.util.IniReader

deleteEntry, getEntry, parse, save, save, setEntry

Field Details

LineNum

private int LineNum
The highest line number parsed yet.

Constructor Details

BasicScriptReader

public BasicScriptReader(BufferedReader r)
            throws IOException
Reads the script from a buffered reader

BasicScriptReader

public BasicScriptReader(InputStream in)
            throws IOException
Reads the script from the InputStream.

BasicScriptReader

public BasicScriptReader(String data)
            throws IOException
reads the script from the given string

Method Details

getEntry

public String[] getEntry(int line)
returns a line slashed into command, and arguments

getLineNumber

public int getLineNumber()
Returns the number of lines this script has.

iterator

public Iterator iterator()
Returns an iterator over this object.

parse

public void parse(String line)
The parsing of a line.
Overrides:
parse in interface IniReader