Package org.incenp.obofoundry.odk
Class BasePlugin
java.lang.Object
org.incenp.obofoundry.odk.BasePlugin
- All Implemented Interfaces:
org.obolibrary.robot.Command
- Direct Known Subclasses:
CheckAlignmentCommand,CheckCommand,ImportCommand,NormalizeCommand,SubsetCommand
Helper base class for ROBOT commands.
This class is intended to serve as a base class for ROBOT commands, to avoid
duplicating boilerplate across several commands. Subclasses should call the
constructor with the desired name, description, and help message, add any
option they need, and implement the
performOperation(CommandState, CommandLine) method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.obolibrary.robot.IOHelperprotected org.apache.commons.cli.OptionsFields inherited from interface org.obolibrary.robot.Command
global, missingFileError -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBasePlugin(String name, String desc, String usage) Creates a new command. -
Method Summary
Modifier and TypeMethodDescriptionorg.obolibrary.robot.CommandStateprotected org.semanticweb.owlapi.model.IRICreates an IRI from a user-specified source.getName()org.apache.commons.cli.OptionsgetUsage()voidabstract voidperformOperation(org.obolibrary.robot.CommandState state, org.apache.commons.cli.CommandLine line) Performs whatever operation the command is supposed to do.
-
Field Details
-
options
protected org.apache.commons.cli.Options options -
ioHelper
protected org.obolibrary.robot.IOHelper ioHelper
-
-
Constructor Details
-
BasePlugin
Creates a new command.- Parameters:
name- The command name, as it should be invoked on the command line.desc- The description of the command that ROBOT will display.usage- The help message for the command.
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceorg.obolibrary.robot.Command
-
getDescription
- Specified by:
getDescriptionin interfaceorg.obolibrary.robot.Command
-
getUsage
- Specified by:
getUsagein interfaceorg.obolibrary.robot.Command
-
getOptions
public org.apache.commons.cli.Options getOptions()- Specified by:
getOptionsin interfaceorg.obolibrary.robot.Command
-
main
- Specified by:
mainin interfaceorg.obolibrary.robot.Command
-
execute
public org.obolibrary.robot.CommandState execute(org.obolibrary.robot.CommandState state, String[] args) throws Exception - Specified by:
executein interfaceorg.obolibrary.robot.Command- Throws:
Exception
-
performOperation
public abstract void performOperation(org.obolibrary.robot.CommandState state, org.apache.commons.cli.CommandLine line) throws Exception Performs whatever operation the command is supposed to do.- Parameters:
state- The internal state of ROBOT.line- The command line used to invoke the command.- Throws:
Exception- If any error occurs when attempting to execute the operation.
-
getIRI
Creates an IRI from a user-specified source. This delegates the task of expanding CURIEs to ROBOT, which may use whatever information it has (such as prefix mappings specified on the command line with the--prefixoption).- Parameters:
term- The term to transform into an IRI.field- The source where the term comes from. Used in ROBOT's error message, if the term cannot be transformed into an IRI.- Returns:
- The resulting IRI.
- Throws:
IllegalArgumentException- If the term cannot be transformed into an IRI.
-