opennlp.tools.cmdline
Class TypedCmdLineTool<T>

java.lang.Object
  extended by opennlp.tools.cmdline.CmdLineTool
      extended by opennlp.tools.cmdline.TypedCmdLineTool<T>
Direct Known Subclasses:
AbstractConverterTool, AbstractTypedParamTool

public abstract class TypedCmdLineTool<T>
extends CmdLineTool

Base class for tools which support processing of samples of some type T coming from a stream of a certain format.


Field Summary
protected  Class<T> type
          variable to access the type of the generic parameter.
 
Constructor Summary
protected TypedCmdLineTool(Class<T> sampleType)
          Constructor with type parameters.
 
Method Summary
protected
<A> String
getBasicHelp(Class<A>... argProxyInterfaces)
           
 String getHelp()
          Retrieves a description on how to use the tool.
abstract  String getHelp(String format)
          Retrieves a description on how to use the tool.
protected  ObjectStreamFactory<T> getStreamFactory(String format)
          Returns stream factory for the type of this tool for the format.
abstract  void run(String format, String[] args)
          Executes the tool with the given parameters.
protected
<A> void
validateAllArgs(String[] args, Class<A> argProxyInterface, String format)
          Validates arguments using parameters from argProxyInterface and the parameters of the format.
protected  void validateFactoryArgs(ObjectStreamFactory<T> factory, String[] args)
          Validates arguments for a format processed by the factory.
 
Methods inherited from class opennlp.tools.cmdline.CmdLineTool
getBasicHelp, getName, getShortDescription, hasParams, validateAndParseParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected final Class<T> type
variable to access the type of the generic parameter.

Constructor Detail

TypedCmdLineTool

protected TypedCmdLineTool(Class<T> sampleType)
Constructor with type parameters.

Parameters:
sampleType - class of the template parameter
Method Detail

getStreamFactory

protected ObjectStreamFactory<T> getStreamFactory(String format)
Returns stream factory for the type of this tool for the format.

Parameters:
format - data format name
Returns:
stream factory for the type of this tool for the format

validateAllArgs

protected <A> void validateAllArgs(String[] args,
                                   Class<A> argProxyInterface,
                                   String format)
Validates arguments using parameters from argProxyInterface and the parameters of the format.

Type Parameters:
A - A
Parameters:
args - arguments
argProxyInterface - interface with parameter descriptions
format - data format name

validateFactoryArgs

protected void validateFactoryArgs(ObjectStreamFactory<T> factory,
                                   String[] args)
Validates arguments for a format processed by the factory.

Parameters:
factory - a stream factory
args - arguments

getBasicHelp

protected <A> String getBasicHelp(Class<A>... argProxyInterfaces)
Overrides:
getBasicHelp in class CmdLineTool

getHelp

public String getHelp()
Description copied from class: CmdLineTool
Retrieves a description on how to use the tool.

Specified by:
getHelp in class CmdLineTool
Returns:
a description on how to use the tool

run

public abstract void run(String format,
                         String[] args)
Executes the tool with the given parameters.

Parameters:
format - format to work with
args - command line arguments

getHelp

public abstract String getHelp(String format)
Retrieves a description on how to use the tool.

Parameters:
format - data format
Returns:
a description on how to use the tool


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.