org.psepr.jClient
Class ParamFile

java.lang.Object
  extended by org.psepr.jClient.ParamFile
Direct Known Subclasses:
JClientParamFile

public class ParamFile
extends java.lang.Object

Read and process a parameter file.

A parameter file of the form:

 <jClient>
    <debug>
       <detail>IO</detail>
       <verbose/>
    </debug>
    <server type="registry">
       <name>frog</name>
    </server>
 </jClient>
 
would create a set of params:
  /jClient/debug/detail: IO
  /jClient/debug/verbose: null
  /jClient/server/@type: registry
  /jClient/server/name: frog
 

Note that is module cannot call the regular DebuggerLogger.log() routine -- that module calls this module to get configration parameters and that causes a very bad loop.

Author:
Robert.Adams@intel.com

Constructor Summary
ParamFile()
           
ParamFile(java.io.Reader inFile)
           
 
Method Summary
 boolean getParam(java.lang.String parm, boolean deflt)
          Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.
 int getParam(java.lang.String parm, int deflt)
          Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.
 long getParam(java.lang.String parm, long deflt)
          Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.
 java.lang.String getParam(java.lang.String parm, java.lang.String deflt)
          Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.
 boolean hasParam(java.lang.String parm)
          return true if this parameter is in the parameter file
 boolean paramFlag(java.lang.String pName)
          Return a boolean flag from the param file.
 java.lang.String paramString(java.lang.String pName)
          Return a string value from the parameter file.
 void parseFile(java.io.Reader inFile)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParamFile

public ParamFile()

ParamFile

public ParamFile(java.io.Reader inFile)
          throws java.text.ParseException
Throws:
java.text.ParseException
Method Detail

parseFile

public void parseFile(java.io.Reader inFile)
               throws java.text.ParseException
Throws:
java.text.ParseException

paramFlag

public boolean paramFlag(java.lang.String pName)
Return a boolean flag from the param file.

Parameters:
pName -
Returns:
'true' if parameter exists or has value 'true', 'yes' or 'on'

paramString

public java.lang.String paramString(java.lang.String pName)
Return a string value from the parameter file. Note that a return of 'null' i does not mean the value does not exist -- it could have the value null. Use 'paramFlag' to verify existance if you care about that.

Parameters:
pName -
Returns:
value of parameter.

hasParam

public boolean hasParam(java.lang.String parm)
return true if this parameter is in the parameter file

Parameters:
parm -
Returns:

getParam

public java.lang.String getParam(java.lang.String parm,
                                 java.lang.String deflt)
Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.

Parameters:
parm -
deflt -
Returns:

getParam

public long getParam(java.lang.String parm,
                     long deflt)
Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.

Parameters:
parm -
deflt -
Returns:

getParam

public int getParam(java.lang.String parm,
                    int deflt)
Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.

Parameters:
parm -
deflt -
Returns:

getParam

public boolean getParam(java.lang.String parm,
                        boolean deflt)
Return the value of the parameter or the default value if the parameter is either not specified or if the value is not specified.

Parameters:
parm -
deflt -
Returns: