MaltParser 1.0.2

org.maltparser.core.options
Class OptionManager

java.lang.Object
  extended by org.maltparser.core.options.OptionManager

public class OptionManager
extends Object

Option Manager is the management class for all option handling. All queries and manipulations of an option or an option value should go through this class.

Since:
1.0
Author:
Johan Hall

Field Summary
static int DEFAULTVALUE
           
 
Constructor Summary
OptionManager()
          Creates the Option Manager
 
Method Summary
 void generateMaps()
          Creates several option maps for fast access to individual options.
 int getNumberOfOptionValues(Integer containerIndex)
          Returns the number of option values for a particular option container.
 OptionDescriptions getOptionDescriptions()
          Returns the option description
 Object getOptionValue(Integer containerIndex, String optiongroup, String optionname)
          Returns the option value for an option that is specified by the option group name and option name.
 Object getOptionValue(String optiongroup, String optionname)
          Returns the option value for an option that is specified by the option group name and the option name.
 String getOptionValueString(Integer containerIndex, String optiongroup, String optionname)
          Returns a string representation of the option value for an option that is specified by the option group name and the option name.
 void loadOptionDescriptionFile()
          Loads the option description file /appdata/options.xml
 void loadOptionDescriptionFile(URL url)
          Loads the option description file
 void loadOptions(InputStreamReader isr)
          Loads the saved options (options that are marked with usage=Option.SAVE).
 void loadOptions(String fileName)
          Loads the saved options (options that are marked with usage=save).
 void overloadOptionValue(Integer containerIndex, String optiongroup, String optionname, String value)
          Overloads the option value specified by the container index, the option group name, the option name.
 void parseCommandLine(String[] args)
          Parses the command line arguments.
 void parseOptionInstanceXMLfile(String fileName)
          Parses the option file for option values.
 void saveOptions(Integer containerIndex, OutputStreamWriter osw)
          Saves all options that are marked as usage=Option.SAVE for a particular option container.
 void saveOptions(Integer containerIndex, String fileName)
          Saves all options that are marked as usage=Option.SAVE for a particular option container.
 void saveOptions(OutputStreamWriter osw)
          Saves all options that are marked as usage=Option.SAVE
 void saveOptions(String fileName)
          Saves all options that are marked as usage=Option.SAVE
 String toString()
           
 String toStringPrettyValues(Integer containerIndex, HashSet<String> excludeGroups)
          Returns a string representation of all option value, except the options in a option group specified by the excludeGroup argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULTVALUE

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

OptionManager

public OptionManager()
Creates the Option Manager

Method Detail

loadOptionDescriptionFile

public void loadOptionDescriptionFile()
                               throws MaltChainedException
Loads the option description file /appdata/options.xml

Throws:
MaltChainedException

loadOptionDescriptionFile

public void loadOptionDescriptionFile(URL url)
                               throws MaltChainedException
Loads the option description file

Parameters:
url - URL of the option description file
Throws:
MaltChainedException

getOptionDescriptions

public OptionDescriptions getOptionDescriptions()
Returns the option description

Returns:
the option description

getOptionValue

public Object getOptionValue(Integer containerIndex,
                             String optiongroup,
                             String optionname)
                      throws MaltChainedException
Returns the option value for an option that is specified by the option group name and option name. The container name points out the specific option container.

Parameters:
containerIndex - The index of the option container (0..n and -1 is default values).
optiongroup - The name of the option group.
optionname - The name of the option.
Returns:
an object that contains the value of the option, null if the option value could not be found.
Throws:
OptionException
MaltChainedException

getOptionValue

public Object getOptionValue(String optiongroup,
                             String optionname)
                      throws MaltChainedException
Returns the option value for an option that is specified by the option group name and the option name.

Parameters:
optiongroup - The name of the option group.
optionname - The name of the option.
Returns:
an object that contains the value of the option, null if the option value could not be found.
Throws:
OptionException
MaltChainedException

getOptionValueString

