com.internationalnetwork.util
Class ReadConfFile

Object
  extended by com.internationalnetwork.util.ReadConfFile

public class ReadConfFile
extends Object

Reads a simple Apache-HTTPd format ".conf" file and provides a HashMap containing the Directives and their associated, unparsed values. At this time, Containers are not yet supported.


Field Summary
static String VERSION
          Version number of this Package (read-only).
 
Constructor Summary
ReadConfFile(String filename, String... directives)
          Processes the specified configuration file.
 
Method Summary
 String get(String directive)
          Returns the value associated with the specified Directive name.
 String get(String directive, int index)
          Returns the value associated with the specified Directive name.
 String[] getDirectives()
          Returns a list of directives that are currently set.
 long getLineNumber()
          Returns the most recently processed line number.
 String[] getLinePair()
          Returns the most recently processed directive and value String pair.
 String[] toArray(String directive)
          Returns the String array[] associated with the specified directive.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Version number of this Package (read-only).

See Also:
Constant Field Values
Constructor Detail

ReadConfFile

public ReadConfFile(String filename,
                    String... directives)
             throws java.io.FileNotFoundException,
                    java.io.IOException,
                    IllegalArgumentException
Processes the specified configuration file. This method may be called more than once to combine multiple configuration files.

Parameters:
filename - Name (and path) of the configuration file to process
directives - One or more Directives that are permitted. The default value for each directive can also be set by including an equal ("=") symbol followed by the default value, and this value will be used when the directive isn't present in the configuration file.
Throws:
java.io.FileNotFoundException - if the file specified cannot be opened
java.io.IOException - if an error occurs while reading the file
IllegalArgumentException - if an invalid Directive is encountered
Method Detail

get

public String get(String directive)
Returns the value associated with the specified Directive name.

Parameters:
directive - Directive name
Returns:
String Value (null = directive not found)

get

public String get(String directive,
                  int index)
Returns the value associated with the specified Directive name.

Parameters:
directive - Directive name
index - Specific value number to obtain
Returns:
String Value (null = directive not found)

getDirectives

public String[] getDirectives()
Returns a list of directives that are currently set.

The following example code illustrates how to obtain a list of directives that have been set, and display each with their associated value.

Returns:
String[] Directives (null = none defined)

getLineNumber

public long getLineNumber()
Returns the most recently processed line number.

Returns:
long Current line number

getLinePair

public String[] getLinePair()
Returns the most recently processed directive and value String pair.

Returns:
String[] A two-element String array containg the Directive, and its Value (unparsed), respectively

toArray

public String[] toArray(String directive)
Returns the String array[] associated with the specified directive.

Parameters:
directive - Name of directive
Returns:
String[] Value (null = directive not found)