kylm.util
Class KylmConfigUtils

java.lang.Object
  extended by kylm.util.KylmConfigUtils

public class KylmConfigUtils
extends java.lang.Object

A class to handle configuration of executable files

Author:
neubig TODO: Add the ability to read configuration files

Field Summary
static int BOOLEAN_TYPE
           
static int FLOAT_TYPE
           
static int INT_ARRAY_TYPE
           
static int INT_TYPE
           
static int STRING_ARRAY_TYPE
           
static int STRING_TYPE
           
 
Constructor Summary
KylmConfigUtils()
          Initialize the class with no usage data to print
KylmConfigUtils(java.lang.String usage)
          Initialize the configuration utilities with usage text to print in case
 
Method Summary
 void addAlias(java.lang.String name, java.lang.String alias)
          Add an alias that points from the long name of a parameter to the short name.
 void addEntry(java.lang.String string)
          Add a boolean entry to the configuration possibilities
 void addEntry(java.lang.String name, int type, java.lang.Object defaultVal)
          Add an entry to the configuration possibilities
 void addEntry(java.lang.String name, int type, java.lang.Object defaultVal, boolean req, java.lang.String desc)
          Add an entry to the configuration possibilities
 void addGroup(java.lang.String string)
           
 void exitOnUsage()
          Exit, printing the usage text.
 void exitOnUsage(int code)
          Exit, printing the usage text
 java.lang.String[] getArguments()
          Get the arguments that are not correlated with a flag
 boolean getBoolean(java.lang.String string)
           
 float getFloat(java.lang.String string)
           
 int getInt(java.lang.String string)
           
 int[] getIntArray(java.lang.String string)
           
 java.lang.String getString(java.lang.String string)
           
 java.lang.String[] getStringArray(java.lang.String string)
           
 java.lang.String getUsage()
          Get the usage text
 java.lang.Object getValue(java.lang.String str)
          Get the value assigned to a certain string ID
 java.lang.String[] parseArguments(java.lang.String[] args)
          Parse command line arguments
 void setUsage(java.lang.String usageText)
          Set the usage text
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_TYPE

public static final int STRING_TYPE
See Also:
Constant Field Values

INT_TYPE

public static final int INT_TYPE
See Also:
Constant Field Values

FLOAT_TYPE

public static final int FLOAT_TYPE
See Also:
Constant Field Values

BOOLEAN_TYPE

public static final int BOOLEAN_TYPE
See Also:
Constant Field Values

STRING_ARRAY_TYPE

public static final int STRING_ARRAY_TYPE
See Also:
Constant Field Values

INT_ARRAY_TYPE

public static final int INT_ARRAY_TYPE
See Also:
Constant Field Values
Constructor Detail

KylmConfigUtils

public KylmConfigUtils()
Initialize the class with no usage data to print


KylmConfigUtils

public KylmConfigUtils(java.lang.String usage)
Initialize the configuration utilities with usage text to print in case

Parameters:
usage - The usage text
Method Detail

addEntry

public void addEntry(java.lang.String name,
                     int type,
                     java.lang.Object defaultVal,
                     boolean req,
                     java.lang.String desc)
Add an entry to the configuration possibilities

Parameters:
name - The name of the entry to be added
type - The type, string, float, integer, boolean
defaultVal - The default value
req - Whether this is required or not
desc - The description of the parameter

addEntry

public void addEntry(java.lang.String name,
                     int type,
                     java.lang.Object defaultVal)
Add an entry to the configuration possibilities

Parameters:
name - The name of the entry to be added
type - The type, string, float, integer, boolean
defaultVal - The default value

addEntry

public void addEntry(java.lang.String string)
Add a boolean entry to the configuration possibilities

Parameters:
string - The name of the entry to be added

addAlias

public void addAlias(java.lang.String name,
                     java.lang.String alias)
Add an alias that points from the long name of a parameter to the short name. (e.g. -classpath = -cp)

Parameters:
name - The long name of the parameter
alias - The short name

parseArguments

public java.lang.String[] parseArguments(java.lang.String[] args)
Parse command line arguments

Parameters:
args - The command line arguments to parse

getValue

public java.lang.Object getValue(java.lang.String str)
Get the value assigned to a certain string ID

Parameters:
str - The string Id of the value
Returns:
The value

getUsage

public java.lang.String getUsage()
Get the usage text

Returns:
The usage text

setUsage

public void setUsage(java.lang.String usageText)
Set the usage text

Parameters:
usageText - The usage text to be printed on -help

getArguments

public java.lang.String[] getArguments()
Get the arguments that are not correlated with a flag

Returns:
The arguments

getBoolean

public boolean getBoolean(java.lang.String string)

getString

public java.lang.String getString(java.lang.String string)

getStringArray

public java.lang.String[] getStringArray(java.lang.String string)

getInt

public int getInt(java.lang.String string)

getFloat

public float getFloat(java.lang.String string)

exitOnUsage

public void exitOnUsage()
Exit, printing the usage text. Default error code is 1.


exitOnUsage

public void exitOnUsage(int code)
Exit, printing the usage text

Parameters:
code - The error code to exit with

getIntArray

public int[] getIntArray(java.lang.String string)

addGroup

public void addGroup(java.lang.String string)