public String getOptionValueString(Integer containerIndex,
                                   String optiongroup,
                                   String optionname)
                            throws MaltChainedException
Returns a string representation of the option value for an option that is specified by the option group name and the option name. The container name points out the specific option container.

Parameters:
containerIndex - The index of the option container (0..n and -1 is default values).
optiongroup - The name of the option group.
optionname - The name of the option.
Returns:
a string representation of the option value
Throws:
MaltChainedException

overloadOptionValue

public void overloadOptionValue(Integer containerIndex,
                                String optiongroup,
                                String optionname,
                                String value)
                         throws MaltChainedException
Overloads the option value specified by the container index, the option group name, the option name. This method is used to override option that have specific dependencies.

Parameters:
containerIndex - the index of the option container (0..n and -1 is default values).
optiongroup - the name of the option group.
optionname - the name of the option.
value - the option value that should replace the current option value.
Throws:
MaltChainedException

getNumberOfOptionValues

public int getNumberOfOptionValues(Integer containerIndex)
Returns the number of option values for a particular option container.

Parameters:
containerIndex - The index of the option container (0..n).
Returns:
the number of option values for a particular option container.

loadOptions

public void loadOptions(String fileName)
                 throws MaltChainedException
Loads the saved options (options that are marked with usage=save).

Parameters:
fileName - The path to the file where to load the saved options.
Throws:
MaltChainedException

loadOptions

public void loadOptions(InputStreamReader isr)
                 throws MaltChainedException
Loads the saved options (options that are marked with usage=Option.SAVE).

Parameters:
isr - the input stream reader of the saved options file.
Throws:
MaltChainedException

saveOptions

public void saveOptions(String fileName)
                 throws MaltChainedException
Saves all options that are marked as usage=Option.SAVE

Parameters:
fileName - The path to the file where the saveOption should by saved.
Throws:
MaltChainedException

saveOptions

public void saveOptions(OutputStreamWriter osw)
                 throws MaltChainedException
Saves all options that are marked as usage=Option.SAVE

Parameters:
osw - the output stream writer of the saved option file
Throws:
MaltChainedException

saveOptions

public void saveOptions(Integer containerIndex,
                        String fileName)
                 throws MaltChainedException
Saves all options that are marked as usage=Option.SAVE for a particular option container.

Parameters:
containerIndex - The index of the option container (0..n).
fileName - The path to the file where the saveOption should by saved.
Throws:
MaltChainedException

saveOptions

public void saveOptions(Integer containerIndex,
                        OutputStreamWriter osw)
                 throws MaltChainedException
Saves all options that are marked as usage=Option.SAVE for a particular option container.

Parameters:
containerIndex - The index of the option container (0..n).
osw - the output stream writer of the saved option file
Throws:
MaltChainedException

generateMaps

public void generateMaps()
                  throws MaltChainedException
Creates several option maps for fast access to individual options.

Throws:
OptionException
MaltChainedException

parseCommandLine

public void parseCommandLine(String[] args)
                      throws MaltChainedException
Parses the command line arguments.

Parameters:
args - An array of arguments that are supplied when starting the application.
Throws:
OptionException
MaltChainedException

parseOptionInstanceXMLfile

public void parseOptionInstanceXMLfile(String fileName)
                                throws MaltChainedException
Parses the option file for option values.

Parameters:
fileName - The option file name (must be a xml file).
Throws:
OptionException
MaltChainedException

toStringPrettyValues

public String toStringPrettyValues(Integer containerIndex,
                                   HashSet<String> excludeGroups)
                            throws MaltChainedException
Returns a string representation of all option value, except the options in a option group specified by the excludeGroup argument.

Parameters:
containerIndex - The index of the option container (0..n and -1 is default values).
excludeGroups - a set of option group names that should by excluded in the string representation
Returns:
a string representation of all option value
Throws:
MaltChainedException

toString

public String toString()
Overrides:
toString in class Object

MaltParser 1.0.2

Copyright 2007 Johan Hall, Jens Nilsson and Joakim Nivre.