Lvg Java
2006p Version

gov.nih.nlm.nls.lvg.Api
Class LvgCmdApi

java.lang.Object
  extended by gov.nih.nlm.nls.lvg.CmdLineSyntax.SystemOption
      extended by gov.nih.nlm.nls.lvg.Api.LvgCmdApi
Direct Known Subclasses:
LvgLexItemApi

public class LvgCmdApi
extends SystemOption

This class provides an LVG API for users to setup flows by defining a Lvg command. Two methods, ProcessLine( ) and Mutate( ) are used for flow mutation for the case of using interface prompt or not. The input of this API is a term (string). The output is a Vector composes of Lvg ouputs in the string format.

All LVG API consists methods for three phases:

History:

Version:
V-2006p
Author:
NLM NLS Development Team
See Also:
Design Document

Field Summary
protected  int catFieldNum_
           
protected  java.util.Vector flowStrs_
           
protected  java.util.Vector flowStrsList_
           
protected  int inflFieldNum_
           
protected static java.io.BufferedReader inReader_
           
protected  boolean promptFlag_
           
protected  java.util.Vector quitStrList_
           
protected  boolean runFlag_
           
protected  int termFieldNum_
           
 
Fields inherited from class gov.nih.nlm.nls.lvg.CmdLineSyntax.SystemOption
systemOption_
 
Constructor Summary
LvgCmdApi()
          Creates an LvgCmdApi object and initiate related data (default).
LvgCmdApi(java.util.Hashtable properties)
          Creates an LvgCmdApi object and initiate related data with properties to be overwritten in configuration.
LvgCmdApi(java.lang.String optionStr)
          Creates an LvgApi object, initiate related data, using a command string.
LvgCmdApi(java.lang.String optionStr, java.util.Hashtable properties)
          Creates an LvgApi object, initiate related data, using a command string with properties to be overwritten in configuration.
LvgCmdApi(java.lang.String optionStr, java.lang.String configFile)
          Creates an LvgApi object, initiate related data, using a command string and the path of configuration file.
LvgCmdApi(java.lang.String optionStr, java.lang.String configFile, java.util.Hashtable properties)
          Creates an LvgApi object, initiate related data, using a command string and the path of configuration file with properties to be overwritten in configuration.
 
Method Summary
 void CleanUp()
          Close Lvg database connection and persistent tries.
protected  void DefineFlag()
          Define the Lvg system option by defining a string.
protected  void ExecuteCommand(OptionItem optionItem, Option systemOption)
          Execute Lvg command for a specified option item in a given system option.
protected  java.util.Vector ExecuteFlow(LexItem in, java.lang.String flowStr)
          Execute a specified Lvg flow transformation for a given LexItem.
 java.sql.Connection GetConnection()
          Get the Db connection
 LvgFlowSpecificOption GetFlowSpecificOptions()
          Get Lvg Flow Specific Options
 LvgOutputOption GetLvgOutputOption()
          Get Lvg Output Option.
protected  void GetPrompt()
          Get the Lvg interface prompt and print it out to system output.
 boolean IsLegalOption()
          Check if the input command is legal.
 void Mutate(java.lang.String inTerm)
          Performs flow mutation by processing the input term.
 java.lang.String MutateToString(java.lang.String inTerm)
          Performs flow mutation by processing the input term and return the result as a string.
static void PrintLvgHelp()
          Print out the Lvg help menu.
 boolean ProcessLine()
          Performs flow mutation by processing the input line (term).
 void SetMinTermLength(int minTermLength)
          Set minimum Trie Length
 void SetOption(java.lang.String optionStr)
          Set the Lvg command for flows.
 void SetPromptStr(java.lang.String promptStr)
          Set the prompt string.
 void SetQuitStrList(java.util.Vector quitStrList)
          Set a list for quiting the program while using Lvg prompt interface.
 
Methods inherited from class gov.nih.nlm.nls.lvg.CmdLineSyntax.SystemOption
CheckOption, CheckSyntax, ExecuteCommands, GetOption, ToBoolean, ToFloatArray, ToIntArray, ToStringArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quitStrList_

protected java.util.Vector quitStrList_

runFlag_

protected boolean runFlag_

inReader_

protected static java.io.BufferedReader inReader_

flowStrs_

protected java.util.Vector flowStrs_

flowStrsList_

protected java.util.Vector flowStrsList_

termFieldNum_

protected int termFieldNum_

catFieldNum_

protected int catFieldNum_

inflFieldNum_

protected int inflFieldNum_

promptFlag_

protected boolean promptFlag_
Constructor Detail

LvgCmdApi

public LvgCmdApi()
Creates an LvgCmdApi object and initiate related data (default). This constructor is consider as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object


LvgCmdApi

public LvgCmdApi(java.lang.String optionStr)
Creates an LvgApi object, initiate related data, using a command string. This constructor is considered as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object

Parameters:
optionStr - the initial lvg option string

LvgCmdApi

public LvgCmdApi(java.lang.String optionStr,
                 java.lang.String configFile)
