org.metastatic.rsync
Class Parameters

java.lang.Object
  |
  +--org.metastatic.rsync.Parameters

public final class Parameters
extends Object

Simple parser for Samba-style config files. The parameters are passed back to the caller via a simple event listener callback interface, ParameterListener.

A sample file looks like:

 [section one]
 parameter one = value string
 parameter two = another value
 [section two]
 new parameter = some value or t'other
 

The syntax is roughly:

 file      ::= parameter* section* EOF
 section   ::= header parameter*
 header    ::= '[' NAME ']'
 parameter ::= NAME '=' VALUE EOL
 

Blank lines, and lines that begin with either '#' or ';' are ignored. long lines may be continued by preceding the end-of-line character(s) with a backslash ('\').


Constructor Summary
Parameters(ParameterListener listener)
          Create a new parameter file parser.
 
Method Summary
 void begin(String filename)
          Begin parsing file filename.
 void parse()
          Parse, or continue parsing the file if a parsing error occured in a previous call to this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parameters

public Parameters(ParameterListener listener)
Create a new parameter file parser. The argument is a concrete imlpmentation of ParameterListener which will take the parsed arguments.

Parameters:
listener - The parameter listener.
Method Detail

begin

public void begin(String filename)
           throws IOException
Begin parsing file filename.

Parameters:
filename - The name of the file to parse.
Throws:
IOException - If an I/O error occurs.

parse

public void parse()
           throws IOException
Parse, or continue parsing the file if a parsing error occured in a previous call to this method. A call to begin(java.lang.String) must have succeeded before this method is called.

Throws:
ParameterException - If a parsing error occurs. Parsing can continue if this exception is thrown by calling this method again.
IOException - If an I/O error occurs.