本文整理汇总了Java中org.kohsuke.args4j.spi.Parameters类的典型用法代码示例。如果您正苦于以下问题:Java Parameters类的具体用法?Java Parameters怎么用?Java Parameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameters类属于org.kohsuke.args4j.spi包,在下文中一共展示了Parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = params.getParameter(0);
if (param == null) {
setter.addValue(true);
return 0;
} else {
String lowerParam = param.toLowerCase();
if (TRUES.contains(lowerParam)) {
setter.addValue(true);
} else if (FALSES.contains(lowerParam)) {
setter.addValue(false);
} else {
throw new CmdLineException(owner,
"Illegal boolean value: " + lowerParam);
}
return 1;
}
}
示例2: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
log.info("Parsing: " + params);
// Different compared to BooleanOptionHandler
if (!option.isArgument()) {
String valueStr = params.getParameter(0).toLowerCase();
int index = ACCEPTABLE_VALUES.indexOf(valueStr);
if (index == -1) {
// TODO Check
Localizable localizable = null;
throw new CmdLineException(theParser, localizable, Messages.ILLEGAL_BOOLEAN.format(valueStr));
}
setter.addValue(index < ACCEPTABLE_VALUES.size() / 2);
return 1;
} else {
setter.addValue(true);
return 0;
}
}
开发者ID:karstengresch,项目名称:chordelia,代码行数:20,代码来源:KombinationsberechnungParameterJaNeinOptionHandler.java
示例3: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
/**
* Tries to parse {@code String[]} argument from {@link Parameters}.
*/
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
int counter = 0;
for (; counter < params.size(); counter++)
{
String param = params.getParameter(counter);
boolean nextAlpha = false;
if (param.length() > 1 && Character.isAlphabetic(param.charAt(1)))
nextAlpha = true;
if (param.startsWith("-") && nextAlpha)
break;
setter.addValue(param);
}
return counter;
}
示例4: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
if (type.equals(STRING)) {
setter.addValue(Optional.of(params.getParameter(0)));
return 1;
}
if (type.equals(PATH)) {
final Path p = Paths.get(params.getParameter(0));
setter.addValue(Optional.of(p));
return 1;
}
if (type.equals(INTEGER)) {
setter.addValue(Optional.of(Integer.parseInt(params.getParameter(0))));
return 1;
}
if (type.equals(LONG)) {
setter.addValue(Optional.of(Long.parseLong(params.getParameter(0))));
return 1;
}
throw new IllegalArgumentException("Unsupported type: " + type);
}
示例5: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public final int parseArguments(Parameters params) throws CmdLineException {
final String value = params.getParameter(0);
short context;
if ("all".equalsIgnoreCase(value)) {
context = DiffPreferencesInfo.WHOLE_FILE_CONTEXT;
} else {
try {
context = Short.parseShort(value, 10);
if (context < 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException e) {
throw new CmdLineException(
owner,
String.format(
"\"%s\" is not a valid value for \"%s\"",
value, ((NamedOptionDef) option).name()));
}
}
setter.addValue(context);
return 1;
}
示例6: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = null;
try {
param = params.getParameter(0);
} catch (CmdLineException expected) {
}
if (param == null) {
setter.addValue(true);
return 0;
} else {
String lowerParam = param.toLowerCase();
if (TRUES.contains(lowerParam)) {
setter.addValue(true);
} else if (FALSES.contains(lowerParam)) {
setter.addValue(false);
} else {
setter.addValue(true);
return 0;
}
return 1;
}
}
示例7: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = null;
try {
param = params.getParameter(0);
} catch (CmdLineException e) {}
if (param == null) {
setter.addValue(true);
return 0;
} else {
String lowerParam = param.toLowerCase();
if (TRUES.contains(lowerParam)) {
setter.addValue(true);
} else if (FALSES.contains(lowerParam)) {
setter.addValue(false);
} else {
setter.addValue(true);
return 0;
}
return 1;
}
}
示例8: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = null;
try {
param = params.getParameter(0);
} catch (CmdLineException e) {
param = null; // to stop linter complaints
}
if (param == null) {
setter.addValue(true);
return 0;
} else {
String lowerParam = Ascii.toLowerCase(param);
if (TRUES.contains(lowerParam)) {
setter.addValue(true);
} else if (FALSES.contains(lowerParam)) {
setter.addValue(false);
} else {
setter.addValue(true);
return 0;
}
return 1;
}
}
示例9: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String parameter = params.getParameter(0);
// An empty string should be null
if (parameter.isEmpty()) {
setter.addValue(null);
} else {
setter.addValue(
instantiateObject(
((NamedOptionDef) option).name(),
"plugin module",
Module.class,
((SoyCmdLineParser) this.owner).pluginLoader,
parameter));
}
return 1;
}
示例10: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String name = params.getParameter(0);
CliCommand handler = getHandler(name);
if (handler == null) throw new CmdLineException(
owner, "Command \"" + name + "\" not found"
);
setter.addValue(handler);
// Collect subcommand arguments
int paramCount = params.size();
String[] subCommandParams = new String[paramCount - 1];
for (int i = 1; i < paramCount; i++) {
subCommandParams[i - 1] = params.getParameter(i);
}
new CmdLineParser(handler).parseArgument(subCommandParams);
return params.size(); // All arguments consumed
}
示例11: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = null;
try {
param = params.getParameter(0);
} catch (CmdLineException e) {
param = null; // to stop linter complaints
}
if (param == null) {
setter.addValue(true);
return 0;
} else {
String lowerParam = param.toLowerCase();
if (TRUES.contains(lowerParam)) {
setter.addValue(true);
} else if (FALSES.contains(lowerParam)) {
setter.addValue(false);
} else {
setter.addValue(true);
return 0;
}
return 1;
}
}
示例12: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
int counter = 0;
boolean hasValues = false;
while (counter < params.size()) {
String param = params.getParameter(counter);
if (!param.isEmpty() && param.charAt(0) == '-') {
break;
}
hasValues = true;
builder.add(param);
counter++;
}
Preconditions.checkArgument(hasValues, "Option \"%s\" takes one or more operands", option);
return counter;
}
示例13: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
/** Tries to parse {@code String[]} argument from {@link Parameters}. */
@Override
public int parseArguments(Parameters params) throws CmdLineException {
int counter = 0;
for (; counter < params.size(); counter++) {
String param = params.getParameter(counter);
// Special case the -- separator
if (param.startsWith("-") && !param.equals(QueryCommand.SET_SEPARATOR)) {
break;
}
setter.addValue(param);
}
return counter;
}
示例14: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
ArrayList<String> genArgs = new ArrayList<>();
for (int ix = 0; ix < params.size(); ix++) {
genArgs.add(params.getParameter(ix));
}
this.setter.addValue(new GeneratorArgs(params));
return params.size();
}
示例15: parseArguments
import org.kohsuke.args4j.spi.Parameters; //导入依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
if (params.size() != 1)
throw new CmdLineException ("an option of type log level should have one parameter [trace,debug,info,warn,error,fatal,off]");
Level result = Level.toLevel(params.getParameter(0).toLowerCase());
setter.addValue(result);
log.debug("set log level " + result);
return 1;
}