EAF 7.6 Util

com.lutris.util
Class ConfigFile

java.lang.Object
  extended by org.enhydra.util.AbsConfigFile
      extended by com.lutris.util.ConfigFile
All Implemented Interfaces:
org.enhydra.util.ConfigFileInterface

public class ConfigFile
extends org.enhydra.util.AbsConfigFile

ConfigFile is used to manipulate Multiserver configuration (*.conf) files. Presents all configuration elements in the form of a keyed table. Configuration elements are grouped by string "keys" according to the function they configure. The syntax is described more formally below.

        stream ::= entry | stream entry
        entry ::= key "=" value_list | comment | blank
        value_list ::= value | value_list "," value
        value ::= fragment | value "+" fragment
        fragment ::= key | quoted_string
        quoted_string ::= (C/C++ style quoted string)
        key ::= (A string matching [A-Za-z_\./][A-Za-z0-9_-\./]*)
        comment ::= "#" (any text up to a newline)
        blank ::= (A line containing only white space)
 
In addition to the above syntax, some additional semantic rules apply. The operator "+" concatenates the fragment immediately to the left and to the right of it. Thus ab + cd results in abcd. The operator "," terminates one element and begins the next element. Thus, the line val = hello, world creates a configuration entry with the key "val" and the two elements "hello", and "world". If the characters "+", ",", or "\" occur at the end of a line, then the entry is continued on the next line. Trailing and leading whitespaces are ignored, and multiple whitespace characters are converted by default into a single space. The "+" operator leaves no whitespace between operands. Finally, within quoted strings, C-style backslash escapes are recognized. These include "\n" for newline, "\t" for tab, etc. An example configuration input file is given below.
        #==============================================================
        # Sample.config
        #==============================================================
        LDAP_SERVERS[] =  "server1.ldap.gov:338",
                          "server2.ldap.gov:1000"
        USER_TIMEOUT =  3600  # seconds.  Comments can follow on same line.
        STRANGE_ENTRY = "This is a long long long long long " +
                        "long long line.  Notice how the \"+\" " +
                        "operator is used to break this line up " +
                        "into more than one line in the config file." ,
                        "And this is the second element."
        # etc.
 

Version:
$Revision: 1.13 $
Author:
Shawn McMurdo
See Also:
Config

Field Summary
 
Fields inherited from class org.enhydra.util.AbsConfigFile
comments, config, file, jndiAdapt, jndiParameterNames, order
 
Fields inherited from interface org.enhydra.util.ConfigFileInterface
TRAILING_COMMENT
 
Constructor Summary
ConfigFile()
           
ConfigFile(java.io.File file)
          Constructor from a File.
ConfigFile(java.io.InputStream inputStream)
          Constructor from an InputStream.
ConfigFile(KeywordValueTable kvt)
          Constructor from a KeywordValueTable.
 
Method Summary
protected  void readJndi()
          Reads application configuration parameters by using JNDI Context.
 void write(java.io.OutputStream outputStream)
          Writes out a config file to the OutputStream specified.
 
Methods inherited from class org.enhydra.util.AbsConfigFile
addEntry, addEntry, getComment, getConfig, getFile, removeEntry, setFile, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigFile

public ConfigFile(java.io.InputStream inputStream)
           throws com.lutris.util.ConfigException
Constructor from an InputStream.

Parameters:
inputStream - The input stream from which to parse the config file.
Throws:
ConfigException

ConfigFile

public ConfigFile()

ConfigFile

public ConfigFile(java.io.File file)
           throws com.lutris.util.ConfigException,
                  java.io.IOException
Constructor from a File. Allows to later write back the configuration to the same file.

Parameters:
file - The local file to parse.
Throws:
java.io.IOException
ConfigException

ConfigFile

public ConfigFile(KeywordValueTable kvt)
           throws com.lutris.util.ConfigException
Constructor from a KeywordValueTable.

Parameters:
kvt - A KeywordValueTable from which to populate the config file.
Throws:
ConfigException
Method Detail

readJndi

protected void readJndi()
                 throws com.lutris.util.ConfigException
Reads application configuration parameters by using JNDI Context.

Overrides:
readJndi in class org.enhydra.util.AbsConfigFile
Throws:
com.lutris.util.ConfigException

write

public void write(java.io.OutputStream outputStream)
Writes out a config file to the OutputStream specified. Note that Objects other than String or String[] will be converted into a String.

Specified by:
write in interface org.enhydra.util.ConfigFileInterface
Specified by:
write in class org.enhydra.util.AbsConfigFile
Parameters:
outputStream - The output stream on which to write the config file.

EAF 7.6 Util