Creates an LvgApi object, initiate related data, using a command string and the path of configuration file. This constructor is considered as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object

Parameters:
optionStr - the initial lvg option string
configFile - the absolute path of the configuration file

LvgCmdApi

public LvgCmdApi(java.util.Hashtable properties)
Creates an LvgCmdApi object and initiate related data with properties to be overwritten in configuration. This constructor is consider as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object

Parameters:
properties - properties to be overwrite in configuration

LvgCmdApi

public LvgCmdApi(java.lang.String optionStr,
                 java.util.Hashtable properties)
Creates an LvgApi object, initiate related data, using a command string with properties to be overwritten in configuration. This constructor is considered as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object

Parameters:
optionStr - the initial lvg option string
properties - properties to be overwrite in configuration

LvgCmdApi

public LvgCmdApi(java.lang.String optionStr,
                 java.lang.String configFile,
                 java.util.Hashtable properties)
Creates an LvgApi object, initiate related data, using a command string and the path of configuration file with properties to be overwritten in configuration. This constructor is considered as a preprocess method.

CleanUp( ) method must be called to close Db connection after using this object

Parameters:
optionStr - the initial lvg option string
configFile - the absolute path of the configuration file
properties - properties to be overwrite in configuration
Method Detail

SetPromptStr

public void SetPromptStr(java.lang.String promptStr)
Set the prompt string. This method allows users to set their customerized prompt string for using Lvg prompt interface.

Parameters:
promptStr - the customerized prompt string

SetQuitStrList

public void SetQuitStrList(java.util.Vector quitStrList)
Set a list for quiting the program while using Lvg prompt interface.

Parameters:
quitStrList - a Vector coposed of string for quiting program

IsLegalOption

public boolean IsLegalOption()
Check if the input command is legal.

Returns:
true or false if the input command is legal or illegal

SetOption

public void SetOption(java.lang.String optionStr)
Set the Lvg command for flows.

Parameters:
optionStr - Lvg command for flows

GetLvgOutputOption

public LvgOutputOption GetLvgOutputOption()
Get Lvg Output Option.

Returns:
lvg output option object

GetConnection

public java.sql.Connection GetConnection()
Get the Db connection

Returns:
Connection lvg database connection

CleanUp

public void CleanUp()
Close Lvg database connection and persistent tries. This methods must be called before exiting LvgCmdApi. It is a method from post process.


ProcessLine

public boolean ProcessLine()
                    throws java.sql.SQLException,
                           java.io.IOException
Performs flow mutation by processing the input line (term). This method provides Lvg command line interface prompt, read input term from system input or from a file. The result of this method include output filter.

Returns:
true or false if the input line is not or is to quit the program
Throws:
java.sql.SQLException
java.io.IOException

PrintLvgHelp

public static void PrintLvgHelp()
Print out the Lvg help menu.


Mutate

public void Mutate(java.lang.String inTerm)
            throws java.lang.Exception
Performs flow mutation by processing the input term. The result of this method also include go through all output filter.

Parameters:
inTerm - the term to be mutated.
Throws:
java.lang.Exception

MutateToString

public java.lang.String MutateToString(java.lang.String inTerm)
                                throws java.lang.Exception
Performs flow mutation by processing the input term and return the result as a string. The result of this method also include go through all output filter.

Parameters:
inTerm - the term to be mutated.
Returns:
the Lvg output result as a string
Throws:
java.lang.Exception

GetFlowSpecificOptions

public LvgFlowSpecificOption GetFlowSpecificOptions()
Get Lvg Flow Specific Options

Returns:
the object of flow specific options

SetMinTermLength

public void SetMinTermLength(int minTermLength)
Set minimum Trie Length

Parameters:
minTermLength - minimum trie term length

ExecuteCommand

protected void ExecuteCommand(OptionItem optionItem,
                              Option systemOption)
Execute Lvg command for a specified option item in a given system option. This function needs to be modified if adding a new flow option.

Specified by:
ExecuteCommand in class SystemOption
Parameters:
optionItem - the option to be executed
systemOption - the system option that the option item will be run on

DefineFlag

protected void DefineFlag()
Define the Lvg system option by defining a string. This function needs to be modified if adding a new flow option.

Specified by:
DefineFlag in class SystemOption

GetPrompt

protected void GetPrompt()
                  throws java.io.IOException
Get the Lvg interface prompt and print it out to system output.

Throws:
java.io.IOException

ExecuteFlow

protected java.util.Vector ExecuteFlow(LexItem in,
                                       java.lang.String flowStr)
                                throws java.sql.SQLException
Execute a specified Lvg flow transformation for a given LexItem.

Notes This function needs to be modified if adding a new flow option.

Parameters:
in - the LexItem to be transformed
flowStr - the specified flow in a string format
Returns:
a Vector of output LexItems
Throws:
java.sql.SQLException

Lvg Java
2006p Version

Submit a bug or feature

Copyright © 2006p National Library of Medicine