|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.LiveGraph.bootstrap.CommandLineProcessor
public class CommandLineProcessor
This class represents a parser for command line arguments for a LiveGraph application.
LiveGraph (http://www.live-graph.org).
Copyright (c) 2007-2008 by G. Paperin.
File: CommandLineProcessor.java
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the LiveGraph project and its web-site, the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
LiveGraph project and its web-site, the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with
the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the LiveGraph project and its
contributors.
(http://www.live-graph.org)
4. All advertising materials distributed in form of HTML pages or any other technology
permitting active hyper-links that mention features or use of this software or any
derived software must display the acknowledgment specified in condition 3 of this
agreement, and in addition, include a visible and working hyper-link to the LiveGraph
homepage (http://www.live-graph.org).
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Field Summary | |
---|---|
private java.lang.String[] |
args
Command line arguments to parse. |
static java.lang.String |
correctPromptMsg
Message specifying the correct usage of command line argumnts. |
private java.util.List<java.lang.String> |
errMessages
Holds any error messages occured during parsing. |
private java.io.File |
file_Data
The data file if such was parsed. |
private java.io.File |
file_DataFileSettings
The data file settings file if such was parsed. |
private java.io.File |
file_DataSeriesSettings
The data series settings file if such was parsed. |
private java.io.File |
file_GraphSettings
The graph settings file if such was parsed. |
private boolean |
hasError
Flag set when any errors during argument parsing or validation occur. |
static java.lang.String |
newLine
System specific new-line string. |
Constructor Summary | |
---|---|
CommandLineProcessor()
Initialises the parser for an empty command line. |
|
CommandLineProcessor(java.lang.String[] args)
Initialises the parser for the specified command line arguments. |
Method Summary | |
---|---|
private void |
error(int argIndex,
java.lang.String argStr,
java.lang.String... messages)
Logs an error message. |
java.lang.String |
getErrorMessages()
Constructs a String from all error messages that occured during parsing or validation. |
java.io.File |
getFile_Data()
Data file - parsed from the command line. |
java.io.File |
getFile_DataFileSettings()
File for data file settings - either parsed from the command line or the default session file. |
java.io.File |
getFile_DataSeriesSettings()
File for data series settings - either parsed from the command line or the default session file. |
java.io.File |
getFile_GraphSettings()
File for graph settings - either parsed from the command line or the default session file. |
boolean |
hasErrors()
Checks whether any errors have occured. |
private java.io.File |
parseArgFile2(int parseIndex,
java.lang.String argDesc,
java.io.File currValue)
Validates a pair of command line arguments, where the first is a flag and the second is a file path. |
private void |
parseArgs()
Parses the command line arguments for legal settings values. |
private void |
processArgs()
Used internally to process the arguments. |
private void |
setFile_Data(java.io.File f)
Sets the data file -parsed from the command line. |
private void |
setFile_DataFileSettings(java.io.File f)
Sets the file for data file settings - either parsed from the command line or the default session file. |
private void |
setFile_DataSeriesSettings(java.io.File f)
Sets the file for data series settings - either parsed from the command line or the default session file. |
private void |
setFile_GraphSettings(java.io.File f)
Sets the file for graph settings - either parsed from the command line or the default session file. |
private void |
supplementWithDefaults()
If data file, graph or data series settings are not set, checks whether the apropriate session.lgdfs, session.lggs and session.lgdss files are available and, if so, sets the argument values appropriately. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String newLine
public static final java.lang.String correctPromptMsg
private java.util.List<java.lang.String> errMessages
private boolean hasError
private java.lang.String[] args
private java.io.File file_DataFileSettings
private java.io.File file_GraphSettings
private java.io.File file_DataSeriesSettings
private java.io.File file_Data
Constructor Detail |
---|
public CommandLineProcessor()
public CommandLineProcessor(java.lang.String[] args)
args
- Command line arguments.Method Detail |
---|
private void processArgs()
private void supplementWithDefaults()
private void parseArgs()
private java.io.File parseArgFile2(int parseIndex, java.lang.String argDesc, java.io.File currValue)
parseIndex
- The argument index of the flag, i.e. the first argument of the pair.argDesc
- A textual description of the current flag (for megsages).currValue
- The current value for the setting corresponding to the flag.
private void error(int argIndex, java.lang.String argStr, java.lang.String... messages)
argIndex
- Index of the argument to which the error relates.argStr
- The argument to which the error relates.messages
- Error messages.public boolean hasErrors()
true
if at least one error occured during parsing or validation,
false
otherwise.public java.lang.String getErrorMessages()
String
from all error messages that occured during parsing or validation.
null
if no errors have occured.public java.io.File getFile_DataFileSettings()
File
from which LiveGraph should load the data file settings
or null
if no file was set or if the file is not present or cannot be accessed.private void setFile_DataFileSettings(java.io.File f)
f
- Validated File
from which LiveGraph should load the data file settings.public java.io.File getFile_GraphSettings()
File
from which LiveGraph should load the graph settings
or null
if no file was set or if the file is not present or cannot be accessed.private void setFile_GraphSettings(java.io.File f)
f
- Validated File
from which LiveGraph should load the graph settings.public java.io.File getFile_DataSeriesSettings()
File
from which LiveGraph should load the data series settings
or null
if no file was set or if the file is not present or cannot be accessed.private void setFile_DataSeriesSettings(java.io.File f)
f
- Validated File
from which LiveGraph should load the data series settings.public java.io.File getFile_Data()
File
from which LiveGraph should load the data
or null
if no file was set or if the file is not present or cannot be accessed.private void setFile_Data(java.io.File f)
f
- Validated File
from which LiveGraph should load the data.
|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |