java.lang.Object
anbxj.AnBx_CommandLine_Parser<R,C>
- Type Parameters:
R
- The type of role enumeration.C
- The type of channels enumerators.
An abstract class for parsing command line arguments.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Properties
Configuration file, set via command line parameters.protected static Crypto_Config
Configuration for cryptography, set via command line parameters.protected static Channel_SSLChannelType
Default SSL channel type, overridden by command line parameters.protected static String
Path to the key file, set via command line parameters.protected AnBx_Layers
The layer for the application.protected static String
Alias for identification, set via command line parameters.protected static String
Name of the protocol, set via command line parameters.protected R
Role enumeration, set via command line parameters.protected static long
Number of sessions for the protocol run, set via command line parameters.protected static String
Path to the shared resources, set via command line parameters.protected static boolean
Verbose flag, set via command line parameters. -
Constructor Summary
ConstructorsConstructorDescriptionAnBx_CommandLine_Parser
(String[] args, String prot, String configName, Class<R> roles, boolean vflag) Create a AnBx_CommandLine_ParserAnBx_CommandLine_Parser
(String[] args, String prot, String configName, Class<R> roles, boolean vflag, boolean parseFullArgs) Create a AnBx_CommandLine_Parser -
Method Summary
Modifier and TypeMethodDescriptionprotected Properties
Loads the properties from the config filegetRole()
Get the role nameprotected R
getRoleShare
(Class<R> roles) Gets the role used to share information during the protocol setupprotected abstract void
Initialise the protocolprotected void
initRole
(Channel_SSLChannelType ct, R role, Map<String, Channel_Settings> cs, Map<String, String> aliases, Class<R> roles, Class<C> channels) Initialise the roleprotected boolean
isFirstRole
(C channel, R role) Get the sender role in a channelprotected void
Reads the properties from the config fileprotected void
setLayer
(AnBx_Layers layer) Set the debug levelprotected static void
Terminates the protocol after an error occurs and prints a messageprotected static void
Terminates the protocol after an error occurs and prints a message along with the arguments passed.static String
usage()
Computes the usage string for the given protocol
-
Field Details
-
ct
Default SSL channel type, overridden by command line parameters. -
layer
The layer for the application. -
keypath
Path to the key file, set via command line parameters. -
myAlias
Alias for identification, set via command line parameters. -
crypto_config
Configuration for cryptography, set via command line parameters. -
role
Role enumeration, set via command line parameters. -
configFile
Configuration file, set via command line parameters. -
protname
Name of the protocol, set via command line parameters. -
sessions
protected static long sessionsNumber of sessions for the protocol run, set via command line parameters. -
vflag
protected static boolean vflagVerbose flag, set via command line parameters.
-
-
Constructor Details
-
AnBx_CommandLine_Parser
public AnBx_CommandLine_Parser(String[] args, String prot, String configName, Class<R> roles, boolean vflag) Create a AnBx_CommandLine_Parser- Parameters:
args
- the command line argumentsprot
- the protocol nameconfigName
- the name of the config fileroles
- the protocol roles enumeratorvflag
- true = verbose mode, false = silent mode
-
AnBx_CommandLine_Parser
public AnBx_CommandLine_Parser(String[] args, String prot, String configName, Class<R> roles, boolean vflag, boolean parseFullArgs) Create a AnBx_CommandLine_Parser- Parameters:
args
- the command line argumentsprot
- the protocol nameconfigName
- the name of the config fileroles
- the protocol roles enumeratorvflag
- true = verbose mode, false = silent modeparseFullArgs
- true = parsing a standard application (all arguments accepted), false = parsing a setup application (fewer arguments accepted)
-
-
Method Details
-
setLayer
Set the debug level- Parameters:
layer
- the debugging layer- See Also:
-
usage
Computes the usage string for the given protocol- Returns:
- the usage string
-
initProtocol
protected abstract void initProtocol()Initialise the protocol -
terminate
Terminates the protocol after an error occurs and prints a message- Parameters:
msg
- the error message to be printed
-
terminate
Terminates the protocol after an error occurs and prints a message along with the arguments passed.- Parameters:
msg
- The error message to be printed.args
- The array of arguments to be included in the error message.
-
getRole
Get the role name- Returns:
- the role name
-
isFirstRole
Get the sender role in a channel- Parameters:
channel
- the specified channelrole
- the specified role- Returns:
- true if R is the first role in channel C
-
getConfigFile
Loads the properties from the config file- Returns:
- the properties object read from the config file
-
readConfigFile
Reads the properties from the config file- Parameters:
aliases
- mapping channel names to channel settingsroles
- the protocol roles enumeratorrole
- the protocol role
-
initRole
protected void initRole(Channel_SSLChannelType ct, R role, Map<String, Channel_Settings> cs, Map<String, String> aliases, Class<R> roles, Class<C> channels) Initialise the role- Parameters:
ct
- the channel typerole
- the protocol rolecs
- mapping channel names to channel settingsaliases
- mapping role names with aliases (identifies)roles
- the protocol roles enumeratorchannels
- the protocol channels enumerator
-