bpiwowar.argparser.handlers
Class GenericObjectsHandler

java.lang.Object
  extended by bpiwowar.argparser.handlers.Handler
      extended by bpiwowar.argparser.handlers.GenericHandler
          extended by bpiwowar.argparser.handlers.GenericObjectsHandler
Direct Known Subclasses:
BooleanHandler, CharSetHandler, ClassChooser, EnumHandler, FileCollectionHandler, FileHandler, FileStringMapHandler, FileStringSetHandler, FloatingPointHandler, IntegerCollectionHandler, IntegerHandler, PatternHandler, StringArrayHandler, StringCollectionHandler, StringConstructorHandler, StringHandler, XStreamHandler

public abstract class GenericObjectsHandler
extends GenericHandler

Author:
Benjamin Piwowarski

Field Summary
protected  int nbExpectedValues
           
 
Fields inherited from class bpiwowar.argparser.handlers.GenericHandler
field, object
 
Constructor Summary
GenericObjectsHandler(Object object, Field field)
          Deprecated. 
GenericObjectsHandler(Object object, Field field, Class<?> aClass)
          Construct a new wrapper
 
Method Summary
protected  void addValue(Object value)
          Add a new value
protected  Object get()
          Get the value of the object
protected
<T extends Annotation>
T
getAnnotation(Class<T> aClass)
           
protected  Object getValue(ArgParser argParser, String arg)
           
protected  Object newInstance()
          Creates a new instance of the field (if it makes sense)
 void optionSet()
           
 int parse(ArgParser argParser, String[] args, int idx)
          Parse the arguments from the current index
protected  Object process(ArgParser argParser, String value)
           
protected  Object process(ArgParser argParser, StringScanner scanner)
           
 
Methods inherited from class bpiwowar.argparser.handlers.Handler
add, getLimitChecker, getLimitChecker, getRangeChecker, isHelpOption, processAnnotations, setPrefix, updateRangeChecker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nbExpectedValues

protected int nbExpectedValues
Constructor Detail

GenericObjectsHandler

@Deprecated
public GenericObjectsHandler(Object object,
                                        Field field)
Deprecated. 

Use GenericObjectsHandler(Object, Field, Class)

Parameters:
object -
field -

GenericObjectsHandler

public GenericObjectsHandler(Object object,
                             Field field,
                             Class<?> aClass)
Construct a new wrapper

Parameters:
object - The object (either holder, or containing a holder field)
field - The field of the object (or null if the holder is the object)
Method Detail

parse

public final int parse(ArgParser argParser,
                       String[] args,
                       int idx)
                throws ArgParseException,
                       StringScanException,
                       IllegalArgumentValue
Description copied from class: Handler
Parse the arguments from the current index

Specified by:
parse in class Handler
Parameters:
argParser - the argument parser
args - The set of arguments
idx - The index of the next argument at process
Throws:
ArgParseException
StringScanException
IllegalArgumentValue - If the parameter is not OK

process

protected Object process(ArgParser argParser,
                         String value)
                  throws StringScanException,
                         ArgParseException,
                         IllegalArgumentValue
Throws:
StringScanException
ArgParseException
IllegalArgumentValue

process

protected Object process(ArgParser argParser,
                         StringScanner scanner)
                  throws StringScanException,
                         ArgParseException,
                         IllegalArgumentValue
Throws:
StringScanException
ArgParseException
IllegalArgumentValue

getValue

protected Object getValue(ArgParser argParser,
                          String arg)
                   throws ArgParseException
Throws:
ArgParseException

optionSet

public void optionSet()

addValue

protected void addValue(Object value)
Add a new value

Parameters:
value - The value

get

protected Object get()
Get the value of the object

Returns:

newInstance

protected Object newInstance()
Creates a new instance of the field (if it makes sense)

Returns:
A freshly created object

getAnnotation

protected <T extends Annotation> T getAnnotation(Class<T> aClass)


Copyright © 2013. All Rights Reserved.