Package org.kohsuke.args4j.spi

## Class StringArrayOptionHandler

- java.lang.Object
- - org.kohsuke.args4j.spi.OptionHandler<java.lang.String>
  - - org.kohsuke.args4j.spi.StringArrayOptionHandler

    public class StringArrayOptionHandler
    extends OptionHandler<java.lang.String>

An `OptionHandler` for greedily mapping a list of tokens into a collection of `String`s (such as `String[]`, `List<String>`, etc.).

# How it works:

Example for parameter `-s`, which is type `String[]`:

     java -jar aaa.jar -s banan hruska jablko
     java -jar aaa.jar -s banan "hruska jablko"
     java -jar aaa.jar -s "banan hruska jablko"
     java -jar aaa.jar -s banan hruska jablko -l 4 -r
     java -jar aaa.jar -t 222 -s banan hruska jablko -r

All of them result in a single string array that contains three tokens: `banan`, `hruska`, and `jablko`.

This `OptionHandler` scans for parameter which begins with `-`. If found, it will stop.

Author:
  PlainText,LuVar

### Field Summary

### Fields inherited from class org.kohsuke.args4j.spi.OptionHandler

`option, owner, setter`

### Constructor Summary

Constructors
`StringArrayOptionHandler​(CmdLineParser parser, OptionDef option, Setter<java.lang.String> setter)`

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `getDefaultMetaVariable()` Returns `"STRING[]"`.
`int` `parseArguments​(Parameters params)` Tries to parse `String[]` argument from `Parameters`.

### Methods inherited from class org.kohsuke.args4j.spi.OptionHandler

`getMetaVariable, getNameAndMeta, getNameAndMeta, print, printDefaultValue`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StringArrayOptionHandler

    public StringArrayOptionHandler​(CmdLineParser parser,
                                    OptionDef option,
                                    Setter<java.lang.String> setter)

### Method Detail

#### getDefaultMetaVariable

    public java.lang.String getDefaultMetaVariable()

Returns `"STRING[]"`.

Specified by:
  `getDefaultMetaVariable` in class `OptionHandler<java.lang.String>`
Returns:
  return "STRING[]";

#### parseArguments

    public int parseArguments​(Parameters params)
                       throws CmdLineException

Tries to parse `String[]` argument from `Parameters`.

Specified by:
  `parseArguments` in class `OptionHandler<java.lang.String>`
Parameters:
  `params` - The rest of the arguments. This method can use this object to access the arguments of the option if necessary. The object is valid only during the method call.
Returns:
  The number of arguments consumed. (For example, returns `0` if this option doesn't take any parameters.)
Throws:
  `CmdLineException`